You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

174 lines
4.9 KiB

1 year ago
//////////////////////////////////////////////////////////////////////////
/// COPYRIGHT NOTICE
/// Copyright (c) 2015, 传控科技
/// 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为UART0 RXD TXD
//P5_SEL1 |= BITN0 +BITN1;
/*****************************************************************************
update by cc @201700110
.
clib/clib.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_UART0_Init
UART0_IRQHandler
L0_Usend_uc------UserDef
-----------------------------------------------------------------------------------------
********************************************************************************/
#include "msp_uart2.h"
///#include "tpc_wifi.h" ///本串口要使用的写意
static volatile TS_Uart_Send_ ts_uart2_send_shop;
///>>>>>>>>>>>>>>>>和cpu相关
#if(MainFre_5M == D_sys_MainFre)
#elif(MainFre_22M == D_sys_MainFre)
#elif(MainFre_27M == D_sys_MainFre)
#else ///MainFre_11M
#if(BRT_115200 == D_uart2_BRT)
void L0_uart2_init(void) /// void UartInit(void) //115200bps@11.0592MHz
{
S2CON = 0x50; //8位数据,可变波特率
AUXR &= 0xFB; //定时器时钟12T模式
T2L = 0xFE; //设置定时初始值
T2H = 0xFF; //设置定时初始值
AUXR |= 0x10; //定时器2开始计时
}
#elif(BRT_19200 == D_UART1_BRT)
#elif(BRT_9600== D_UART1_BRT)
#else///9600
#endif//D_sys_MainFre)
#endif//D_sys_MainFre)
///>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>和cpu相关
void L0_uart2_buf_init(void)
{
/// L1_s2b_lora_init();
ts_uart[uNum2].now = 0;
ts_uart[uNum2].ok = D_ready;
L0_uart2_init();
D_uart2_ES_INT(1); //打开串口中断
#if (D_UART2_485_TYPE != TYPE_485_NONE)
D_UART2_485_RX() //默认处于接收状态
#endif
}
void L0_uart2_sendArray555555(U8 * buf, U16 len)
{
#if (D_UART2_485_TYPE != TYPE_485_NONE)
D_UART2_485_TX() //切换到输出状态
#endif
L0_uartN_sendArray(uNum2,buf,len);
}
/*************************************************
UART
*************************************************/
void INTERRUPT_uart2(void) D_SERVE_UART2// using 2
{
//NOP(); NOP(); NOP();
if(L0_uart2_IntRI()) //如果是U2接收中断
{
L0_uart2_IntRIClear(); //清除接收中断标志
///>>>>>>>>>>>>>接收协议 可以更改为其他协议>>>>>>>>>>>>>>>>>>>>>>>>
/// ts_s2b_lrdlora.reg = L0_uart2_get();
// L1_s2b_lora(&ts_s2b_lrdlora);
///<<<<<<<<<<<<<<<<<<<<<<<<<<<<< (ts_uart[uNum2].t);
}
if(L0_uart2_IntTI()) //如果是U0发送中断
{
L0_uart2_IntTIClear(); //清除发送中断标志
if(ts_uart[uNum2].max != ts_uart[uNum2].now)
{
L0_uart2_set(ts_uart[uNum2].buf[ts_uart[uNum2].now]);
ts_uart[uNum2].now ++;
}
else
{
ts_uart[uNum2].ok = D_ready;
ts_uart[uNum2].max = 0;
ts_uart[uNum2].now = 0;//可以发送下一个数据
#if (D_UART2_485_TYPE != TYPE_485_NONE)
D_UART2_485_RX() //切换到接收状态
#endif
}
}
//NOP(); NOP(); NOP();
}