/*** 
 * @Author: mbw
 * @Date: 2024-12-06 16:52:29
 * @LastEditors: mbw && 1600520629@qq.com
 * @LastEditTime: 2024-12-09 11:15:13
 * @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"

#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)//

#define  UART3_RX_PIN   GPIO_Pin_20   //PB20
#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


typedef struct __attribute__((packed))
{
    uint8_t cmd;
    uint8_t buf[];
} BtData_t;

typedef struct __attribute__((packed))
{
    uint8_t len;
    uint8_t buf[256];
} BTFrameData;


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);


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);

uint8_t _CheckSum(const uint8_t *data, size_t len);
extern uint8_t BtRxTaskId;

#endif // !__BSP_UART_H__
