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.

153 lines
5.7 KiB

5 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: cc
/// Modified date: 20190222
/// Version:
/// Descriptions: 中断的now和max调整类型 可以支持int型的数据一次发送,前提是指向已有的数组
//////////////////////////////////////////////////////////////////////////
/*****************************************************************************
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 _uart0_H
#define _uart0_H
#include "../bsp/bsp_config.h"
#include "../clib/type.h"
//#include "../debug/debug_drv.h"
//#include "../uartcom/urec2protocol.h"
//?include "../uartcom/uprotocol2app.h"
#include "../tpc/tpc_modbus.h"
#define Ldi_print(x) Lc_print_buf(x)
//#include "../uartcom/UProtocol.h"
#include "../ctask/task.h"
#include "../clib/Clib.h"
//extern struct _s_uart_rec_ s_uart0_rec;
// extern TS_Handle_PH1 volatile s_uart0_rec;
//extern TS_Handle_PH1A volatile s_uart0_rec;
extern TS_Handle_PH4 s_uart0_rec;
///#define D_s_uart0_rec_close(); s_uart0_rec.ok = 2;// 关闭串口协议解析
///#define D_s_uart0_rec_open(); s_uart0_rec.ok = 0;// 关闭串口协议解析
#define D_uart0_free() (0 == ts_uart_send_shop.max)
#define D_uart0_busy() (0 != ts_uart_send_shop.max)
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
////fixme:和cpu的程序容量息息相关
#define D_send_buf_max 8 /// 9600bps = 10000bps = 1000 Bps = 1Byte/ms
/// 19200bps = 20000bps = 2000Bps = 2Byte/ms = 1Byte/0.5ms
/// 128Bytes = 128*0.5ms = 64ms
#define D_send_buf2_max 6
typedef struct _ts_uart0_send_buf_
{//8byte
U8 num; //接收到的数目注意数据长度的范围
U8 *p;
vU16 now; /// 当前buf所在的位置 0------(max-1)
vU16 max; /// 当前buf的最大值,也就是需要发送的长度
vU16 over; /// 当前buf的最大值,也就是需要发送的长度
U8 ok; /// 当前buf的最大值,也就是需要发送的长度
U8 buf[D_send_buf_max];
/// U8 buf2[D_send_buf2_max];
U8 buf3[D_send_buf2_max];
//// U8 buf4[D_send_buf_max];
/// U8 buf[D_send_buf_max + 1];//buffer 的第一位是 长度
}Ts_uart_send_buf;
extern volatile Ts_uart_send_buf ts_uart_send_shop;
///extern volatile Ts_uart_send_buf ts_uart_send_depot;
#define D_uart0_ES_INT(x) ES = (x)
#define L0_uart0_IntRI() (RI)//BITN_G(SCON,U0RI)
#define L0_uart0_IntTI() (TI)//BITN_G(SCON,U0TI)
#define L0_uart0_IntRIClear(); RI = 0;//BITN_0(SCON,U0RI)
#define L0_uart0_IntTIClear(); TI = 0;//BITN_0(SCON,U0TI)
#define L0_uart0_set(x) SBUF = (x);
#define L0_uart0_get() (SBUF)
//#define D_send_us(x) gRccUs01 = x;L0_uart0_uc(gRccUs01_H);L0_uart0_uc(gRccUs01_L);
#define D_send_ushex(x) L0_uart0_ushex(x,16);///Lc_delay_ms(2);//gRccUs01 = x;L0_uart0_uchex(gRccUs01_H);L0_uart0_uchex(gRccUs01_L);
#define D_uart0_send_over() (D_ready == ts_uart_send_shop.ok)
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
void L1_uart0_buf_init(void);
extern void L0_uart0_init(void);
extern void L0_uart0_init32K_290BPS(void);
extern void L0_Uart0_Init4800(void) ;
extern void L0_uart0_uchex(U8 ww);
extern void L0_uart0_ulhex(vU32 ww);
extern void L0_uart0_ul(vU32 ww);
extern void L0_uart0_sendstr(U8 *str);
extern void L0_uart0_0d0a(void);
extern void L0_uart0_uc(U8 ww);
extern void L0_uart0_uc_debug(U8 ww);
extern void L0_uart0_us(vU32 ww);
extern void L0_uart0_ushex(vU16 ww,U8 hex);
extern void L0_uart0_uldec(U32 ww);
///////////////////////////////////////////////////////////////
extern void L0_uart0_sendArray(U8 *buf,U16 len);
extern void L0_uart0_sendbuf(void);
///extern void L0_uart0_sendArraylong(U8 *buf,U16 usStart,U16 usEnd);
#endif //#ifndef _uart0_H