具有蓝牙低功耗(LE)连接和高级功能,例如方向查找和近场通信(NFC)
A
A
硬件概览
它是如何工作的?
BL653 Click 基于 Ezurio 的 BL653,这是一个面向下一代工业物联网(IIoT)的长距离蓝牙低功耗(LE)模块。该模块采用 Nordic 的 nRF52833 芯片,集成了功能强大的 Cortex-M4F 微控制器,提供 512kB 闪存和 128kB RAM,支持无主机操作及高效的应用处理。凭借其多无线功能(支持蓝牙 v5.4 和 NFC)以及通过 FCC、ISED、EU、RCM、MIC、KC、AS/NZS 和蓝牙 SIG 的模块化认证,BL653 Click 可确保快速且无障碍地在全球市场部署。它代表了无线工业物联网连接的未来,即便在最苛刻的操作环境中也能实现可靠的无线通信。此 Click 板™ 提供多种可配置接口,包括 UART、I2C、SPI、USB 和 NFC,便于集成到各种工业系统中。它支持蓝牙 LE 的外围设备和中心设备角色,可用于数据采集、设备控制和接近感测等应用。支持蓝牙 5.4 的功能,如方向查找(AoA 和 AoD)和多种数据速率,包括 2Mbps、1Mbps 和 125kbps 编码 PHY,确保在长距离通信中
的高性能表现。开发者可以通过简单的 AT 命令集、Zephyr RTOS 或 Nordic SDK 轻松编程,从而创建事件驱动的自动化应用或实现自定义解决方案。此 Click 板™ 通过 UART 接口在 BL653 模块和主机 MCU 之间建立通信,使用标准 UART RX 和 TX 引脚,以及通过 CTS 和 RTS 引脚实现硬件流控制。默认通信速度为 115200bps,确保高效的数据交换。主机 MCU 可通过高级 AT 命令配置通信及其他功能,无需深入了解蓝牙协议即可轻松管理。此外,板载 SPI 接口的最大时钟速度为 8MHz,I2C 接口的最大时钟速度为 400kHz。除了接口引脚外,板上还配备复位(RST)引脚,用于在必要时硬复位模块,以及 ARN 引脚作为 BL653 模块的 AutoRUN 信号,用于在上电时选择两种 BL653 操作模式:独立运行模式或交互/开发模式。此板还包括一个 USB Type-C 接口,支持 USB 2.0 全速 12Mbps 硬件能力,可通过 PC 提供电源和配置。这一功能由 CP2102N 高度集成的 USB 转
UART 桥接芯片实现,同时通过 NCP1117 LDO 稳压器将 USB 电源转换为模块所需的 3.3V。BL653 Click 还包括专用引脚支持 NFC,完全符合 NFC Forum 规范。该功能以 13.56MHz 的频率运行,数据速率为 106kbps,支持 NFC Type 2 和 Type 4 标签仿真。它提供禁用、感应和激活等多种操作模式,为在应用中集成高级 NFC 功能提供灵活性。此外,板上还配备两个用户可配置按钮(BTN1 和 BTN2)和两个用户可配置 LED 指示灯(蓝色 LED1 和橙色 LED2),用于自定义用户交互和状态指示。为开发和调试目的,Click 板™ 配备了未焊接的 SWD 接口引脚,便于访问编程和调试功能。此 Click 板™ 仅支持 3.3V 逻辑电压操作。如果使用不同逻辑电压的 MCU,必须执行适当的逻辑电压电平转换。该板还配备一个库,包含函数和示例代码,可作为进一步开发的参考。
功能概述
开发板
Nucleo 32开发板搭载STM32F031K6 MCU,提供了一种经济且灵活的平台,适用于使用32引脚封装的STM32微控制器进行实验。该开发板具有Arduino™ Nano连接性,便于通过专用扩展板进行功能扩展,并且支持mbed,使其能够无缝集成在线资源。板载集成
ST-LINK/V2-1调试器/编程器,支持通过USB重新枚举,提供三种接口:虚拟串口(Virtual Com port)、大容量存储和调试端口。该开发板的电源供应灵活,可通过USB VBUS或外部电源供电。此外,还配备了三个LED指示灯(LD1用于USB通信,LD2用于电源
指示,LD3为用户可控LED)和一个复位按钮。STM32 Nucleo-32开发板支持多种集成开发环境(IDEs),如IAR™、Keil®和基于GCC的IDE(如AC6 SW4STM32),使其成为开发人员的多功能工具。

微控制器概述
MCU卡片 / MCU

建筑
ARM Cortex-M0
MCU 内存 (KB)
32
硅供应商
STMicroelectronics
引脚数
32
RAM (字节)
4096
你完善了我!
配件
Click Shield for Nucleo-32是扩展您的开发板功能的理想选择,专为STM32 Nucleo-32引脚布局设计。Click Shield for Nucleo-32提供了两个mikroBUS™插座,可以添加来自我们不断增长的Click板™系列中的任何功能。从传感器和WiFi收发器到电机控制和音频放大器,我们应有尽有。Click Shield for Nucleo-32与STM32 Nucleo-32开发板兼容,为用户提供了一种经济且灵活的方式,使用任何STM32微控制器快速创建原型,并尝试各种性能、功耗和功能的组合。STM32 Nucleo-32开发板无需任何独立的探针,因为它集成了ST-LINK/V2-1调试器/编程器,并随附STM32全面的软件HAL库和各种打包的软件示例。这个开发平台为用户提供了一种简便且通用的方式,将STM32 Nucleo-32兼容开发板与他们喜欢的Click板™结合,应用于即将开展的项目中。
使用的MCU引脚
mikroBUS™映射器
“仔细看看!”
Click board™ 原理图

一步一步来
项目组装
实时跟踪您的结果
应用程序输出
1. 应用程序输出 - 在调试模式下,“应用程序输出”窗口支持实时数据监控,直接提供执行结果的可视化。请按照提供的教程正确配置环境,以确保数据正确显示。

2. UART 终端 - 使用UART Terminal通过USB to UART converter监视数据传输,实现Click board™与开发系统之间的直接通信。请根据项目需求配置波特率和其他串行设置,以确保正常运行。有关分步设置说明,请参考提供的教程。

3. Plot 输出 - Plot功能提供了一种强大的方式来可视化实时传感器数据,使趋势分析、调试和多个数据点的对比变得更加直观。要正确设置,请按照提供的教程,其中包含使用Plot功能显示Click board™读数的分步示例。在代码中使用Plot功能时,请使用以下函数:plot(insert_graph_name, variable_name);。这是一个通用格式,用户需要将“insert_graph_name”替换为实际图表名称,并将“variable_name”替换为要显示的参数。

软件支持
库描述
BL653 Click 演示应用程序使用 NECTO Studio开发,确保与 mikroSDK 的开源库和工具兼容。该演示设计为即插即用,可与所有具有 mikroBUS™ 插座的 开发板、入门板和 mikromedia 板完全兼容,用于快速实现和测试。
示例描述
本示例演示了如何使用 BL653 Click 板,通过处理来自已连接蓝牙设备的数据来实现通信。
关键功能:
bl653_cfg_setup
- 配置对象初始化函数。bl653_init
- 初始化函数。bl653_cmd_run
- 发送指定命令(可带或不带参数)至 Click 模块的函数。bl653_cmd_set
- 设置 Click 模块指定命令参数值的函数。bl653_cmd_get
- 获取 Click 模块指定命令参数值的函数。
应用初始化
初始化驱动程序和日志系统。
应用任务
应用任务分为几个阶段:
BT653_POWER_UP:
- 启动设备并读取系统信息。BT653_CONFIG_EXAMPLE:
- 设置 BT 设备名称。BT653_EXAMPLE:
- 执行一个 BT 终端示例,通过处理来自连接的 BT 设备的所有数据并发送适当的响应消息。
开源
代码示例
完整的应用程序代码和一个现成的项目可以通过NECTO Studio包管理器直接安装到NECTO Studio。 应用程序代码也可以在MIKROE的GitHub账户中找到。
/*!
* @file main.c
* @brief BL653 Click Example.
*
* # Description
* This example demonstrates the use of BL653 Click board by processing data
* from a connected BT device.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes the driver and logger.
*
* ## Application Task
* Application task is split in few stages:
* - BL653_POWER_UP:
* Powers up the device and reads the system information.
* - BL653_CONFIG_EXAMPLE:
* Sets the BT device name.
* - BL653_EXAMPLE:
* Performs a BT terminal example by processing all data from a connected BT device
* and sending back an adequate response messages.
*
* ## Additional Function
* - static void bl653_clear_app_buf ( void )
* - static void bl653_log_app_buf ( void )
* - static err_t bl653_process ( bl653_t *ctx )
* - static err_t bl653_read_response ( bl653_t *ctx, uint8_t *rsp )
* - static err_t bl653_power_up ( bl653_t *ctx )
* - static err_t bl653_config_example ( bl653_t *ctx )
* - static err_t bl653_example ( bl653_t *ctx )
*
* @note
* We have used the Serial Bluetooth Terminal smartphone application for the test.
*
* @author Stefan Filipovic
*
*/
#include "board.h"
#include "log.h"
#include "bl653.h"
// Message content
#define MESSAGE_CONTENT "BL653 Click board - demo example."
// Local device name.
#define DEVICE_NAME "BL653 Click"
static bl653_t bl653;
static log_t logger;
// Application buffer size
#define APP_BUFFER_SIZE 600
#define PROCESS_BUFFER_SIZE 200
static uint8_t app_buf[ APP_BUFFER_SIZE ] = { 0 };
static int32_t app_buf_len = 0;
/**
* @brief Example states.
* @details Predefined enum values for application example state.
*/
typedef enum
{
BL653_POWER_UP = 1,
BL653_CONFIG_EXAMPLE,
BL653_EXAMPLE
} bl653_app_state_t;
static bl653_app_state_t app_state = BL653_POWER_UP;
/**
* @brief BL653 clearing application buffer.
* @details This function clears memory of application buffer and reset its length.
* @note None.
*/
static void bl653_clear_app_buf ( void );
/**
* @brief BL653 log application buffer.
* @details This function logs data from application buffer to USB UART.
* @note None.
*/
static void bl653_log_app_buf ( void );
/**
* @brief BL653 data reading function.
* @details This function reads data from device and concatenates data to application buffer.
* @param[in] ctx : Click context object.
* See #bl653_t object definition for detailed explanation.
* @return @li @c 0 - Read some data.
* @li @c -1 - Nothing is read.
* See #err_t definition for detailed explanation.
* @note None.
*/
static err_t bl653_process ( bl653_t *ctx );
/**
* @brief BL653 read response function.
* @details This function waits for a response message, reads and displays it on the USB UART.
* @param[in] ctx : Click context object.
* See #bl653_t object definition for detailed explanation.
* @param[in] rsp Expected response.
* @return @li @c 0 - OK response.
* @li @c -2 - Timeout error.
* @li @c -3 - Command error.
* See #err_t definition for detailed explanation.
* @note None.
*/
static err_t bl653_read_response ( bl653_t *ctx, uint8_t *rsp );
/**
* @brief BL653 power up function.
* @details This function powers up the device, and reads the system information.
* @param[in] ctx : Click context object.
* See #bl653_t object definition for detailed explanation.
* @return @li @c 0 - OK.
* @li @c != 0 - Read response error.
* See #err_t definition for detailed explanation.
* @note None.
*/
static err_t bl653_power_up ( bl653_t *ctx );
/**
* @brief BL653 config example function.
* @details This function sets the BT device name.
* @param[in] ctx : Click context object.
* See #bl653_t object definition for detailed explanation.
* @return @li @c 0 - OK.
* @li @c != 0 - Read response error.
* See #err_t definition for detailed explanation.
* @note None.
*/
static err_t bl653_config_example ( bl653_t *ctx );
/**
* @brief BL653 example function.
* @details This function performs a BT terminal example by processing all data from
* a connected BT device and sending back an adequate response messages.
* @param[in] ctx : Click context object.
* See #bl653_t object definition for detailed explanation.
* @return @li @c 0 - OK.
* @li @c != 0 - Read response error.
* See #err_t definition for detailed explanation.
* @note None.
*/
static err_t bl653_example ( bl653_t *ctx );
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
bl653_cfg_t bl653_cfg; /**< Click config object. */
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
bl653_cfg_setup( &bl653_cfg );
BL653_MAP_MIKROBUS( bl653_cfg, MIKROBUS_1 );
if ( UART_ERROR == bl653_init( &bl653, &bl653_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
app_state = BL653_POWER_UP;
log_printf( &logger, ">>> APP STATE - POWER UP <<<\r\n\n" );
}
void application_task ( void )
{
switch ( app_state )
{
case BL653_POWER_UP:
{
if ( BL653_OK == bl653_power_up( &bl653 ) )
{
app_state = BL653_CONFIG_EXAMPLE;
log_printf( &logger, ">>> APP STATE - CONFIG EXAMPLE <<<\r\n\n" );
}
break;
}
case BL653_CONFIG_EXAMPLE:
{
if ( BL653_OK == bl653_config_example( &bl653 ) )
{
app_state = BL653_EXAMPLE;
log_printf( &logger, ">>> APP STATE - EXAMPLE <<<\r\n\n" );
}
break;
}
case BL653_EXAMPLE:
{
bl653_example( &bl653 );
break;
}
default:
{
log_error( &logger, " APP STATE." );
break;
}
}
}
int main ( void )
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
static void bl653_clear_app_buf ( void )
{
memset( app_buf, 0, app_buf_len );
app_buf_len = 0;
}
static void bl653_log_app_buf ( void )
{
for ( int32_t buf_cnt = 0; buf_cnt < app_buf_len; buf_cnt++ )
{
log_printf( &logger, "%c", app_buf[ buf_cnt ] );
}
}
static err_t bl653_process ( bl653_t *ctx )
{
uint8_t rx_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
int32_t overflow_bytes = 0;
int32_t rx_cnt = 0;
int32_t rx_size = bl653_generic_read( ctx, rx_buf, PROCESS_BUFFER_SIZE );
if ( ( rx_size > 0 ) && ( rx_size <= APP_BUFFER_SIZE ) )
{
if ( ( app_buf_len + rx_size ) > APP_BUFFER_SIZE )
{
overflow_bytes = ( app_buf_len + rx_size ) - APP_BUFFER_SIZE;
app_buf_len = APP_BUFFER_SIZE - rx_size;
memmove ( app_buf, &app_buf[ overflow_bytes ], app_buf_len );
memset ( &app_buf[ app_buf_len ], 0, overflow_bytes );
}
for ( rx_cnt = 0; rx_cnt < rx_size; rx_cnt++ )
{
if ( rx_buf[ rx_cnt ] )
{
app_buf[ app_buf_len++ ] = rx_buf[ rx_cnt ];
}
}
return BL653_OK;
}
return BL653_ERROR;
}
static err_t bl653_read_response ( bl653_t *ctx, uint8_t *rsp )
{
#define READ_RESPONSE_TIMEOUT_MS 30000
uint32_t timeout_cnt = 0;
bl653_clear_app_buf ( );
bl653_process( ctx );
while ( ( 0 == strstr( app_buf, rsp ) ) &&
( 0 == strstr( app_buf, BL653_RSP_ERROR ) ) )
{
bl653_process( ctx );
if ( timeout_cnt++ > READ_RESPONSE_TIMEOUT_MS )
{
bl653_log_app_buf( );
bl653_clear_app_buf( );
log_error( &logger, " Timeout!" );
return BL653_ERROR_TIMEOUT;
}
Delay_ms( 1 );
}
Delay_ms ( 200 );
bl653_process( ctx );
bl653_log_app_buf( );
if ( strstr( app_buf, rsp ) )
{
log_printf( &logger, "--------------------------------\r\n" );
return BL653_OK;
}
return BL653_ERROR_CMD;
}
static err_t bl653_power_up ( bl653_t *ctx )
{
err_t error_flag = BL653_OK;
log_printf( &logger, ">>> Reset device.\r\n" );
bl653_reset_device( &bl653 );
while ( BL653_OK == bl653_process( ctx ) )
{
bl653_log_app_buf( );
bl653_clear_app_buf ( );
}
log_printf( &logger, "--------------------------------\r\n" );
log_printf( &logger, ">>> Factory reset.\r\n" );
bl653_cmd_run( &bl653, BL653_CMD_FACTORY_RESET, NULL );
error_flag |= bl653_read_response( &bl653, BL653_RSP_OK );
log_printf( &logger, ">>> Check communication.\r\n" );
bl653_cmd_run( &bl653, BL653_CMD_AT, NULL );
error_flag |= bl653_read_response( &bl653, BL653_RSP_OK );
log_printf( &logger, ">>> Get device type.\r\n" );
bl653_cmd_run( ctx, BL653_CMD_GET_INFO, BL653_PARAM_DEVICE_TYPE );
error_flag |= bl653_read_response( ctx, BL653_RSP_OK );
log_printf( &logger, ">>> Get firmware version.\r\n" );
bl653_cmd_run( ctx, BL653_CMD_GET_INFO, BL653_PARAM_FW_VERSION );
error_flag |= bl653_read_response( ctx, BL653_RSP_OK );
log_printf( &logger, ">>> Get BT address.\r\n" );
bl653_cmd_run( ctx, BL653_CMD_GET_INFO, BL653_PARAM_BT_ADDRESS );
error_flag |= bl653_read_response( ctx, BL653_RSP_OK );
return error_flag;
}
static err_t bl653_config_example ( bl653_t *ctx )
{
err_t error_flag = BL653_OK;
log_printf( &logger, ">>> Set device name to \"%s\".\r\n", ( char * ) DEVICE_NAME );
bl653_cmd_set( ctx, BL653_CMD_PARAM_ACCESS_STR, BL653_PARAM_ID_DEVICE_NAME, DEVICE_NAME );
error_flag |= bl653_read_response( ctx, BL653_RSP_OK );
log_printf( &logger, ">>> Save settings.\r\n" );
bl653_cmd_run( &bl653, BL653_CMD_SAVE_SETTINGS, NULL );
error_flag |= bl653_read_response( ctx, BL653_RSP_OK );
log_printf( &logger, ">>> Reboot.\r\n" );
bl653_cmd_run( ctx, BL653_CMD_WARM_RESET, NULL );
error_flag |= bl653_read_response( ctx, BL653_RSP_OK );
return error_flag;
}
static err_t bl653_example ( bl653_t *ctx )
{
err_t error_flag = BL653_OK;
uint32_t timeout_cnt = 0;
#define BT_TERMINAL_TIMEOUT_MS 60000
#define BT_TERMINAL_MESSAGE_FREQ_MS 5000
#define TERMINATION_CMD "END"
#define TERMINATION_RESPONSE "END command received, the connection will be terminated in a few seconds."
#define TERMINATION_TIMEOUT "Timeout, closing the connection in a few seconds."
#define NEW_LINE_STRING "\r\n"
#define DISCONNECT_PEER "0"
log_printf( &logger, ">>> Waiting for a BT peer to establish connection with the Click board...\r\n" );
for ( ; ; )
{
bl653_clear_app_buf( );
if ( BL653_OK == bl653_process( ctx ) )
{
Delay_ms ( 200 );
bl653_process( ctx );
bl653_log_app_buf( );
if ( strstr( app_buf, BL653_RSP_CONNECT ) )
{
log_printf( &logger, "--------------------------------\r\n" );
log_printf( &logger, ">>> BT peer has connected.\r\n" );
break;
}
}
}
log_printf( &logger, ">>> Waiting for data (up to 60 seconds)...\r\n" );
log_printf( &logger, ">>> Connection will be terminated if the Click receives an \"END\" string.\r\n" );
for ( ; ; )
{
bl653_clear_app_buf( );
if ( BL653_OK == bl653_process( ctx ) )
{
Delay_ms ( 200 );
timeout_cnt = 0;
bl653_process( ctx );
bl653_log_app_buf( );
if ( strstr( app_buf, TERMINATION_CMD ) )
{
log_printf( &logger, ">>> Terminating connection on demand.\r\n" );
bl653_generic_write ( ctx, TERMINATION_RESPONSE, strlen ( TERMINATION_RESPONSE ) );
bl653_generic_write ( ctx, NEW_LINE_STRING, strlen ( NEW_LINE_STRING ) );
Delay_ms ( 100 );
log_printf( &logger, ">>> Disconnecting BT peer.\r\n" );
// Sending 4 escape chars with at least 250ms intervening delay
bl653_generic_write ( ctx, BL653_CMD_VSP_ESCAPE_CHAR, strlen ( BL653_CMD_VSP_ESCAPE_CHAR ) );
Delay_ms ( 300 );
bl653_generic_write ( ctx, BL653_CMD_VSP_ESCAPE_CHAR, strlen ( BL653_CMD_VSP_ESCAPE_CHAR ) );
Delay_ms ( 300 );
bl653_generic_write ( ctx, BL653_CMD_VSP_ESCAPE_CHAR, strlen ( BL653_CMD_VSP_ESCAPE_CHAR ) );
Delay_ms ( 300 );
bl653_generic_write ( ctx, BL653_CMD_VSP_ESCAPE_CHAR, strlen ( BL653_CMD_VSP_ESCAPE_CHAR ) );
Delay_ms ( 300 );
error_flag |= bl653_read_response( ctx, BL653_RSP_NO_CARRIER );
break;
}
else if ( strstr( app_buf, BL653_RSP_NO_CARRIER ) )
{
log_printf( &logger, ">>> BT peer has disconnected.\r\n" );
break;
}
}
timeout_cnt++;
if ( 0 == ( timeout_cnt % BT_TERMINAL_MESSAGE_FREQ_MS ) )
{
log_printf( &logger, ">>> Sending \"%s\" message to connected device.\r\n", ( char * ) MESSAGE_CONTENT );
bl653_generic_write ( ctx, MESSAGE_CONTENT, strlen ( MESSAGE_CONTENT ) );
bl653_generic_write ( ctx, NEW_LINE_STRING, strlen ( NEW_LINE_STRING ) );
Delay_ms ( 100 );
}
if ( BT_TERMINAL_TIMEOUT_MS < timeout_cnt )
{
log_printf( &logger, ">>> Terminating connection due to 60s timeout expiration.\r\n" );
bl653_generic_write ( ctx, TERMINATION_TIMEOUT, strlen ( TERMINATION_TIMEOUT ) );
bl653_generic_write ( ctx, NEW_LINE_STRING, strlen ( NEW_LINE_STRING ) );
Delay_ms ( 100 );
log_printf( &logger, ">>> Disconnecting BT peer.\r\n" );
// Sending 4 escape chars with at least 250ms intervening delay
bl653_generic_write ( ctx, BL653_CMD_VSP_ESCAPE_CHAR, strlen ( BL653_CMD_VSP_ESCAPE_CHAR ) );
Delay_ms ( 300 );
bl653_generic_write ( ctx, BL653_CMD_VSP_ESCAPE_CHAR, strlen ( BL653_CMD_VSP_ESCAPE_CHAR ) );
Delay_ms ( 300 );
bl653_generic_write ( ctx, BL653_CMD_VSP_ESCAPE_CHAR, strlen ( BL653_CMD_VSP_ESCAPE_CHAR ) );
Delay_ms ( 300 );
bl653_generic_write ( ctx, BL653_CMD_VSP_ESCAPE_CHAR, strlen ( BL653_CMD_VSP_ESCAPE_CHAR ) );
Delay_ms ( 300 );
error_flag |= bl653_read_response( ctx, BL653_RSP_NO_CARRIER );
break;
}
Delay_ms ( 1 );
}
return error_flag;
}
// ------------------------------------------------------------------------ END
额外支持
资源
类别:蓝牙/蓝牙低功耗