|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
/// 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:
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
/*****************************************************************************
|
|
|
|
update by cc @201700110
|
|
|
|
针对多串口 和 单一串口 有区别 每个串口是独立的还是分开的有讲究 程序是复杂的还是软件应用简单是
|
|
|
|
个需要平衡的事情.
|
|
|
|
|
|
|
|
clib/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_UART2_Init
|
|
|
|
UART2_IRQHandler
|
|
|
|
L0_Usend_uc------UserDef
|
|
|
|
-----------------------------------------------------------------------------------------
|
|
|
|
********************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _UART2_H
|
|
|
|
#define _UART2_H
|
|
|
|
#include "bsp_config.h"
|
|
|
|
//#include "tpc_modbus.h"
|
|
|
|
#include "msp_uartN.h"
|
|
|
|
//#include "msp_time2.h"
|
|
|
|
|
|
|
|
//#include "../tpc/tpc_x.h"
|
|
|
|
|
|
|
|
#define D_UART2_ES_INT(x) (x) ? (BITN_1(IE2,ES2)) : (BITN_0(IE2,ES2))
|
|
|
|
#define L0_uart2_IntRI() (S2CON & S2RI)//BITN_G(SCON,U0RI)
|
|
|
|
#define L0_uart2_IntTI() (S2CON & S2TI)//BITN_G(SCON,U0TI)
|
|
|
|
#define L0_uart2_IntRIClear(); BITN_0(S2CON,S2RI)
|
|
|
|
#define L0_uart2_IntTIClear(); BITN_0(S2CON,S2TI)
|
|
|
|
#define L0_uart2_get() (S2BUF)
|
|
|
|
#define L0_uart2_set(x) (S2BUF = x)
|
|
|
|
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
|
|
|
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
|
|
|
|
|
|
|
extern void L0_uart2_buf_init(void);
|
|
|
|
/////extern void L1_uart2_sendArray(U8 * buf, U16 len);
|
|
|
|
|
|
|
|
#define L0_uart2_uc(X) L0_uartN_uc(D_UART2,X)
|
|
|
|
#define L0_uart2_us(X) L0_uartN_us(D_UART2,X)
|
|
|
|
#define L0_uart2_ul(X) L0_uartN_ul(D_UART2,X)
|
|
|
|
#define L0_uart2_0d0a() L0_uartN_0d0a(0)
|
|
|
|
#define L0_uart2_uchex(X) L0_uartN_uchex(D_UART2,X)
|
|
|
|
#define L0_uart2_ushex(X) L0_uartN_ushex(D_UART2,X)
|
|
|
|
#define L0_uart2_ulhex(X) L0_uartN_ulhex(D_UART2,X)
|
|
|
|
#define L0_uart2_str(buf) L0_uartN_str(D_UART2,buf)
|
|
|
|
#define L1_uart2_Array(buf,len) L0_uartN_Array(D_UART2,(buf),(len))
|
|
|
|
|
|
|
|
|
|
|
|
#define L1_uart2_Arrayhex(buf,len) L0_uartN_uchexArray(D_UART2,(buf),(len))
|
|
|
|
|
|
|
|
///void L2_callback_UART2_free(void);
|
|
|
|
|
|
|
|
///void L2_callback_UART2_free(Ts_uart_rev_ *p);
|
|
|
|
|
|
|
|
#define L1_UART2_isFree(); /////L0_timer2_start();
|
|
|
|
#define L1_UART2_isFree_over(); /////L0_timer2_stop();
|
|
|
|
#define L1_UART2_timer_isFree_init(); /////L0_timer2_init();L0_timer2_stop();\
|
|
|
|
/////L0_timer2_int_on();\
|
|
|
|
/////ts_timer2.callback = L2_callback_UART2_free;ts_timer2.p = &s_UART2_rec;
|
|
|
|
extern void L2_uart2_overtime_callback(void);
|
|
|
|
|
|
|
|
#endif //#ifndef _UART2_H
|
|
|
|
|