67 lines
1.9 KiB
C
67 lines
1.9 KiB
C
#ifndef _MW_BT_H
|
|
#define _MW_BT_H
|
|
|
|
#define BT_RST_PIN BIT3
|
|
#define BT_RST_PSEL P10SEL
|
|
#define BT_RST_POUT P10OUT
|
|
#define BT_RST_PDIR P10DIR
|
|
|
|
#define BT_IO_PSEL P1SEL
|
|
#define BT_IO_RTS BIT0
|
|
#define BT_IO_CTS BIT3
|
|
#define BT_IO_POUT P1OUT
|
|
#define BT_IO_PIN P1IN
|
|
#define BT_IO_PDIR P1DIR
|
|
#define BT_IO_REN P1REN
|
|
|
|
#define BT_IO_PIN1 BIT5
|
|
#define BT_IO_PIN2 BIT6
|
|
#define BT_IO_CLKREQ BIT4
|
|
|
|
#define BT_SHUTDOWN() { BT_RST_POUT &= ~BT_RST_PIN; }
|
|
#define BT_ENABLE() { BT_RST_POUT |= BT_RST_PIN; }
|
|
|
|
#define BT_UART_PSEL P5SEL
|
|
#define BT_UART_PDIR P5DIR
|
|
#define BT_UART_REN P5REN
|
|
#define BT_UART_POUT P5OUT
|
|
#define BT_UART_TX_PIN BIT6
|
|
#define BT_UART_RX_PIN BIT7
|
|
|
|
#define CONFIG_BT_PINS() { \
|
|
BT_RST_PSEL &= ~BT_RST_PIN; \
|
|
BT_RST_PDIR |= BT_RST_PIN; \
|
|
BT_SHUTDOWN(); \
|
|
BT_IO_PSEL &= ~(BT_IO_RTS | BT_IO_CTS | BT_IO_PIN1 | BT_IO_PIN2 | BT_IO_CLKREQ); \
|
|
BT_IO_PDIR &= ~(BT_IO_RTS | BT_IO_CTS | BT_IO_PIN1 | BT_IO_PIN2 | BT_IO_CLKREQ); \
|
|
BT_IO_POUT &= ~(BT_IO_RTS | BT_IO_CTS | BT_IO_PIN1 | BT_IO_PIN2 | BT_IO_CLKREQ); \
|
|
BT_UART_PSEL &= ~(BT_UART_TX_PIN | BT_UART_RX_PIN); \
|
|
BT_UART_PDIR &= ~(BT_UART_TX_PIN | BT_UART_RX_PIN); \
|
|
BT_UART_REN |= BT_UART_TX_PIN | BT_UART_RX_PIN; \
|
|
BT_UART_POUT |= BT_UART_TX_PIN | BT_UART_RX_PIN; \
|
|
}
|
|
|
|
void mw_enable_bt(void);
|
|
void mw_disable_bt(void);
|
|
|
|
typedef enum {
|
|
BT_UART_BD19200 = 0,
|
|
BT_UART_BD38400,
|
|
BT_UART_BD57600,
|
|
BT_UART_BD115200,
|
|
BT_UART_BD234000,
|
|
} bt_uart_baud_t;
|
|
|
|
#define BT_MW_DEVICE_CLASS 0x842704 /* Limited discovery, Rendering, Information, Wearable, Wrist Watch */
|
|
#define BT_RX_MAX_SIZE 255
|
|
|
|
void mw_init_bt_uart(const bt_uart_baud_t baud);
|
|
|
|
int mw_bt_uart_tx(const void *buf, const unsigned int len);
|
|
// extern char BT_UART_RX_CHAR;
|
|
|
|
int mw_bt_get_rxbuf_len(void);
|
|
const unsigned char *mw_bt_get_rx_buf(unsigned char **rpos, unsigned char *len);
|
|
unsigned char bt_feed_packet_data(unsigned char pdata);
|
|
uint8_t mw_bt_is_enabled(void);
|
|
#endif
|