|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
/// 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:
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
/*****************************************************************************
|
|
|
|
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
|
|
|
|
-----------------------------------------------------------------------------------------
|
|
|
|
********************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _uart4_H
|
|
|
|
#define _uart4_H
|
|
|
|
#include "../bsp/bsp_config.h"
|
|
|
|
//#include "../bsp/type_hs.h"
|
|
|
|
//#include "../debug/debug_drv.h"
|
|
|
|
//#include "../uartcom/urec2protocol.h"
|
|
|
|
//?include "../uartcom/uprotocol2app.h"
|
|
|
|
#include "../tpc/tpc_uart.h"
|
|
|
|
#include "../ctask/task.h"
|
|
|
|
#include "../clib/Clib.h"
|
|
|
|
|
|
|
|
#define D_txd4_wakeup() P03 = 1 // 后面应该延时 >750us 让发送模块启动
|
|
|
|
#define D_txd4_low() P03 = 0
|
|
|
|
|
|
|
|
#define D_s_uart4_rec_close(); s_uart4_rec.ok = 2;// 关闭串口协议解析
|
|
|
|
#define D_s_uart4_rec_open(); s_uart4_rec.ok = 0;// 关闭串口协议解析
|
|
|
|
|
|
|
|
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
|
|
#define D_send4_buf_max 64 /// 9600bps = 10000bps = 1000 Bps = 1Byte/ms
|
|
|
|
/// 19200bps = 20000bps = 2000Bps = 2Byte/ms = 1Byte/0.5ms
|
|
|
|
/// 128Bytes = 128*0.5ms = 64ms
|
|
|
|
struct _s_uart4_send_buf_
|
|
|
|
{//8byte
|
|
|
|
U8 num; //接收到的数目注意数据长度的范围
|
|
|
|
U8 *p;
|
|
|
|
U8 now; /// 当前buf所在的位置 0------(max-1)
|
|
|
|
U8 max; /// 当前buf的最大值,也就是需要发送的长度
|
|
|
|
U8 buf[D_send4_buf_max + 1];//buffer 的第一位是 长度
|
|
|
|
};
|
|
|
|
|
|
|
|
extern struct _s_uart4_send_buf_ s_uart4_send_shop;
|
|
|
|
extern struct _s_uart4_send_buf_ s_uart4_send_depot;
|
|
|
|
|
|
|
|
|
|
|
|
#define D_uart4_ES_INT_CLOSE() BITN_0(IE2,ES4)
|
|
|
|
#define D_uart4_ES_INT_OPEN() BITN_1(IE2,ES4)
|
|
|
|
#define L0_uart4_IntRI() (S4CON & S4RI)//BITN_G(SCON,U0RI)
|
|
|
|
#define L0_uart4_IntTI() (S4CON & S4TI)//BITN_G(SCON,U0TI)
|
|
|
|
#define L0_uart4_IntRIClear(); BITN_0(S4CON,S4RI)
|
|
|
|
#define L0_uart4_IntTIClear(); BITN_0(S4CON,S4TI)
|
|
|
|
#define L0_uart4_set(x) S4BUF = (x);
|
|
|
|
#define L0_uart4_get() (S4BUF)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
|
|
|
|
|
|
|
void L1_uart4_buf_init(void);
|
|
|
|
extern void L0_uart4_init(void);
|
|
|
|
extern void L0_uart4_uchex(U8 ww);
|
|
|
|
|
|
|
|
extern void L0_uart4_ulhex(vU32 ww);
|
|
|
|
|
|
|
|
extern void L0_uart4_ul(vU32 ww);
|
|
|
|
extern void L0_uart4_sendstr(U8 *str);
|
|
|
|
extern void L0_uart4_0d0a(void);
|
|
|
|
extern void L0_uart4_uc(U8 ww);
|
|
|
|
///////////////////////////////////////////////////////////////
|
|
|
|
extern void L0_uart4_sendbuf16(U8 buf[],vU16 num);
|
|
|
|
extern void L0_uart4_sendbuf(void);
|
|
|
|
extern void L0_uart4_sendArray(U8 *str,U8 len);
|
|
|
|
|
|
|
|
#endif //#ifndef _uart4_H
|
|
|
|
|