From 3e85ea83179fd377a8da5575415589141f27e4e1 Mon Sep 17 00:00:00 2001 From: Zhangwen <13970730+mkc46119@user.noreply.gitee.com> Date: Tue, 11 Jun 2024 16:41:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B3=A2=E7=89=B9=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- keilp/stcTTSS2_W5.uvprojx | 54 +++++++++++++++++++------- source/bsp/TTSSbsp/bsp_config.h | 2 +- source/debug/debug_drv.c | 4 +- source/msp/uart/msp_uart1.c | 68 ++++++--------------------------- 4 files changed, 55 insertions(+), 73 deletions(-) diff --git a/keilp/stcTTSS2_W5.uvprojx b/keilp/stcTTSS2_W5.uvprojx index d6a9b7f..b9ecc38 100644 --- a/keilp/stcTTSS2_W5.uvprojx +++ b/keilp/stcTTSS2_W5.uvprojx @@ -10,7 +10,6 @@ STC8H3K64S2 0x0 MCS-51 - 0 STC8H3K64S4 Series @@ -124,6 +123,47 @@ 0 16 + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + + + 0 + 1 + 0 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + + 0 + -1 + + + + + + + + + + + + + + + @@ -177,14 +217,12 @@ 0 0 0 - 0 0 0 0 0 0 0 - 0 0 0 0 @@ -254,16 +292,6 @@ 0x0 0x0 - - 0 - 0x0 - 0x0 - - - 0 - 0x0 - 0x0 - diff --git a/source/bsp/TTSSbsp/bsp_config.h b/source/bsp/TTSSbsp/bsp_config.h index 81808b4..2f2f597 100644 --- a/source/bsp/TTSSbsp/bsp_config.h +++ b/source/bsp/TTSSbsp/bsp_config.h @@ -166,7 +166,7 @@ //串口配置 /// #define D_UART1_BRT BRT_460800 /// #define D_UART1_BRT BRT_921600 -#define D_UART1_BRT BRT_115200 +#define D_UART1_BRT BRT_9600 #define D_UART1_SBIT SBIT_1 #define D_PIN_UART1 PIN_UART1_Rxd_30_Txd_31 #define D_UART2_BRT BRT_115200///BRT_921600///BRT_115200/// diff --git a/source/debug/debug_drv.c b/source/debug/debug_drv.c index b285916..7e081d7 100644 --- a/source/debug/debug_drv.c +++ b/source/debug/debug_drv.c @@ -119,7 +119,7 @@ u8 L3_tpc_hex(void) return 1; } } - printfs("\r\n cmd error!!"); + // printfs("\r\n cmd error!!"); return 0; } #endif @@ -132,7 +132,7 @@ vtype L2_debug_ONcomand(void) { ts_Urec[D_UART1].debugok = 0;////解析协议 /// printf("\r\nw ts_Urec[D_UART1].max = %d num = %d",(int)ts_Urec[D_UART1].rmax,(int)ts_Urec[D_UART1].num); - printf1("\r\ndebugok %2x",(int)ts_Urec[D_UART1].debugok); + // printf1("\r\ndebugok %2x",(int)ts_Urec[D_UART1].debugok); } if(1 == ts_Urec[D_UART1].ok) diff --git a/source/msp/uart/msp_uart1.c b/source/msp/uart/msp_uart1.c index 568d3e9..915db29 100644 --- a/source/msp/uart/msp_uart1.c +++ b/source/msp/uart/msp_uart1.c @@ -1,60 +1,3 @@ - -////////////////////////////////////////////////////////////////////////// -/// COPYRIGHT NOTICE -/// Copyright (c) 2023 CCSENS -/// All rights reserved. -/// -/// @file main.c -/// @brief main app -/// -///(本文件实现的功能的详述) -/// -/// @version 1.1 CCsens technology -/// @author CC -/// @date 20150102 -/// -/// -/// 修订说明:最初版本 -/// Modified by: -/// Modified date: -/// Version: -/// Descriptions: -// 20160413 CC-ACC-VH02 -// 连接至 J22 RXD0 TXD0 -//P5_DIR &= ~BITN1; //p5.1输出TXD -//P5_DIR |= BITN0; //p5.0输入RXD -//P5_SEL0 &= ~(BITN0 +BITN1); //设置P5.0 P5.1为uart1 RXD TXD -//P5_SEL1 |= BITN0 +BITN1; - -/***************************************************************************** -update by cc @201700110 -针对多串口 和 单一串口 有区别 每个串口是独立的还是分开的有讲究 程序是复杂的还是软件应用简单是 -个需要平衡的事情. - -c_lib/c_lib.c: -公用的函数 和硬件无关 -放置串行模式(串口等其他通讯总线类的输出)输出的函数, -一些覆盖模式输出的(lcd等固屏输出的)的也可使用 - void Lc_print(void (*L0pf_send_uc)(char ww), char *dat,...) ------------------------------------------------------------------------------------------ -uartcom/Uprotocol2app - 协议到应用 - 为了适应不同的通讯协议需要不同的uart口来对应 和应用相关 - -typedef struct _ts_lcm_pro_; 应用协议包的定义? LCM的协议------------ - L3_UARTcom0_exp_protocol 解析应用协议 ------------------------------------------------------------------------------------------ -uartcom/urec2protocol: 接收到的数据放入到指向特定协议的缓存中,和协议的格式有关 一般分为 标头式或者标尾式 -公用的串口通讯定义 - struct _s_uart_rec_ 的公共协议包(关键的结构体)的声明------struct _s_uart_rec_ - void L1_uart_2buf(struct _s_uart_rec_ *p)串行数据保存到指向特定协议的缓冲中 --------------------------------------------------------------------------------------------- -msp/uartx.c 底层代码 和cpu相关 缓存发送也放在里面 - L0_uart1_Init - uart1_IRQHandler - L0_Usend_uc------UserDef ------------------------------------------------------------------------------------------ -********************************************************************************/ #include "msp_uart1.h" ///#include "msp_time2.h" #include "c_crc.h" @@ -105,6 +48,17 @@ msp/uartx.c 底层代码 和cpu相关 缓存发送也放在里面 #elif(BRT_19200 == D_UART1_BRT) #elif(BRT_9600== D_UART1_BRT) + void L0_uart1_init(void) //9600bps@22.1184MHz + { + SCON = 0x50; //8位数据,可变波特率 + AUXR |= 0x40; //定时器时钟1T模式 + AUXR &= 0xFE; //串口1选择定时器1为波特率发生器 + TMOD &= 0x0F; //设置定时器模式 + TL1 = 0xC0; //设置定时初始值 + TH1 = 0xFD; //设置定时初始值 + ET1 = 0; //禁止定时器中断 + TR1 = 1; //定时器1开始计时 + } #else///9600 #endif//)