一、硬件介绍
分享一款便宜的蓝牙模块,ECB02H2,淘宝售价为两块多。这里值得注意的是, 此蓝牙模块不支持中文 。
二、引脚定义
引脚定义如下:
RXD: 接单片机的TXD
TXD:接单片机的RXD
三、软件配置
1.串口配置
void bsp_usart3_gpioConfig(void)
{
rcu_periph_clock_enable(BSP_USART3_GPIO_RCU);
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);
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);
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);
}
void bsp_usart3_usartConfig(uint32_t bound)
{
rcu_periph_clock_enable(BSP_USART3_RCU);
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
原作者:卢阿涛
|