121 lines
3.1 KiB
C
121 lines
3.1 KiB
C
|
/************************************************************************************
|
|||
|
* @Copyright (c) :(C)2021, Qindao ieslab Co., Ltd
|
|||
|
* @FileName :nb_uart_driver.h
|
|||
|
* @Author :QDIES PLATFORM TEAM
|
|||
|
* @Version :V1.1
|
|||
|
* @Date :2021-07
|
|||
|
* @Description :
|
|||
|
************************************************************************************/
|
|||
|
|
|||
|
#ifndef __BLE_UART_DRIVER_H
|
|||
|
#define __BLE_UART_DRIVER_H
|
|||
|
|
|||
|
#include "ddl.h"
|
|||
|
#include "type.h"
|
|||
|
#include "UWater_uart_driver.h"
|
|||
|
|
|||
|
#ifdef __cplusplus
|
|||
|
extern "C"
|
|||
|
{
|
|||
|
#endif
|
|||
|
|
|||
|
#define BLE_TX_PORT LPUART1_TX_PORT //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD>
|
|||
|
#define BLE_TX_PIN LPUART1_TX_PIN
|
|||
|
#define BLE_RX_PORT LPUART1_RX_PORT //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD>
|
|||
|
#define BLE_RX_PIN LPUART1_RX_PIN
|
|||
|
#define BLE_LP_COM 1 //<2F>Ƿ<EFBFBD>ΪLPUART<52><54>1<EFBFBD><31><EFBFBD>ǣ<EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD>Ӧ
|
|||
|
#define BLE_UART_REALCOM M0P_LPUART1 //<2F>ײ<EFBFBD><D7B2>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4>ڣ<EFBFBD><DAA3>б<EFBFBD><D0B1>봮<EFBFBD><EBB4AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
|
|||
|
|
|||
|
#define BLE_AT_RCV_BUF_SIZE 64
|
|||
|
#define BLE_AT_SCAN_MAC_TOTAL 20 //ɨ<>軺<EFBFBD><E8BBBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
//UART<52><54>ѯ<EFBFBD><D1AF>״̬<D7B4><CCAC>Ϣ
|
|||
|
#define BLE_UART_ING ((s8)-1) //<2F><>ѯ<EFBFBD><D1AF>
|
|||
|
#define BLE_UART_FINISH ((s8)-2) //<2F><><EFBFBD><EFBFBD>
|
|||
|
#define BLE_UART_ERROR ((s8)-3) //<2F><><EFBFBD><EFBFBD>֡
|
|||
|
#define BLE_UART_OK ((s8)-4) //<2F><>ȷ֡
|
|||
|
|
|||
|
#define BLE_UP_BUF_SIZE 256
|
|||
|
#define BLE_AT_UP_BUF_SIZE 50
|
|||
|
/*************************************<2A><>ͨʹ<CDA8><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>궨<EFBFBD><EAB6A8>******************************************/
|
|||
|
//<2F><><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD>״̬<D7B4><CCAC><EFBFBD>е<EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD>BLE_S0-BLE_S10
|
|||
|
enum{
|
|||
|
BLE_S0 = 10 ,
|
|||
|
BLE_S1 ,
|
|||
|
BLE_S2 ,
|
|||
|
BLE_S3 ,
|
|||
|
BLE_S4 ,
|
|||
|
BLE_S5 ,
|
|||
|
BLE_S6 ,
|
|||
|
BLE_S7 ,
|
|||
|
BLE_S8 ,
|
|||
|
BLE_S9 ,
|
|||
|
BLE_S10 ,
|
|||
|
};
|
|||
|
|
|||
|
|
|||
|
|
|||
|
enum
|
|||
|
{
|
|||
|
BLE_cst_AT_NOMAL_RCV = 0,//<><CDB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
BLE_cst_AT_OK_ERROR ,//<2F><>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
BLE_cst_AT_AT ,//AT?
|
|||
|
BLE_cst_AT_QUERY ,
|
|||
|
BLE_cst_AT_SCAN_RCV ,//<2F><><EFBFBD><EFBFBD>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
};
|
|||
|
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD>ͨ<EFBFBD>Žṹ<C5BD><E1B9B9>
|
|||
|
typedef struct
|
|||
|
{
|
|||
|
u16 send_len; //<2F><>¼<EFBFBD><C2BC><EFBFBD>͵<EFBFBD><CDB5>ܳ<EFBFBD><DCB3><EFBFBD>
|
|||
|
u16 send_count; //<2F><>¼<EFBFBD><C2BC><EFBFBD>͵ĵ<CDB5>ǰλ<C7B0><CEBB>
|
|||
|
u8 *send_buf; //<2F><><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|||
|
u8 send_style; //<2F><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>ָ<EFBFBD>ȷ<EEA3AC><C8B7>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD>շ<EFBFBD>ʽ
|
|||
|
s8 rev_ack_flag; //<2F><><EFBFBD><EFBFBD>״̬<D7B4><CCAC>־λ
|
|||
|
u8 ble_rcv_flag; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><EFBFBD><CDB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
u8 ble_rev_buf[BLE_UP_BUF_SIZE];
|
|||
|
u16 ble_rcv_len;
|
|||
|
// u16 rev_len; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
|||
|
} BLE_UART_COMM;
|
|||
|
|
|||
|
typedef struct
|
|||
|
{
|
|||
|
u8 mac[6]; //MAC<41><43>ַ
|
|||
|
u8 adv_data[11]; //<2F>㲥<EFBFBD><E3B2A5><EFBFBD><EFBFBD>
|
|||
|
mtype16_ rssi; //<2F>ź<EFBFBD>
|
|||
|
} BLE_SLAVE_INFO, *P_BLE_SLAVE_INFO;
|
|||
|
|
|||
|
//******************************* <20>ⲿ<EFBFBD><E2B2BF><EFBFBD><EFBFBD>***************************************
|
|||
|
|
|||
|
|
|||
|
|
|||
|
//******************************* <20>ⲿ<EFBFBD>ӿں<D3BF><DABA><EFBFBD>***********************************
|
|||
|
//#define NBUartReceiveIT BleUartReceiveIT
|
|||
|
void BleUartSend(u8 *buf, u16 len, u8 style);
|
|||
|
s8 BleCheckAtAck(void);
|
|||
|
u8 BleUartChkStyle(void);
|
|||
|
void BleUartChangeStyle(u8 style);
|
|||
|
void BleUartReceiveIT(void);
|
|||
|
u8 BleRcvAtData(u8 **p_data);
|
|||
|
|
|||
|
#if BLE_CENTRAL_SLAVE_MOD
|
|||
|
void BleClrMacBuf(void); //<2F><><EFBFBD><EFBFBD>ɨ<EFBFBD>軺<EFBFBD><E8BBBA>
|
|||
|
u8 BleGetScanDevInfo(BLE_SLAVE_INFO **p_data);//<2F><>ȡɨ<C8A1>赽<EFBFBD><E8B5BD><EFBFBD>豸<EFBFBD><E8B1B8>Ϣ
|
|||
|
u8 BleGetScanCompleteFlag(void);
|
|||
|
void BleClrScanCompleteFlag(void);
|
|||
|
#endif
|
|||
|
|
|||
|
u8 BleRcvFrameDataFlag(void);
|
|||
|
void BleClrRcvFrameDataFlag(void);
|
|||
|
void BleGetUartRcvData(u8 **rev_data,u16 *data_len);
|
|||
|
u8 BleCheckIfResetFlag(void);
|
|||
|
void BleClrIfResetFlag(void);
|
|||
|
|
|||
|
#ifdef __cplusplus
|
|||
|
}
|
|||
|
#endif
|
|||
|
|
|||
|
#endif /* __BLE_UART_DRIVER_H */
|
|||
|
|