Middleware for the Bluetooth peripheral on RA MCUs. This module implements the BLE ABS Interface.
Overview
This module provides BLE GAP functionality that complies with the Bluetooth Core Specification version 5.0 specified by the Bluetooth SIG. This module is configured via the QE for BLE. QE for BLE provides standard and custom services defined by the user.
The module supports the Renesas Electronics DA14531 Bluetooth® Low Energy 5 Module. The rm_ble_abs_gtl driver interfaces with the DA14531 module over UART.
Features
The Bluetooth Low Energy (BLE) Abstraction module with GTL supports the following features:
- Common functionality
- Open/Close the BLE protocol stack.
- The following GAP Role support
- Peripheral: The device that accepts a connection request from Central and establishes a connection.
- GAP functionality
- Initialize the Host stack.
- Setting address.
- Start/Stop Advertising.
- Connect/Disconnect a link.
- GATT Common functionality
- GATT Server functionality
- Initialization of GATT Server.
- Loading of Profile definition.
- Notification of characteristics modification.
- Read/Write of GATT Profile from host.
Configuration
Pin Configuration
Pins used by the BLE driver to control the DA14531 module:
- Reset Pin : Active low reset line for DA14531 module
- UART Interface : RX/TX Pins
Usage Notes
Getting Started Guide
The below guide walks users through building a fully working solution that allows booting from the host via 1-wire UART in order to run a BLE application from the RA MCU using the GTL interface.
https://lpccs-docs.renesas.com/DA1453x-FSP_BLE_Framework/UM-B-172/index.html
Addresses
When using a public BD address the address pre-programmed into the DA14531 will be used and can't be overridden.
A random address can be set by calling the R_BLE_VS_SetBdAddr function before the R_BLE_GAP_Init function is called.
Heap Requirements
Ensure the BSP heap size is set to at least 2K bytes.
When using FreeRTOS ensure the heap 4 size is set to a minimum of 2K bytes.
Module Firmware Compatibility
This middleware module is compatible with GTL binary version 6.0.18 and later. You must ensure that the DA14531 Module (or PMOD) you are using contains this version (or later) firmware or that you use the boot from host feature and have the host MCU load the binary into the DA14531.
Instructions detailing how to upgrade the firmware in a DA14531 Module can be found here:
https://lpccs-docs.renesas.com/US159-DA14531EVZ_Firmware_Upgrade/index.html
The GTL binary file can be downloaded using the tool described in the above instructions, or by using the following link:
https://www.renesas.com/us/en/document/swo/fsp-gtl-binary-us159-da14531evz-pmod-programming?r=1564826
Limitations
Developers should be aware of the following limitations when using the BLE_ABS:
Following a power on reset, the R_BLE_VS_GetRand function always returns the same number. Subsequent calls to this function produce random numbers.
Service and characteristic write callback functions, created when using the QE Tool are not supported
The boot from host feature currently only supports 1-wire UART operation. This means that the UART RX and TX pins on the host RA MCU must be tied together using a 1K ohm resistor in order to boot the DA14531 - this resistor can remain in place after the boot operation has been completed.
Currently supported rm_ble_abs_gtl interface functions:
- RM_BLE_ABS_Open
- RM_BLE_ABS_Close
- RM_BLE_ABS_StartLegacyAdvertising
Currently supported r_ble_api interface functions:
- R_BLE_Open
- R_BLE_Close
- R_BLE_Execute
- R_BLE_IsTaskFree
- R_BLE_GetVersion
- R_BLE_GAP_Init
- R_BLE_GAP_Terminate
- R_BLE_GAP_UpdConn
- R_BLE_GAP_SetDataLen
- R_BLE_GAP_Disconnect
- R_BLE_GAP_GetVerInfo
- R_BLE_GAP_ReadRssi
- R_BLE_GAP_ReadChMap
- R_BLE_GAP_SetAdvParam
- R_BLE_GAP_SetAdvSresData
- R_BLE_GAP_StartAdv
- R_BLE_GAP_StopAdv
- R_BLE_GAP_GetRemainAdvBufSize
- R_BLE_GAP_GetRemDevInfo
- R_BLE_GATTS_SetDbInst
- R_BLE_GATT_GetMtu
- R_BLE_GATTS_RegisterCb
- R_BLE_GATTS_DeregisterCb
- R_BLE_GATTS_Notification
- R_BLE_GATTS_Indication
- R_BLE_GATTS_GetAttr
- R_BLE_GATTS_SetAttr
- R_BLE_GATTC_RegisterCb
- R_BLE_GATTC_DeregisterCb
- R_BLE_GATTC_ReqExMtu
- R_BLE_GATTC_DiscAllPrimServ
- R_BLE_GATTC_DiscIncServ
- R_BLE_GATTC_ReadChar
- R_BLE_GATTC_WriteCharWithoutRsp
- R_BLE_GATTC_SignedWriteChar
- R_BLE_GATTC_WriteChar
- R_BLE_GATTC_WriteLongChar
- R_BLE_GATTC_ExecWrite
- R_BLE_VS_Init
- R_BLE_VS_GetBdAddr
- R_BLE_VS_SetBdAddr
- R_BLE_VS_GetRand
Currently supported callback events:
- BLE_GAP_EVENT_STACK_ON
- BLE_GAP_EVENT_STACK_OFF
- BLE_GAP_EVENT_CONN_IND
- BLE_GAP_EVENT_DISCONN_IND
- BLE_GAP_EVENT_DATA_LEN_CHG
- BLE_GAP_EVENT_CONN_PARAM_UPD_COMP
- BLE_GAP_EVENT_ADV_ON
- BLE_GAP_EVENT_ADV_OFF
- BLE_GAP_EVENT_SET_DATA_LEN_COMP
- BLE_GAP_EVENT_LOC_VER_INFO
- BLE_GAP_EVENT_RSSI_RD_COMP
- BLE_GAP_EVENT_CH_MAP_RD_COMP
- BLE_GAP_EVENT_GET_REM_DEV_INFO
- BLE_GATTS_EVENT_WRITE_RSP_COMP
- BLE_GATTS_EVENT_HDL_VAL_CNF
- BLE_GATTS_EVENT_DB_ACCESS_IND
- BLE_GATTC_EVENT_EX_MTU_RSP
- BLE_GATTC_EVENT_PRIM_SERV_16_DISC_IND
- BLE_GATTC_EVENT_PRIM_SERV_128_DISC_IND
- BLE_GATTC_EVENT_ALL_PRIM_SERV_DISC_COMP
Examples
BLE_ABS_GTL Basic Example
This is a basic example of minimal use of the BLE_ABS_GTL in an application.
void gap_peripheral_cb (uint16_t type, ble_status_t result,
st_ble_evt_data_t * p_data)
{
switch (type)
{
{
g_ble_event_flag = g_ble_event_flag | BLE_ABS_EVENT_FLAG_STACK_ON;
break;
}
{
g_advertising_handle = p_gap_adv_set_evt_param->
adv_hdl;
g_ble_event_flag |= BLE_ABS_EVENT_FLAG_ADV_ON;
break;
}
{
g_ble_event_flag |= BLE_ABS_EVENT_FLAG_ADV_OFF;
break;
}
{
g_ble_event_flag |= BLE_ABS_EVENT_FLAG_CONN_IND;
break;
}
{
break;
}
default:
break;
}
}
#define BLE_ABS_EVENT_FLAG_STACK_ON (0x01 << 0)
#define BLE_ABS_EVENT_FLAG_CONN_IND (0x01 << 1)
#define BLE_ABS_EVENT_FLAG_ADV_ON (0x01 << 2)
#define BLE_ABS_EVENT_FLAG_ADV_OFF (0x01 << 3)
#define BLE_ABS_EVENT_FLAG_DISCONN_IND (0x01 << 4)
#define BLE_ABS_EVENT_FLAG_RSLV_LIST_CONF_COMP (0x01 << 5)
#define BLE_ABS_EXAMPLE_SHORTENED_LOCAL_NAME 'E', 'x', 'a', 'm', 'p', 'l', 'e'
#define BLE_ABS_EXAMPLE_COMPLETE_LOCAL_NAME 'T', 'E', 'S', 'T', '_', 'E', 'x', 'a', 'm', 'p', 'l', 'e'
#define BLE_ABS_EXAMPLE_SLOW_ADVERTISING_INTERVAL (0x00000640)
void ble_abs_peripheral_example (void)
{
volatile uint32_t timeout = UINT16_MAX * UINT8_MAX * 8;
uint8_t advertising_data[] =
{
0x02,
0x01,
(0x1a),
0x08,
0x08,
BLE_ABS_EXAMPLE_SHORTENED_LOCAL_NAME,
};
uint8_t scan_response_data[] =
{
0x0D,
0x09,
BLE_ABS_EXAMPLE_COMPLETE_LOCAL_NAME,
};
{
.slow_advertising_interval = BLE_ABS_EXAMPLE_SLOW_ADVERTISING_INTERVAL,
.slow_advertising_period = 0x0000,
.p_advertising_data = advertising_data,
.advertising_data_length = sizeof(advertising_data),
.p_scan_response_data = scan_response_data,
.scan_response_data_length = sizeof(scan_response_data),
.own_bluetooth_address = {0},
};
g_ble_event_flag = 0;
assert(FSP_SUCCESS == err);
assert(FSP_SUCCESS == err);
while (!(BLE_ABS_EVENT_FLAG_STACK_ON & g_ble_event_flag) && (--timeout > 0U))
{
}
time_out_handle_error(timeout);
g_ble_event_flag = 0;
timeout = UINT16_MAX * UINT8_MAX * 8;
assert(FSP_SUCCESS == err);
while (!(BLE_ABS_EVENT_FLAG_CONN_IND & g_ble_event_flag) && (--timeout > 0U))
{
if (BLE_ABS_EVENT_FLAG_ADV_OFF & g_ble_event_flag)
{
if (FSP_SUCCESS == err)
{
g_ble_event_flag &= (uint16_t) ~BLE_ABS_EVENT_FLAG_ADV_OFF;
}
{
;
}
else
{
assert(FSP_SUCCESS == err);
}
}
else if ((timeout % BLE_ABS_RETRY_INTERVAL) == 0U)
{
}
else
{
;
}
}
time_out_handle_error(timeout);
g_ble_event_flag = 0;
assert(FSP_SUCCESS == err);
}