分享一款便宜的蓝牙模块,ECB02H2,淘宝售价为两块多。这里值得注意的是, 此蓝牙模块不支持中文 。
引脚定义如下:
RXD: 接单片机的TXD
TXD:接单片机的RXD
/**
* @name:
* @function: 引脚配置
* [url=home.php?mod=space&uid=1141835]@Return[/url] {*}
* @author: lengyuefeng
* @Date: 2022-11-24 20:33:41
*/
void bsp_usart3_gpioConfig(void)
{
/* enable GPIO clock */
rcu_periph_clock_enable(BSP_USART3_GPIO_RCU);
/* configure the USART0 TX pin and USART0 RX pin */
gpio_af_set(BSP_USART3_TX_PORT, GPIO_AF_7, BSP_USART3_TX_PIN);
gpio_af_set(BSP_USART3_RX_PORT, GPIO_AF_7, BSP_USART3_RX_PIN);
/* configure USART0 TX as alternate function push-pull */
gpio_mode_set(BSP_USART3_TX_PORT, GPIO_MODE_AF, GPIO_PUPD_PULLUP, BSP_USART3_TX_PIN);
gpio_output_options_set(BSP_USART3_TX_PORT, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, BSP_USART3_TX_PIN);
/* configure USART0 RX as alternate function push-pull */
gpio_mode_set(BSP_USART3_RX_PORT, GPIO_MODE_AF, GPIO_PUPD_PULLUP, BSP_USART3_RX_PIN);
gpio_output_options_set(BSP_USART3_RX_PORT, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, BSP_USART3_RX_PIN);
}
/**
* @name:
* @function: 串口配置
* [url=home.php?mod=space&uid=3142012]@param[/url] {uint32_t} bound:波特率
* @return {*}
* @author: lengyuefeng
* @Date: 2022-11-24 20:36:50
*/
void bsp_usart3_usartConfig(uint32_t bound)
{
/* enable USART clock */
rcu_periph_clock_enable(BSP_USART3_RCU);
/* USART configure */
usart_deinit(BSP_USART3_USART);
usart_baudrate_set(BSP_USART3_USART, bound);
usart_receive_config(BSP_USART3_USART, USART_RECEIVE_ENABLE);
usart_transmit_config(BSP_USART3_USART, USART_TRANSMIT_ENABLE);
usart_enable(BSP_USART3_USART);
}
默认上电后,单片机会每隔1s时间发送一次Evaluation of Jishu Community Development Board
原作者:卢阿涛
更多回帖