享受高质量音频和数据传输,无限制。
A
A
硬件概览
它是如何工作的?
BLE 12 Click基于BM832A,这是一款高度灵活、超低功耗的蓝牙模块,为任何嵌入式应用提供BLE连接,由Fanstel提供。BM832A模块基于Nordic nRF52 SoC,集成了64MHz的32位ARM Cortex M4处理器,具有浮点单元(FPU)和2.4GHz多协议无线电(支持蓝牙5.0和集成PCB天线),具有-96dBm RX灵敏度(取决于数据速率),以及192kB的Flash内存和24kB的RAM。BLE 12 Click允许使用UART和SPI接口,常用的UART RX和TX引脚作为默认通信协议,用于以默认配置的115200 bps速度传输和交换AT命令,以便与主机MCU进行数据传输和交换。可以通过将标记为COMM SEL的SMD跳线置于适当位置来进行选择。注意,所有跳线的位置必须在同一侧,否则
Click board™可能会无响应。mikroBUS™的PWM引脚上的CMD引脚代表通信激活功能。CMD引脚的高逻辑状态允许模块与MCU通信,而低状态允许数据透明地发送到远端设备(例如智能手机)。在选择UART接口的情况下,可以通过发送命令"AT+STOP"来减少功耗。CS引脚必须设置为低逻辑状态200μs或更长时间,以唤醒UART接口。此外,它还有一个额外的数据就绪信号,标记为REQ,并连接到mikroBUS™插座的INT引脚,表示有新数据准备好供主机使用。此Click board™通过了全球范围内的监管认证,提供了增强的性能、安全性和可靠性,以支持在蓝牙网络上运行的物联网产品。此外,在BLE 12 Click的中心,还有一个额外的未填充的头部,提供了完全的
调试和编程支持。通过这个头部,用户可以使用串行线调试接口进行编程和调试,通过SWD接口引脚(SWDIO,SWCLK和SWO)提供。除了适当的接口外,此Click board™还具有一些额外的功能。一个连接到mikroBUS™插座RST引脚的复位按钮将模块置于复位状态,而两个额外的LED指示灯,标记为LED1和LED2的黄色和红色LED,可以用于可选的用户配置的视觉指示。此Click board™只能在3.3V逻辑电压水平下运行。因此,在使用不同逻辑电平的MCU之前,必须进行适当的逻辑电压电平转换。此外,此Click board™配备了包含函数和示例代码的库,可用作进一步开发的参考。
功能概述
开发板
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”替换为要显示的参数。

软件支持
库描述
该库包含 BLE 12 Click 驱动程序的 API。
关键功能:
ble12_set_device_name
- BLE 12 设置设备名称功能ble12_set_op_mode
- BLE 12 设置操作模式功能ble12_send_cmd
- BLE 12 发送命令功能
开源
代码示例
完整的应用程序代码和一个现成的项目可以通过NECTO Studio包管理器直接安装到NECTO Studio。 应用程序代码也可以在MIKROE的GitHub账户中找到。
/*!
* @file main.c
* @brief BLE 12 Click Example.
*
* # Description
* This example reads and processes data from BLE 12 Click board™.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes UART driver and logs UART.
* After driver initialization, the app performs a wake-up module,
* enters command mode, sets the device name and advertising time interval,
* and disconnects all connections.
* After that, the blinking of the yellow LED Indicates
* that the BLE 12 Click board™ is ready for connection.
* After establishing the connection, the yellow LED is turned on.
*
* ## Application Task
* This example demonstrates the use of the BLE 12 Click board™.
* Reads the received data and parses it.
* Results are being sent to the Usart Terminal, where you can track their changes.
*
* ## Additional Function
* - static void ble12_clear_app_buf ( void )
* - static err_t ble12_process ( void )
*
* @note
* We have used the Serial Bluetooth Terminal Android application for the test
* and you can find it at the link:
* https://play.google.com/store/apps/details?id=de.kai_morich.serial_bluetooth_terminal
*
* @author Nenad Filipovic
*
*/
#include "board.h"
#include "log.h"
#include "ble12.h"
#define PROCESS_BUFFER_SIZE 200
#define RSP_TIMEOUT 100
static ble12_t ble12;
static log_t logger;
static char app_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
static int32_t app_buf_len = 0;
static int32_t app_buf_cnt = 0;
/**
* @brief BLE 12 clearing application buffer.
* @details This function clears memory of application buffer and reset it's length and counter.
* @note None.
*/
static void ble12_clear_app_buf ( void );
/**
* @brief BLE 12 data reading function.
* @details This function reads data from device and concatenates data to application buffer.
*
* @return @li @c 0 - Read some data.
* @li @c -1 - Nothing is read.
* @li @c -2 - Application buffer overflow.
*
* See #err_t definition for detailed explanation.
* @note None.
*/
static err_t ble12_process ( void );
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
ble12_cfg_t ble12_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.
ble12_cfg_setup( &ble12_cfg );
BLE12_MAP_MIKROBUS( ble12_cfg, MIKROBUS_1 );
if ( UART_ERROR == ble12_init( &ble12, &ble12_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( BLE12_ERROR == ble12_default_cfg ( &ble12 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
app_buf_len = 0;
app_buf_cnt = 0;
Delay_ms( 100 );
log_info( &logger, " Application Task " );
log_printf( &logger, "-------------------------------\r\n" );
log_printf( &logger, "\t BLE 12 Click\r\n" );
log_printf( &logger, "-------------------------------\r\n" );
log_printf( &logger, "\t Command mode\r\n" );
ble12_set_op_mode( &ble12, BLE12_OP_MODE_CMD );
Delay_ms( 100 );
ble12_event_startup( &ble12 );
Delay_ms( 100 );
ble12_set_led_state( &ble12, BLE12_LED_RED, BLE12_LED_OFF );
ble12_set_led_state( &ble12, BLE12_LED_YELLOW, BLE12_LED_OFF );
Delay_ms( 100 );
log_printf( &logger, "- - - - - - - - - - - - - - - -\r\n" );
log_printf( &logger, "> Set device name:" );
log_printf( &logger, " BLE 12 Click\r\n" );
ble12_set_device_name( &ble12, "BLE 12 Click" );
Delay_ms( 100 );
log_printf( &logger, "> Set Adv. Interval: 99 ms\r\n" );
ble12_set_adv_interval( &ble12, "0099" );
Delay_ms( 100 );
log_printf( &logger, "> Disconnect all connections\r\n" );
ble12_disconnect( &ble12 );
Delay_ms( 100 );
log_printf( &logger, "-------------------------------\r\n" );
log_printf( &logger, " Please connect your device\r\n" );
do
{
ble12_process();
ble12_set_led_state( &ble12, BLE12_LED_YELLOW, BLE12_LED_ON );
Delay_ms( 50 );
ble12_set_led_state( &ble12, BLE12_LED_YELLOW, BLE12_LED_OFF );
Delay_ms( 50 );
}
while ( !strstr( app_buf, BLE12_EVT_CONNECTED ) );
Delay_ms( 100 );
ble12_set_led_state( &ble12, BLE12_LED_RED, BLE12_LED_OFF );
ble12_set_led_state( &ble12, BLE12_LED_YELLOW, BLE12_LED_ON );
log_printf( &logger, "- - - - - - - - - - - - - - - -\r\n" );
log_printf( &logger, "\tDevice connected\r\n" );
Delay_ms( 100 );
ble12_set_op_mode( &ble12, BLE12_OP_MODE_DATA );
log_printf( &logger, "-------------------------------\r\n" );
log_printf( &logger, "\t Data mode\r\n" );
log_printf( &logger, "- - - - - - - - - - - - - - - -\r\n" );
Delay_ms( 100 );
ble12_process();
ble12_clear_app_buf( );
Delay_ms( 100 );
}
void application_task ( void )
{
ble12_process();
if ( app_buf_len > 0 )
{
log_printf( &logger, "%s", app_buf );
ble12_clear_app_buf( );
}
}
void main ( void )
{
application_init( );
for ( ; ; )
{
application_task( );
}
}
static void ble12_clear_app_buf ( void )
{
memset( app_buf, 0, app_buf_len );
app_buf_len = 0;
app_buf_cnt = 0;
}
static err_t ble12_process ( void )
{
int32_t rx_size;
char rx_buff[ PROCESS_BUFFER_SIZE ] = { 0 };
rx_size = ble12_generic_read( &ble12, rx_buff, PROCESS_BUFFER_SIZE );
if ( rx_size > 0 )
{
int32_t buf_cnt = 0;
if ( app_buf_len + rx_size >= PROCESS_BUFFER_SIZE )
{
ble12_clear_app_buf( );
return BLE12_ERROR;
}
else
{
buf_cnt = app_buf_len;
app_buf_len += rx_size;
}
for ( int32_t rx_cnt = 0; rx_cnt < rx_size; rx_cnt++ )
{
if ( ( rx_buff[ rx_cnt ] != 0 ) && ( rx_buff[ rx_cnt ] != 0x2B ) )
{
app_buf[ ( buf_cnt + rx_cnt ) ] = rx_buff[ rx_cnt ];
}
else
{
app_buf_len--;
buf_cnt--;
}
}
return BLE12_OK;
}
return BLE12_ERROR;
}
// ------------------------------------------------------------------------ END