sop板
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.

121 lines
4.4 KiB

4 years 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:
//////////////////////////////////////////////////////////////////////////
/*****************************************************************************
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 _uartN_H
#define _uartN_H
#include "../clib/clib.h"
4 years ago
#include "../tpc/tpc_x.h"
#include "../bsp/bsp_config.h"
4 years ago
1 year ago
#define D_uartN_free() (0 == ts_uart_send_buf[uartx].max)
#define D_uartN_busy() (0 != ts_uart_send_buf[uartx].max)
#define D_BRT_COUNT(t,clk,uartBRT) (U16)(65536- (clk / (4 * uartBRT * t)))
4 years ago
1 year ago
typedef struct _ts_uart_send_buf_
{
4 years ago
vU8 num; //接收到的数目注意数据长度的范围
vU8 *p;
vU16 now; /// 当前buf所在的位置 0------(max-1)
vU16 max; /// 当前buf的最大值,也就是需要发送的长度
vU32 over; /// 结束等待标志,over累加到某个值时,结束等待
vU8 ok; /// 发送完成标志
vU8 buf[D_UART_send_buf_max + 1];
vU8 buf3[D_UART_send_buf2_max];
4 years ago
}Ts_uart_send_buf;
1 year ago
typedef struct _ts_uart_recv_buf_
{//8byte
vU8 reg;
vU8 ok; //接收协议ok标志,串口初始化设置为0
vU8 head; //接收标志头标志,串口初始化设置0
vU8 maxnum; //接收到的数目的最大值,串口初始化设置
1 year ago
vU8 cashe[2];
vU8 head_0;
vU8 head_1;
vU8 tail_0;
vU8 index; //当前下标
vU8 num; //协议实际长度
1 year ago
vU8 *buf; ////协议缓冲,由每个串口根据需要的缓冲区大小自己定义
vU8 *sp;
vU8 *sp2; //备份值,如果协议需要备份,单独提供备份缓冲区
vU8 ocr;
vU8 crc[2];
}Ts_uart_recv_buf;
4 years ago
typedef struct _TS_uart_reg
{
Ts_uart_send_buf *p;
1 year ago
Ts_uart_recv_buf *t;
void (*tp_handler)(Ts_uart_recv_buf *);
4 years ago
}TS_uart_reg;
extern TS_uart_reg ts_uart[SERIAL_MAX_NUM];
4 years ago
extern void L0_uartN_init(U8 uartx);
extern void L0_uartN_set(U8 uartx,U8 x);
4 years ago
extern U8 L0_uartN_get(U8 uartx);
extern void L0_uartN_sendArray(U8 uartx,void *buf,U16 len);
extern void L0_uartN_uc(U8 uartx,U8 ww);
extern void L0_uartN_us(U8 uartx,vU16 ww);
extern void L0_uartN_ul(U8 uartx,vU32 ww);
extern void L0_uartN_0d0a(U8 uartx);
extern void L0_uartN_uchex(U8 uartx, U8 ww);
extern void L0_uartN_ushex(U8 uartx, U16 ww);
extern void L0_uartN_ulhex(U8 uartx, U32 ww);
extern void L0_uartN_sendstr(U8 uartx,U8 *buf);
extern void L0_uartN_sendArrayHex(U8 uartx,vU8 *buf,U16 n);
4 years ago
#endif //#ifndef _uartN_H