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.

171 lines
5.6 KiB

1 year ago
//////////////////////////////////////////////////////////////////////////
/// 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/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 "c_lib.h"
#include "tpc_x.h"
#include "bsp_config.h"
#define D_UART1 0
#define D_UART2 1
#define D_UART3 2
#define D_UART4 3
#define D_uartN_free() (0 == ts_Usend[uartx].max)
#define D_uartN_busy() (0 != ts_Usend[uartx].max)
#define D_BRT_COUNT(t,clk,uartBRT) (U16)(65536- (clk / (4 * uartBRT * t)))
typedef struct
{
U8 reg;
//// U8 f2;
U8 overtime_t; //超时溢出的计数器
U8 idle; ///0:没有超时溢出 1:超时溢出 总线空闲
/// U8 over_flag; ////串口接收结束的状态 0:超时溢出 1:超出max接收
U8 head; //接收标志头标志
/// U8 f; //接收标志头标志
U16 num; //接收到的数据的计数, 随着数据接收而变化注意数据长度的范围
U8 ok; //接收协议ok标志
U8 debugok;
U16 rmax;
/// U8 len;
U8 fifo;////有数据FIFO= 1;空闲标志读取后之后fifo =0
U8 *sp;
/// U8 t[D_debug_max+1];
}TS_rec_road_;///处理debug类型的协议时使用变量 ////协议处理变量
extern TS_rec_road_ ts_Urec[SERIAL_MAX_NUM];
/////可以依据实际使用独立定制
#define D_rec1_max 128
#define D_rec2_max 1
#define D_rec3_max 1
#define D_rec4_max 1
typedef struct
{
U8 r1[D_rec1_max];
U8 r2[D_rec2_max];
U8 r3[D_rec3_max];
U8 r4[D_rec4_max];
U8 r5[D_rec4_max];
/// U8 t[D_debug_max+1];
}TS_rec_buf_;///处理debug类型的协议时使用变量 ////协议处理变量
extern TS_rec_buf_ ts_Urecbuf;
#define D_send1_max 128
#define D_send2_max 1
#define D_send3_max 1
#define D_send4_max 1
typedef struct
{
U8 s1[D_send1_max];
U8 s2[D_send2_max];
U8 s3[D_send3_max];
U8 s4[D_send4_max];
/// U8 t[D_debug_max+1];
}TS_send_buf_;///处理debug类型的协议时使用变量 ////协议处理变量
extern TS_send_buf_ ts_Usendbuf;
typedef struct
{
vU16 num; //注意数据长度的范围
//// vU8 *p;
vU16 now; /// 当前buf所在的位置 0------(max-1)
vU16 max; /// 当前buf的最大值,也就是需要发送的长度
vU8 overtime;
vU32 over; /// 结束等待标志,over累加到某个值时,结束等待
vU8 ok; /// 发送完成标志
vU8 *sbuf;////sbuf[]
vU16 max_def; /// 当前buf的最大值,D_sendx_max 需要在初始化的时候赋值
vU8 buf3[D_UART_send_buf2_max];
}TS_Uart_Send_;
extern TS_Uart_Send_ ts_Usend[SERIAL_MAX_NUM];
extern void L0_uartN_init(U8 uartx);
extern void L0_uartN_Array(U8 uartx,void *buf,U16 len);
extern void L0_uartN_Arraylong(U8 uartx,U8 *buf,U16 usStart,U16 usEnd);
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_str(U8 uartx,U8 *buf);
extern void L0_uartN_uchexArray(U8 uartx,vU8 *buf,U16 n);
extern void L0_waitFree_uartN(U8 uartx);
extern void L0_uartN_set(U8 uartx,U8 x);
////使用内置的usend buf的发送
extern void L0_uartN_ushexArray(U8 uartx,vU16 *buf,U16 n);
////把发送缓存中的len个数据用中断自动发送出去
extern void L0_uartN_Array_withoutbuf(U8 uartx,U16 len);
///要把buf的内容经过hex转化后 放入发送缓存中
extern void L0_uartN_Arrayhex_withoutbuf(U8 uartx,vU8 *buf,U16 len);
extern void L0_uartN_sbuf(U8 uartx);
#endif //#ifndef _uartN_H