2024-12-07 17:09:36 +08:00
|
|
|
/***
|
|
|
|
* @Author: mbw
|
|
|
|
* @Date: 2024-12-06 16:52:29
|
|
|
|
* @LastEditors: mbw && 1600520629@qq.com
|
2025-01-02 13:42:24 +08:00
|
|
|
* @LastEditTime: 2025-01-02 11:22:39
|
2024-12-07 17:09:36 +08:00
|
|
|
* @FilePath: \ble_-tyq_-bjq_-ch584-m\bsp\inc\bsp_uart.h
|
|
|
|
* @Description:
|
|
|
|
* @
|
|
|
|
* @Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
|
|
|
|
*/
|
|
|
|
#ifndef __BSP_UART_H__
|
|
|
|
#define __BSP_UART_H__
|
|
|
|
|
|
|
|
#include "CH58x_common.h"
|
|
|
|
|
2024-12-11 20:03:50 +08:00
|
|
|
#define BT_START_EVT (0X01 << 0)
|
|
|
|
#define BT_REC_EVT (0X01 << 1)
|
|
|
|
#define BT_INFO_UPDATA_EVT (0X01 << 2)
|
|
|
|
#define BT_SEND_EVT (0X01 << 3)//
|
2025-01-02 13:42:24 +08:00
|
|
|
#define BT_REC_EVT_FINISH (0X01 << 4) //接收完成事件
|
2024-12-07 17:09:36 +08:00
|
|
|
|
2024-12-11 20:03:50 +08:00
|
|
|
#define UART3_RX_PIN GPIO_Pin_20 //PB20
|
2024-12-07 17:09:36 +08:00
|
|
|
#define UART3_TX_PIN GPIO_Pin_21 // PB21
|
|
|
|
|
|
|
|
|
|
|
|
#define BT_UART_TX_PIN GPIO_Pin_9 //PA9
|
|
|
|
#define BT_UART_RX_PIN GPIO_Pin_8 //PA8
|
|
|
|
|
2024-12-11 20:03:50 +08:00
|
|
|
typedef struct __attribute__((packed))
|
2024-12-07 17:09:36 +08:00
|
|
|
{
|
2024-12-11 20:03:50 +08:00
|
|
|
uint8_t cmd;
|
|
|
|
uint8_t buf[];
|
|
|
|
} BtData_t;
|
2024-12-07 17:09:36 +08:00
|
|
|
|
2024-12-11 20:03:50 +08:00
|
|
|
typedef struct __attribute__((packed))
|
2024-12-07 17:09:36 +08:00
|
|
|
{
|
2024-12-11 20:03:50 +08:00
|
|
|
uint8_t len;
|
|
|
|
uint8_t buf[256];
|
|
|
|
} BTFrameData;
|
2024-12-07 17:09:36 +08:00
|
|
|
|
|
|
|
|
|
|
|
void BSP_UART1_Init(void);
|
|
|
|
unsigned int BSP_Uart1_Receive_Data(void *buf, unsigned int len);
|
|
|
|
unsigned int BSP_Uart1_Send_Data(const void *buf, unsigned int len);
|
2024-12-13 19:07:00 +08:00
|
|
|
unsigned int BSP_Uart1_Send_String(const void *buf);
|
|
|
|
void BSP_Uart1_Send_Loop(void);
|
|
|
|
void BSP_Uart3_Send_Loop(void);
|
2024-12-07 17:09:36 +08:00
|
|
|
void BSP_UART3_Init(void);
|
|
|
|
unsigned int BSP_Uart3_Receive_Data(void *buf, unsigned int len);
|
|
|
|
unsigned int BSP_Uart3_Send_Data(const void *buf, unsigned int len);
|
|
|
|
|
2024-12-12 18:56:18 +08:00
|
|
|
uint8_t _CheckSum(const uint8_t *data, size_t len);
|
2024-12-13 19:07:00 +08:00
|
|
|
uint8_t BT_GenerateRawFrame(BTFrameData *pRawData, const uint8_t *p_src, uint8_t src_len);
|
|
|
|
|
2024-12-11 20:03:50 +08:00
|
|
|
extern uint8_t BtRxTaskId;
|
2024-12-07 17:09:36 +08:00
|
|
|
|
|
|
|
#endif // !__BSP_UART_H__
|