BLE TINY click
BLE TINY Click is a compact add-on board that provides BLE connectivity for any embedded application. This board features the DA14531, SmartBond TINY module based on the world’s smallest and lowest power Bluetooth 5.1 System-on-Chip (SoC) from Dialog Semiconductor.
click Product page
Click library
- Author : Luka Filipovic
- Date : Apr 2021.
- Type : UART type
Software Support
We provide a library for the BLETINY Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.
Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on mikroE github account.
Library Description
This library contains API for BLETINY Click driver.
Standard key functions :
bletiny_cfg_setup
Config Object Initialization function.
void bletiny_cfg_setup(bletiny_cfg_t *cfg)
BLE TINY configuration object setup function.
BLE TINY Click configuration object.
Definition bletiny.h:180
bletiny_init
Initialization function.
err_t bletiny_init(bletiny_t *ctx, bletiny_cfg_t *cfg)
BLE TINY initialization function.
BLE TINY Click context object.
Definition bletiny.h:162
bletiny_default_cfg
Click Default Configuration function.
err_t bletiny_default_cfg(bletiny_t *ctx)
BLE TINY default configuration function.
Example key functions :
bletiny_send_cmd
Send command function.
void bletiny_send_cmd(bletiny_t *ctx, char *cmd)
Send command function.
bletiny_i2c_config
Configure Click board for I2C master communication.
void bletiny_i2c_config(bletiny_t *ctx, uint8_t speed, uint8_t reg_len)
Configure Click board for I2C master communication.
bletiny_i2c_write
Send command to write data to reg address of slave device via I2C communication.
err_t bletiny_i2c_write(bletiny_t *ctx, uint8_t slave_address, uint16_t reg, uint8_t reg_data)
Send command to write data to reg address of slave device via I2C communication.
Example Description
This example reads and processes data from BLE TINY clicks.
Application waits for connection with Click board with phone. Then checks its Coadless FW version and checks connected device. Then waits for command to be stored in it's memory on 0 slot. After that depending on the command stored it executes that type of example.
The demo application is composed of two sections :
Application Init
Initializes driver and resets device and seds Disconnect and Reset IO commands.
Then it waits for the connection to device. When connected it sends commands to check Coadless FW, connected device, its BLE address and signal quality of connection. In the end it waits for command from its memory. After valid command is stored in memory on 0 slot it contines to Application Task.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_printf( &logger, "\r\nApplication Init\r\n" );
Delay_ms ( 1000 );
if ( init_flag == UART_ERROR )
{
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
bletiny_process( );
bletiny_clear_app_buf( );
app_buf_len = 0;
app_buf_cnt = 0;
log_printf( &logger, " Waiting for phone to connect\r\n" );
{
bletiny_process( );
}
log_printf( &logger, " Connected\r\n" );
bletiny_clear_app_buf( );
volatile err_t app_error_flag = bletiny_rsp_check();
{
bletiny_log_app_buf();
log_printf( &logger, "-----------------------------------\r\n" );
}
else
{
bletiny_error_check( app_error_flag );
}
Delay_ms ( 1000 );
app_error_flag = bletiny_rsp_check();
{
bletiny_log_app_buf();
log_printf( &logger, "-----------------------------------\r\n" );
}
else
{
bletiny_error_check( app_error_flag );
}
Delay_ms ( 1000 );
app_error_flag = bletiny_rsp_check();
{
bletiny_log_app_buf();
log_printf( &logger, "-----------------------------------\r\n" );
}
else
{
bletiny_error_check( app_error_flag );
}
Delay_ms ( 1000 );
app_error_flag = bletiny_rsp_check();
{
bletiny_log_app_buf();
log_printf( &logger, "-----------------------------------\r\n" );
}
else
{
bletiny_error_check( app_error_flag );
}
bletiny_example_init( );
bletiny_clear_app_buf( );
log_printf( &logger, " Application Task \r\n" );
}
@ BLETINY_OK
Definition bletiny.h:203
#define BLETINY_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition bletiny.h:149
#define BLETINY_CMD_ATRI
Definition bletiny.h:78
#define BLETINY_CMD_BDADDR
Definition bletiny.h:79
#define BLETINY_CMD_ATR
BLE TINY control commands.
Definition bletiny.h:74
#define BLETINY_CMD_ATI
Definition bletiny.h:77
#define BLETINY_CMD_RSSI
Definition bletiny.h:80
#define BLETINY_CMD_GAPDISCONNECT
Definition bletiny.h:76
#define BLETINY_CMD_ATZ
Definition bletiny.h:75
#define BLETINY_CONNECTED
Definition bletiny.h:102
void application_init(void)
Definition main.c:181
Application Task
Executes one of thre application task selected in Application Init:I2C, SPI, APP.
I2C example uses EEPROM Click board to write and read data of its memory. SPI example uses EEPROM 2 Click board to write and read data of its memory. APP example just reads UART data and logs it to UART Terminal.
{
static uint8_t info = 0;
switch ( example_type )
{
{
if (!info)
{
info++;
log_printf( &logger, " I2C example\r\n" );
bletiny_process( );
bletiny_clear_app_buf( );
}
bletiny_i2c_example( );
break;
}
{
if (!info)
{
info++;
log_printf( &logger, " SPI example\r\n" );
bletiny_process( );
bletiny_clear_app_buf( );
}
bletiny_spi_example( );
break;
}
{
if (!info)
{
info++;
log_printf( &logger, " Application example\r\n" );
bletiny_process( );
bletiny_clear_app_buf( );
}
bletiny_application_example( );
break;
}
default:
{
break;
}
}
}
void application_task(void)
Definition main.c:289
@ BLETINY_I2C_EXAMPLE
Definition main.c:65
@ BLETINY_APP_CTRL
Definition main.c:64
@ BLETINY_SPI_EXAMPLE
Definition main.c:66
Note
For this application you need to install Dialog's mobile application SmartConsole.
This application I2C example is created using EEPROM Click board, and for SPI example EEPROM 2 Click board is used.
The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on mikroE github account.
Other mikroE Libraries used in the example:
- MikroSDK.Board
- MikroSDK.Log
- Click.BLETINY
Additional notes and informations
Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all Mikroelektronika compilers.