ARM技术论坛
直播中

江左盟

8年用户 1417经验值
擅长:电源/新能源
私信 关注
[经验]

分享一款便宜的蓝牙模块ECB02H2

一、硬件介绍

分享一款便宜的蓝牙模块,ECB02H2,淘宝售价为两块多。这里值得注意的是, 此蓝牙模块不支持中文

二、引脚定义

引脚定义如下:

RXD: 接单片机的TXD
TXD:接单片机的RXD

三、软件配置

1.串口配置

/**
 * @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

 title=

原作者:卢阿涛

更多回帖

发帖
×
20
完善资料,
赚取积分