/** * @brief Initializes the serial communications peripheral and GPIO ports * to communicate with the PAN BT .. assuming 16 Mhz CPU * * @param none * * @return none */ void hal_uart_dma_init(void) { BT_PORT_SEL |= BT_PIN_RXD + BT_PIN_TXD; BT_PORT_DIR |= BT_PIN_TXD; BT_PORT_DIR &= ~BT_PIN_RXD; // set BT RTS RTS_SEL &= ~RTS_PIN; // = 0 - I/O RTS_DIR |= RTS_PIN; // = 1 - Output RTS_OUT |= RTS_PIN; // = 1 - RTS high -> stop // set BT CTS CTS_SEL &= ~CTS_PIN; // = 0 - I/O CTS_DIR &= ~CTS_PIN; // = 0 - Input // set BT SHUTDOWN to 1 (active low) N_SHUTDOWN_SEL &= ~N_SHUTDOWN_PIN; // = 0 - I/O N_SHUTDOWN_DIR |= N_SHUTDOWN_PIN; // = 1 - Output N_SHUTDOWN_OUT |= N_SHUTDOWN_PIN; // = 1 - Active low -> ok // wait for Bluetooth to power up properly after providing 32khz clock waitAboutOneSecond(); UCA0CTL1 |= UCSWRST; //Reset State UCA0CTL0 = UCMODE_0; UCA0CTL0 &= ~UC7BIT; // 8bit char UCA0CTL1 |= UCSSEL_2; UCA0CTL1 &= ~UCSWRST; // continue hal_uart_dma_set_baud(115200); }
/** * @brief Initializes the serial communications peripheral and GPIO ports * to communicate with the PAN BT .. assuming 16 Mhz CPU * * @param none * * @return none */ void hal_uart_dma_init(void) { BT_PORT_SEL |= BT_PIN_RXD + BT_PIN_TXD; BT_PORT_DIR |= BT_PIN_TXD; BT_PORT_DIR &= ~BT_PIN_RXD; // set BT RTS (P1.3) P1SEL &= ~BIT3; // = 0 - I/O P1DIR |= BIT3; // = 1 - Output P1OUT |= BIT3; // = 1 - RTS high -> stop // set BT CTS (P1.4) P1SEL &= ~BIT4; // = 0 - I/O P1DIR &= ~BIT4; // = 0 - Input P1DIR |= BIT4; // RTS // set BT SHUTDOWN (P2.7) to 1 (active low) P2SEL &= ~BIT7; // = 0 - I/O P2DIR |= BIT7; // = 1 - Output P2OUT |= BIT7; // = 1 - Active low -> ok // Enable ACLK to provide 32 kHz clock to Bluetooth module P2SEL |= BIT6; P2DIR |= BIT6; // wait for Bluetooth to power up properly after providing 32khz clock waitAboutOneSecond(); UCA2CTL1 |= UCSWRST; //Reset State UCA2CTL0 = UCMODE_0; UCA2CTL0 &= ~UC7BIT; // 8bit char UCA2CTL1 |= UCSSEL_2; UCA2CTL1 &= ~UCSWRST; // continue hal_uart_dma_set_baud(115200); }
static int h4_set_baudrate(uint32_t baudrate){ log_info("h4_set_baudrate - set baud %lu", baudrate); return hal_uart_dma_set_baud(baudrate); }
static int btstack_uart_block_freertos_open(void){ hal_uart_dma_init(); hal_uart_dma_set_baud(uart_config->baudrate); return 0; }