12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- #ifndef __hal_ble_uart0__
- #define __hal_ble_uart0__
- #include <stdbool.h>
- #include <stdint.h>
- #include <string.h>
- #include "sdk_common.h"
- #include "SEGGER_RTT.h"
- #include "usr_config.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #ifdef __cplusplus
- }
- #endif
- /*************** 发送命令 ********************/
- typedef enum {
- UART0_T_HEART = 0,
- UART0_T_CONFIG_ASK, //配对申请
- UART0_T_CONFIG_ACK, //配对成功
- UART0_T_CHAR_VOL, //充电电量
- UART0_NUM_OF_T, //命令连续用此值
- }UART0_T_n;
- //#define UART0_NUM_OF_T 9 //注意:::此值根据命令的数量改变
- /*************** 发送子命令 ********************/
- //enum { //UART0_T_UPDATE
- // UART0_T_UPDATE_BASEINFO = 0, //设备基本信息
- // UART0_T_UPDATE_DATA , //设备数据
- // UART0_T_UPDATE_STEPNUM , //回复存储步数
- // UART0_T_UPDATE_STEPNUM_CLERA, //删除存储步数
- //};
- //enum { //UART0_T_CHARGE
- // UART0_T_CHARGE_NONE = 0,
- // UART0_T_CHARGE_PULLOUT,
- // UART0_T_CHARGE_INSERT,
- // UART0_T_CHARGE_DONE,
- // UART0_T_CHARGE_ERROR,
- //};
- /*************** 接收命令 ********************/
- typedef enum {
- UART0_R_HEART = 0,
- UART0_R_CONFIG_ASK, //配对申请
- UART0_R_CONFIG_ACK, //配对成功
- UART0_R_CHAR_VOL, //充电电量
- UART0_NUM_OF_R, //命令连续用此值
- }UART0_R_n;
- //#define UART0_NUM_OF_R 11 //注意:::此值根据命令的数量改变
- /*************** 接收子命令 ********************/
- //enum { //UART0_R_UPDATE
- // UART0_R_UPDATE_BASEINFO = 0,
- // UART0_R_UPDATE_DATA ,
- // UART0_R_UPDATE_STEPNUM,
- // UART0_R_UPDATE_STEPNUM_CLERA,
- //};
- typedef void (*UART0_Callback)(void*);
- typedef struct _UART0_Rx{
- uint8_t cmd;
- uint8_t* pDat;
- uint8_t datLen;
- UART0_Callback cb;
- }UART0_Rx_t;
- typedef struct _UART0_Tx{
- uint8_t n;
- uint32_t t;
- uint8_t ncnt;
- uint32_t tcnt;
- uint8_t cmd;
- uint8_t* pDat;
- uint8_t datLen;
- uint8_t holdon;
- UART0_Callback cb;
- struct _UART0_Tx *next; //单向链表
- }UART0_Tx_t;
- void UART0_Initialize(void);
- void UART0_unInit(void);
- void UART0_Send(unsigned char cmd,unsigned char *pDat,unsigned char datLen);
- int UART0_Rx_Regist(unsigned char cmd,UART0_Callback cb);
- void UART0_Tx_Send(UART0_Tx_t* handle,unsigned char cmd,unsigned char *pDat,unsigned char datLen);
- void UART0_Tx_Clear(UART0_Tx_t* handle);
- void UART0_Push(unsigned char* p,int len);
- #endif
|