Hardware components | ||||||
| × | 1 | ||||
Software apps and online services | ||||||
| ||||||
| ||||||
| ||||||
On this project I will go through how you can control Advertising on the DA14531MOD by button interrupt. The DA14531MOD will start Undirected Connectable Advertising and when the SW2 (on the DevKit) is pressed it will switch to Non-Connectable Advertising (beacon). For this project I used DA1453x Dev Kit Pro with the DA14531MOD Daughterboard.I used the latest SDK v6.0.24, Keil IDE and the empty_peripheral_template project.The project can be found on:...\DA145xx_SDK\6.0.24.1464\projects\target_apps\template\empty_peripheral_template
Regarding SDK6:The DA1453x/DA1458x software platform utilizes a small and efficient Real-Time Kernel. Almost the complete BLE Stack and most of the application makes use of the services offered by the Real-Time Kernel. The kernel offers task, message, events and dynamic memory capabilities. The tasks communicate with messages, which are pushed in a queue whenever a task is trying to send a message to another task. Timers and other hardware events also push events in a queue. Whenever the kernel scheduler is called from the main loop it pops messages and events out of the queues according to their priority and invokes the relevant handler, to trigger the execution of the different tasks. The execution continues until the queues are empty.The core of the kernel is a scheduler that runs in the main loop of the application. The scheduler checks if an event is set and calls the corresponding handler to service the pending events. The event may be a BLE or a timer event, or a message between two tasks.The BLE example applications expose a number of callback functions in the form of a structure (see the user_app_main_loop_callbacks structure definition in the respective user_callback_config.h file). Such functions may be called in the main loop in order to handle certain events system-wise. BLE events may be handled at user level through callback functions.More detailed information can be found on: UM-B-119: DA1453x/DA1458x SW Platform Reference Manual — UM-B-119: DA1453x/DA1458x SW Platform Reference Manual
When we open the project, we will go on user_callback_config.h file and we will insert our callbacks for the BLE events.
.app_on_connection = user_on_connection,
.app_on_disconnect = user_on_disconnect,
.app_on_update_params_rejected = NULL,
.app_on_update_params_complete = NULL,
.app_on_set_dev_config_complete = default_app_on_set_dev_config_complete,
.app_on_adv_nonconn_complete = user_app_adv_nonconn_complete,
.app_on_adv_undirect_complete = user_app_adv_undirect_complete,
.app_on_adv_direct_complete = NULL,
.app_on_db_init_complete = default_app_on_db_init_complete,
.app_on_scanning_completed = NULL,
.app_on_adv_report_ind = NULL,
.app_on_get_dev_name = default_app_on_get_dev_name,
.app_on_get_dev_appearance = default_app_on_get_dev_appearance,
.app_on_get_dev_slv_pref_params = default_app_on_get_dev_slv_pref_params,
.app_on_set_dev_info = default_app_on_set_dev_info,
.app_on_data_length_change = NULL,
.app_on_update_params_request = default_app_update_params_request,
.app_on_generate_static_random_addr = default_app_generate_static_random_addr,
.app_on_svc_changed_cfg_ind = NULL,
.app_on_get_peer_features = NULL,Note: Details on the code will be shared on the Code section.
We will then continue on the user_empty_peripheral_template.c file to implement the callbacks we have declared.The idea is that DA14531 will start Undirected connectable advertising with the user_app_adv_undirect_start function. During the initialization of the device we would have an Interrupt configured on Button pressed. We will use P0_11 for the Button which corresponds to SW2 on the Dev Kit.For this Button interrupt we will use the Wake-Up Controller because we will enable Extended Sleep mode for our project as well.When the Button interrupt occurs, the app_button_press_cb callback function will be executed.Inside that callback function we will stop advertising via the app_easy_gap_advertise_stop API and reconfigure the Button Interrupt via app_button_enable function. That will trigger the user_app_adv_undirect_complete BLE event callback function.Inside the user_app_adv_undirect_complete callback we will call the user_app_adv_nonconn_start function which will start Non-Connectable Advertising which is used for beacon implementations.If user presses the Button again then the same interrupt callback will be executed.This time, the user_app_adv_nonconn_complete BLE event callback will be executed after we stopped advertising.Inside the user_app_adv_nonconn_complete we will call the user_app_adv_undirect_start function to start Undirected Connectable Advertising.The project will continue going through this loop.As mentioned above, we would like to use Extended Sleep mode.We will go on user_config.h file and we will modify the app_deafult_sleep_mode as shown below:
/******************************************
* Default sleep mode. Possible values are:
*
* - ARCH_SLEEP_OFF
* - ARCH_EXT_SLEEP_ON
* - ARCH_EXT_SLEEP_OTP_COPY_ON
*
******************************************
*/
static const sleep_state_t app_default_sleep_mode = ARCH_EXT_SLEEP_ON;The Extended Sleep mode will power down the BLE core between Advertising/Scanning/Connection intervals and wake up to handle BLE events.During Extended Sleep mode we cannot have any Peripheral block active (e.g. I2C, UART etc). If we want Peripheral blocks, we will have to go handle the Extended Sleep mode via the available APIs.
More details on the available Sleep modes can be found here: DA1453x & DA1458x Sleep Modes Tutorial — DA1453x & DA1458x Tutorial Sleep Modes
Details on how to configure the Advertising Intervals, the Connection intervals and more can be found on the user_config.h file.At the end, we will store our Firmware on the SPI Flash which is integrated on the DA14531MOD. For this purpose, we will initialize the SPI interface and use the SPI Flash APIs to make sure that the SPI Flash is powered down so we can guarantee low power consumption.Go on user_periph_setup.h file and add the following:
// Define SPI Configuration
#define SPI_MS_MODE SPI_MS_MODE_MASTER
#define SPI_CP_MODE SPI_CP_MODE_0
#define SPI_WSZ SPI_MODE_8BIT
#define SPI_CS SPI_CS_0
#define SPI_SPEED_MODE SPI_SPEED_MODE_4MHz
#define SPI_EDGE_CAPTURE SPI_MASTER_EDGE_CAPTURE
#define GPIO_BUTTON_PORT GPIO_PORT_0
#define GPIO_BUTTON_PIN GPIO_PIN_11Then on user_periph_setup.c file reserve and configure the SPI GPIOs as shown in the Code section. Finally initialize the SPI Flash interface (inside periph_init function) for the P25Q11U SPI Flash which is integrated on the DA14531MOD.
#if defined (CFG_SPI_FLASH_ENABLE)
// Configuration struct for SPI
static const spi_cfg_t spi_cfg = {
.spi_ms = SPI_MS_MODE,
.spi_cp = SPI_CP_MODE,
.spi_speed = SPI_SPEED_MODE,
.spi_wsz = SPI_WSZ,
.spi_cs = SPI_CS,
.cs_pad.port = SPI_EN_PORT,
.cs_pad.pin = SPI_EN_PIN,
#if defined (__DA14531__)
.spi_capture = SPI_EDGE_CAPTURE,
#endif
};
// Configuration struct for SPI FLASH
static const spi_flash_cfg_t spi_flash_cfg = {
.chip_size = P25Q11U_CHIP_SIZE,
.jedec_id = P25Q11U_JEDEC_ID,
};
#endif
#if defined (CFG_SPI_FLASH_ENABLE)
// Configure SPI Flash environment
spi_flash_configure_env(&spi_flash_cfg);
// Initialize SPI
spi_initialize(&spi_cfg);
#endifThe spi_flash_power_down API should be called on our user code.
By following the steps described above we have learned:
- Undirected Connectable Advertising
- Non-Connectable Advertising
- Handle BLE events via callbacks
- Button interrupts via Wake-up Controller
- Configure SPI Flash
- Extended Sleep mode
This configuration forms a solid foundation for creating low-power Bluetooth IoT devices with Renesas’ DA1453x.
Button Configuration
C/C++/**
****************************************************************************************
* @brief Triggered by button press.
****************************************************************************************
*/
static void app_button_press_cb(void)
{
#if defined (CFG_PRINTF)
arch_printf("Button pressed \r\n");
#endif
app_button_enable();
app_easy_gap_advertise_stop();
}
void app_button_enable(void)
{
wkupct_register_callback(app_button_press_cb);
wkupct_enable_irq(WKUPCT_PIN_SELECT(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN), // select pin (GPIO_BUTTON_PORT, GPIO_BUTTON_PIN)
WKUPCT_PIN_POLARITY(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN, WKUPCT_PIN_POLARITY_LOW), // polarity low
1, // 1 event
0); // debouncing time = 0
}
Handle Undirected Connectable Advertising
C/C++void user_app_adv_undirect_start(void)
{
struct gapm_start_advertise_cmd* cmd;
cmd = app_easy_gap_undirected_advertise_get_active();
#if defined (CFG_PRINTF)
arch_printf("Start undirected advertising \r\n");
#endif
app_easy_gap_undirected_advertise_start();
}
void user_app_adv_undirect_complete(uint8_t status)
{
#if defined (CFG_PRINTF)
arch_printf("Undirected advertising stopped \r\n");
#endif
// If advertising was canceled then update advertising data and start advertising again
if (status == GAP_ERR_CANCELED)
{
user_app_adv_nonconn_start();
}
}
Handle Non-Connectable Advertising
C/C++void user_app_adv_nonconn_start(void)
{
struct gapm_start_advertise_cmd* cmd;
cmd = app_easy_gap_non_connectable_advertise_get_active();
#if defined (CFG_PRINTF)
arch_printf("Start non-connectable advertising \r\n");
#endif
app_easy_gap_non_connectable_advertise_start();
}
void user_app_adv_nonconn_complete(uint8_t status)
{
#if defined (CFG_PRINTF)
arch_printf("Non connectable advertising stopped \r\n");
#endif
// If advertising was canceled then update advertising data and start advertising again
if (status == GAP_ERR_CANCELED)
{
user_app_adv_undirect_start();
}
}
BLE Connection-Disconnection
C/C++We have not made any implementation for those.
void user_on_connection(uint8_t connection_idx, struct gapc_connection_req_ind const *param)
{
#if defined (CFG_PRINTF)
arch_printf("Connected... \r\n");
#endif
default_app_on_connection(connection_idx, param);
}
void user_on_disconnect( struct gapc_disconnect_ind const *param )
{
#if defined (CFG_PRINTF)
arch_printf("Disconnected... \r\n");
#endif
default_app_on_disconnect(param);
}
/**
****************************************************************************************
*
* @file user_callback_config.h
*
* @brief Callback functions configuration file.
*
* Copyright (C) 2015-2025 Renesas Electronics Corporation and/or its affiliates.
* All rights reserved. Confidential Information.
*
* This software ("Software") is supplied by Renesas Electronics Corporation and/or its
* affiliates ("Renesas"). Renesas grants you a personal, non-exclusive, non-transferable,
* revocable, non-sub-licensable right and license to use the Software, solely if used in
* or together with Renesas products. You may make copies of this Software, provided this
* copyright notice and disclaimer ("Notice") is included in all such copies. Renesas
* reserves the right to change or discontinue the Software at any time without notice.
*
* THE SOFTWARE IS PROVIDED "AS IS". RENESAS DISCLAIMS ALL WARRANTIES OF ANY KIND,
* WHETHER EXPRESS, IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. TO THE
* MAXIMUM EXTENT PERMITTED UNDER LAW, IN NO EVENT SHALL RENESAS BE LIABLE FOR ANY DIRECT,
* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE, EVEN IF RENESAS HAS BEEN ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGES. USE OF THIS SOFTWARE MAY BE SUBJECT TO TERMS AND CONDITIONS CONTAINED IN
* AN ADDITIONAL AGREEMENT BETWEEN YOU AND RENESAS. IN CASE OF CONFLICT BETWEEN THE TERMS
* OF THIS NOTICE AND ANY SUCH ADDITIONAL LICENSE AGREEMENT, THE TERMS OF THE AGREEMENT
* SHALL TAKE PRECEDENCE. BY CONTINUING TO USE THIS SOFTWARE, YOU AGREE TO THE TERMS OF
* THIS NOTICE.IF YOU DO NOT AGREE TO THESE TERMS, YOU ARE NOT PERMITTED TO USE THIS
* SOFTWARE.
*
****************************************************************************************
*/
#ifndef _USER_CALLBACK_CONFIG_H_
#define _USER_CALLBACK_CONFIG_H_
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "app_api.h"
#include "app_bass.h"
#include "app_findme.h"
#include "app_proxr.h"
#include "app_suotar.h"
#include "app_callback.h"
#include "app_prf_types.h"
#if (BLE_APP_SEC)
#include "app_bond_db.h"
#endif // (BLE_APP_SEC)
#include "user_empty_peripheral_template.h"
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Function to be called on the advertising completion event.
* @param[in] uint8_t GAP Error code
****************************************************************************************
*/
void app_advertise_complete(const uint8_t);
/**
****************************************************************************************
* @brief SUOTAR session start or stop event handler.
* @param[in] suotar_event SUOTAR_START/SUOTAR_STOP
****************************************************************************************
*/
void on_suotar_status_change(const uint8_t suotar_event);
/*
* LOCAL VARIABLE DEFINITIONS
****************************************************************************************
*/
#if (BLE_BATT_SERVER)
static const struct app_bass_cb user_app_bass_cb = {
.on_batt_level_upd_rsp = NULL,
.on_batt_level_ntf_cfg_ind = NULL,
};
#endif
#if (BLE_FINDME_TARGET)
static const struct app_findt_cb user_app_findt_cb = {
.on_findt_alert_ind = default_findt_alert_ind_handler,
};
#endif
#if (BLE_PROX_REPORTER)
static const struct app_proxr_cb user_app_proxr_cb = {
.on_proxr_alert_ind = default_proxr_alert_ind_handler,
};
#endif
#if (BLE_SUOTA_RECEIVER)
static const struct app_suotar_cb user_app_suotar_cb = {
.on_suotar_status_change = on_suotar_status_change,
.on_suotar_version_check = default_suotar_on_version_check,
};
#endif
static const struct app_callbacks user_app_callbacks = {
.app_on_connection = user_on_connection,
.app_on_disconnect = user_on_disconnect,
.app_on_update_params_rejected = NULL,
.app_on_update_params_complete = NULL,
.app_on_set_dev_config_complete = default_app_on_set_dev_config_complete,
.app_on_adv_nonconn_complete = user_app_adv_nonconn_complete,
.app_on_adv_undirect_complete = user_app_adv_undirect_complete,
.app_on_adv_direct_complete = NULL,
.app_on_db_init_complete = default_app_on_db_init_complete,
.app_on_scanning_completed = NULL,
.app_on_adv_report_ind = NULL,
.app_on_get_dev_name = default_app_on_get_dev_name,
.app_on_get_dev_appearance = default_app_on_get_dev_appearance,
.app_on_get_dev_slv_pref_params = default_app_on_get_dev_slv_pref_params,
.app_on_set_dev_info = default_app_on_set_dev_info,
.app_on_data_length_change = NULL,
.app_on_update_params_request = default_app_update_params_request,
.app_on_generate_static_random_addr = default_app_generate_static_random_addr,
.app_on_svc_changed_cfg_ind = NULL,
.app_on_get_peer_features = NULL,
#if (BLE_APP_SEC)
.app_on_pairing_request = default_app_on_pairing_request,
.app_on_tk_exch = default_app_on_tk_exch,
.app_on_irk_exch = NULL,
.app_on_csrk_exch = NULL,
.app_on_ltk_exch = default_app_on_ltk_exch,
.app_on_pairing_succeeded = NULL,
.app_on_encrypt_ind = NULL,
.app_on_encrypt_req_ind = NULL,
.app_on_security_req_ind = NULL,
.app_on_addr_solved_ind = NULL,
.app_on_addr_resolve_failed = NULL,
#if !defined (__DA14531_01__) && !defined (__DA14535__)
.app_on_ral_cmp_evt = NULL,
.app_on_ral_size_ind = NULL,
.app_on_ral_addr_ind = NULL,
#endif // not for DA14531-01, DA14535
#endif // (BLE_APP_SEC)
};
#if (BLE_APP_SEC)
static const struct app_bond_db_callbacks user_app_bond_db_callbacks = {
.app_bdb_init = NULL,
.app_bdb_get_size = NULL,
.app_bdb_add_entry = NULL,
.app_bdb_remove_entry = NULL,
.app_bdb_search_entry = NULL,
.app_bdb_get_number_of_stored_irks = NULL,
.app_bdb_get_stored_irks = NULL,
.app_bdb_get_device_info_from_slot = NULL,
.app_bdb_erase = NULL,
};
#endif // (BLE_APP_SEC)
#define app_process_catch_rest_cb user_catch_rest_hndl
static const struct default_app_operations user_default_app_operations = {
.default_operation_adv = default_advertise_operation,
};
static const struct arch_main_loop_callbacks user_app_main_loop_callbacks = {
.app_on_init = user_app_init,
// By default the watchdog timer is reloaded and resumed when the system wakes up.
// The user has to take into account the watchdog timer handling (keep it running,
// freeze it, reload it, resume it, etc), when the app_on_ble_powered() is being
// called and may potentially affect the main loop.
.app_on_ble_powered = NULL,
// By default the watchdog timer is reloaded and resumed when the system wakes up.
// The user has to take into account the watchdog timer handling (keep it running,
// freeze it, reload it, resume it, etc), when the app_on_system_powered() is being
// called and may potentially affect the main loop.
.app_on_system_powered = NULL,
.app_before_sleep = NULL,
.app_validate_sleep = NULL,
.app_going_to_sleep = NULL,
.app_resume_from_sleep = NULL,
};
//place in this structure the app_<profile>_db_create and app_<profile>_enable functions
//for SIG profiles that do not have this function already implemented in the SDK
//or if you want to override the functionality. Check the prf_func array in the SDK
//for your reference of which profiles are supported.
static const struct prf_func_callbacks user_prf_funcs[] =
{
{TASK_ID_INVALID, NULL, NULL} // DO NOT MOVE. Must always be last
};
#endif // _USER_CALLBACK_CONFIG_H_
/**
****************************************************************************************
*
* @file user_empty_peripheral_template.h
*
* @brief Empty peripheral template project header file.
*
* Copyright (C) 2012-2023 Renesas Electronics Corporation and/or its affiliates.
* All rights reserved. Confidential Information.
*
* This software ("Software") is supplied by Renesas Electronics Corporation and/or its
* affiliates ("Renesas"). Renesas grants you a personal, non-exclusive, non-transferable,
* revocable, non-sub-licensable right and license to use the Software, solely if used in
* or together with Renesas products. You may make copies of this Software, provided this
* copyright notice and disclaimer ("Notice") is included in all such copies. Renesas
* reserves the right to change or discontinue the Software at any time without notice.
*
* THE SOFTWARE IS PROVIDED "AS IS". RENESAS DISCLAIMS ALL WARRANTIES OF ANY KIND,
* WHETHER EXPRESS, IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. TO THE
* MAXIMUM EXTENT PERMITTED UNDER LAW, IN NO EVENT SHALL RENESAS BE LIABLE FOR ANY DIRECT,
* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE, EVEN IF RENESAS HAS BEEN ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGES. USE OF THIS SOFTWARE MAY BE SUBJECT TO TERMS AND CONDITIONS CONTAINED IN
* AN ADDITIONAL AGREEMENT BETWEEN YOU AND RENESAS. IN CASE OF CONFLICT BETWEEN THE TERMS
* OF THIS NOTICE AND ANY SUCH ADDITIONAL LICENSE AGREEMENT, THE TERMS OF THE AGREEMENT
* SHALL TAKE PRECEDENCE. BY CONTINUING TO USE THIS SOFTWARE, YOU AGREE TO THE TERMS OF
* THIS NOTICE.IF YOU DO NOT AGREE TO THESE TERMS, YOU ARE NOT PERMITTED TO USE THIS
* SOFTWARE.
*
****************************************************************************************
*/
#ifndef _USER_EMPTY_PERIPHERAL_TEMPLATE_H_
#define _USER_EMPTY_PERIPHERAL_TEMPLATE_H_
/**
****************************************************************************************
* @addtogroup APP
* @ingroup RICOW
*
* @brief
*
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "rwble_config.h"
#include "app_task.h" // application task
#include "gapc_task.h" // gap functions and messages
#include "gapm_task.h" // gap functions and messages
#include "app.h" // application definitions
#include "co_error.h" // error code definitions
/****************************************************************************
Add here supported profiles' application header files.
i.e.
#if (BLE_DIS_SERVER)
#include "app_dis.h"
#include "app_dis_task.h"
#endif
*****************************************************************************/
/*
* TYPE DEFINITIONS
****************************************************************************************
*/
/*
* DEFINES
****************************************************************************************
*/
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Connection function.
* @param[in] conidx Connection Id index
* @param[in] param Pointer to GAPC_CONNECTION_REQ_IND message
****************************************************************************************
*/
void user_on_connection(const uint8_t conidx, struct gapc_connection_req_ind const *param);
/**
****************************************************************************************
* @brief Disconnection function.
* @param[in] param Pointer to GAPC_DISCONNECT_IND message
****************************************************************************************
*/
void user_on_disconnect(struct gapc_disconnect_ind const *param);
/**
****************************************************************************************
* @brief Undirect advertising completion function.
* @param[in] status Command complete event message status
****************************************************************************************
*/
void user_app_adv_undirect_complete(uint8_t status);
/**
****************************************************************************************
* @brief Application initialization function.
****************************************************************************************
*/
void user_app_init(void);
/**
****************************************************************************************
* @brief Non Connectable advertising completion function.
* @param[in] status Command complete event message status
****************************************************************************************
*/
void user_app_adv_nonconn_complete(uint8_t status);
/**
****************************************************************************************
* @brief Configure Button Interrupt (on P0_11)
*
****************************************************************************************
*/
void app_button_enable(void);
/**
****************************************************************************************
* @brief Handles the messages that are not handled by the SDK internal mechanisms.
* @param[in] msgid Id of the message received.
* @param[in] param Pointer to the parameters of the message.
* @param[in] dest_id ID of the receiving task instance.
* @param[in] src_id ID of the sending task instance.
****************************************************************************************
*/
void user_catch_rest_hndl(ke_msg_id_t const msgid,
void const *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id);
/// @} APP
#endif // _USER_EMPTY_PERIPHERAL_TEMPLATE_H_
/**
****************************************************************************************
*
* @file user_periph_setup.h
*
* @brief Peripherals setup header file.
*
* Copyright (C) 2015-2025 Renesas Electronics Corporation and/or its affiliates.
* All rights reserved. Confidential Information.
*
* This software ("Software") is supplied by Renesas Electronics Corporation and/or its
* affiliates ("Renesas"). Renesas grants you a personal, non-exclusive, non-transferable,
* revocable, non-sub-licensable right and license to use the Software, solely if used in
* or together with Renesas products. You may make copies of this Software, provided this
* copyright notice and disclaimer ("Notice") is included in all such copies. Renesas
* reserves the right to change or discontinue the Software at any time without notice.
*
* THE SOFTWARE IS PROVIDED "AS IS". RENESAS DISCLAIMS ALL WARRANTIES OF ANY KIND,
* WHETHER EXPRESS, IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. TO THE
* MAXIMUM EXTENT PERMITTED UNDER LAW, IN NO EVENT SHALL RENESAS BE LIABLE FOR ANY DIRECT,
* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE, EVEN IF RENESAS HAS BEEN ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGES. USE OF THIS SOFTWARE MAY BE SUBJECT TO TERMS AND CONDITIONS CONTAINED IN
* AN ADDITIONAL AGREEMENT BETWEEN YOU AND RENESAS. IN CASE OF CONFLICT BETWEEN THE TERMS
* OF THIS NOTICE AND ANY SUCH ADDITIONAL LICENSE AGREEMENT, THE TERMS OF THE AGREEMENT
* SHALL TAKE PRECEDENCE. BY CONTINUING TO USE THIS SOFTWARE, YOU AGREE TO THE TERMS OF
* THIS NOTICE.IF YOU DO NOT AGREE TO THESE TERMS, YOU ARE NOT PERMITTED TO USE THIS
* SOFTWARE.
*
****************************************************************************************
*/
#ifndef _USER_PERIPH_SETUP_H_
#define _USER_PERIPH_SETUP_H_
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "arch.h"
#include "gpio.h"
#include "uart.h"
/*
* DEFINES
****************************************************************************************
*/
/****************************************************************************************/
/* UART2 configuration to use with arch_console print messages */
/****************************************************************************************/
// Define UART2 Tx Pad
#if defined (__DA14531__)
#define UART2_TX_PORT GPIO_PORT_0
#define UART2_TX_PIN GPIO_PIN_6
#else
#define UART2_TX_PORT GPIO_PORT_0
#define UART2_TX_PIN GPIO_PIN_4
#endif
// Define UART2 Settings
#define UART2_BAUDRATE UART_BAUDRATE_115200
#define UART2_DATABITS UART_DATABITS_8
#define UART2_PARITY UART_PARITY_NONE
#define UART2_STOPBITS UART_STOPBITS_1
#define UART2_AFCE UART_AFCE_DIS
#define UART2_FIFO UART_FIFO_EN
#define UART2_TX_FIFO_LEVEL UART_TX_FIFO_LEVEL_0
#define UART2_RX_FIFO_LEVEL UART_RX_FIFO_LEVEL_0
/****************************************************************************************/
/* SPI configuration */
/****************************************************************************************/
// Define SPI Pads
#if defined (__DA14531__)
#define SPI_EN_PORT GPIO_PORT_0
#define SPI_EN_PIN GPIO_PIN_1
#define SPI_CLK_PORT GPIO_PORT_0
#define SPI_CLK_PIN GPIO_PIN_4
#define SPI_DO_PORT GPIO_PORT_0
#define SPI_DO_PIN GPIO_PIN_0
#define SPI_DI_PORT GPIO_PORT_0
#define SPI_DI_PIN GPIO_PIN_3
#elif !defined (__DA14586__)
#define SPI_EN_PORT GPIO_PORT_0
#define SPI_EN_PIN GPIO_PIN_3
#define SPI_CLK_PORT GPIO_PORT_0
#define SPI_CLK_PIN GPIO_PIN_0
#define SPI_DO_PORT GPIO_PORT_0
#define SPI_DO_PIN GPIO_PIN_6
#define SPI_DI_PORT GPIO_PORT_0
#define SPI_DI_PIN GPIO_PIN_5
#endif
// Define SPI Configuration
#define SPI_MS_MODE SPI_MS_MODE_MASTER
#define SPI_CP_MODE SPI_CP_MODE_0
#define SPI_WSZ SPI_MODE_8BIT
#define SPI_CS SPI_CS_0
#define SPI_SPEED_MODE SPI_SPEED_MODE_4MHz
#define SPI_EDGE_CAPTURE SPI_MASTER_EDGE_CAPTURE
/***************************************************************************************/
/* Production debug output configuration */
/***************************************************************************************/
#if PRODUCTION_DEBUG_OUTPUT
#if defined (__DA14531__)
#define PRODUCTION_DEBUG_PORT GPIO_PORT_0
#define PRODUCTION_DEBUG_PIN GPIO_PIN_11
#else
#define PRODUCTION_DEBUG_PORT GPIO_PORT_2
#define PRODUCTION_DEBUG_PIN GPIO_PIN_5
#endif
#endif
#define GPIO_BUTTON_PORT GPIO_PORT_0
#define GPIO_BUTTON_PIN GPIO_PIN_11
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
#if DEVELOPMENT_DEBUG
/**
****************************************************************************************
* @brief Reserves application's specific GPIOs
* @details Used only in Development mode (#if DEVELOPMENT_DEBUG)
* i.e. to reserve P0_1 as Generic Purpose I/O:
* RESERVE_GPIO(DESCRIPTIVE_NAME, GPIO_PORT_0, GPIO_PIN_1, PID_GPIO);
****************************************************************************************
*/
void GPIO_reservations(void);
#endif
/**
****************************************************************************************
* @brief Sets the functionality of application pads
* @details i.e. to set P0_1 as Generic purpose Output:
* GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_1, OUTPUT, PID_GPIO, false);
****************************************************************************************
*/
void set_pad_functions(void);
/**
****************************************************************************************
* @brief Initializes application's peripherals and pins
****************************************************************************************
*/
void periph_init(void);
#endif // _USER_PERIPH_SETUP_H_
/**
****************************************************************************************
*
* @file user_periph_setup.c
*
* @brief Peripherals setup and initialization.
*
* Copyright (C) 2015-2025 Renesas Electronics Corporation and/or its affiliates.
* All rights reserved. Confidential Information.
*
* This software ("Software") is supplied by Renesas Electronics Corporation and/or its
* affiliates ("Renesas"). Renesas grants you a personal, non-exclusive, non-transferable,
* revocable, non-sub-licensable right and license to use the Software, solely if used in
* or together with Renesas products. You may make copies of this Software, provided this
* copyright notice and disclaimer ("Notice") is included in all such copies. Renesas
* reserves the right to change or discontinue the Software at any time without notice.
*
* THE SOFTWARE IS PROVIDED "AS IS". RENESAS DISCLAIMS ALL WARRANTIES OF ANY KIND,
* WHETHER EXPRESS, IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. TO THE
* MAXIMUM EXTENT PERMITTED UNDER LAW, IN NO EVENT SHALL RENESAS BE LIABLE FOR ANY DIRECT,
* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE, EVEN IF RENESAS HAS BEEN ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGES. USE OF THIS SOFTWARE MAY BE SUBJECT TO TERMS AND CONDITIONS CONTAINED IN
* AN ADDITIONAL AGREEMENT BETWEEN YOU AND RENESAS. IN CASE OF CONFLICT BETWEEN THE TERMS
* OF THIS NOTICE AND ANY SUCH ADDITIONAL LICENSE AGREEMENT, THE TERMS OF THE AGREEMENT
* SHALL TAKE PRECEDENCE. BY CONTINUING TO USE THIS SOFTWARE, YOU AGREE TO THE TERMS OF
* THIS NOTICE.IF YOU DO NOT AGREE TO THESE TERMS, YOU ARE NOT PERMITTED TO USE THIS
* SOFTWARE.
*
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "user_periph_setup.h"
#include "datasheet.h"
#include "system_library.h"
#include "rwip_config.h"
#include "gpio.h"
#include "uart.h"
#include "syscntl.h"
#include "spi_flash.h"
#include "spi_531.h"
/*
* GLOBAL VARIABLE DEFINITIONS
****************************************************************************************
*/
#if DEVELOPMENT_DEBUG
void GPIO_reservations(void)
{
/*
i.e. to reserve P0_1 as Generic Purpose I/O:
RESERVE_GPIO(DESCRIPTIVE_NAME, GPIO_PORT_0, GPIO_PIN_1, PID_GPIO);
*/
// Push Button
RESERVE_GPIO(PUSH_BUTTON, GPIO_BUTTON_PORT, GPIO_BUTTON_PIN, PID_GPIO);
#if defined (CFG_PRINTF_UART2)
RESERVE_GPIO(UART2_TX, UART2_TX_PORT, UART2_TX_PIN, PID_UART2_TX);
#endif
#if defined (CFG_SPI_FLASH_ENABLE) && !defined (__DA14586__)
// SPI Flash
RESERVE_GPIO(SPI_EN, SPI_EN_PORT, SPI_EN_PIN, PID_SPI_EN);
RESERVE_GPIO(SPI_CLK, SPI_CLK_PORT, SPI_CLK_PIN, PID_SPI_CLK);
RESERVE_GPIO(SPI_DO, SPI_DO_PORT, SPI_DO_PIN, PID_SPI_DO);
RESERVE_GPIO(SPI_DI, SPI_DI_PORT, SPI_DI_PIN, PID_SPI_DI);
#endif
#if !defined (__DA14586__)
// RESERVE_GPIO(SPI_EN, SPI_EN_PORT, SPI_EN_PIN, PID_SPI_EN);
#endif
}
#endif
void set_pad_functions(void)
{
/*
i.e. to set P0_1 as Generic purpose Output:
GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_1, OUTPUT, PID_GPIO, false);
*/
// Push Button
GPIO_ConfigurePin(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN, INPUT_PULLUP, PID_GPIO, false);
#if defined (__DA14586__)
// Disallow spontaneous DA14586 SPI Flash wake-up
GPIO_ConfigurePin(GPIO_PORT_2, GPIO_PIN_3, OUTPUT, PID_GPIO, true);
#else
// Disallow spontaneous SPI Flash wake-up
// GPIO_ConfigurePin(SPI_EN_PORT, SPI_EN_PIN, OUTPUT, PID_SPI_EN, true);
#endif
#if defined (CFG_SPI_FLASH_ENABLE)
// SPI Flash
GPIO_ConfigurePin(SPI_EN_PORT, SPI_EN_PIN, OUTPUT, PID_SPI_EN, true);
GPIO_ConfigurePin(SPI_CLK_PORT, SPI_CLK_PIN, OUTPUT, PID_SPI_CLK, false);
GPIO_ConfigurePin(SPI_DO_PORT, SPI_DO_PIN, OUTPUT, PID_SPI_DO, false);
GPIO_ConfigurePin(SPI_DI_PORT, SPI_DI_PIN, INPUT, PID_SPI_DI, false);
#endif
#if defined (CFG_PRINTF_UART2)
// Configure UART2 TX Pad
GPIO_ConfigurePin(UART2_TX_PORT, UART2_TX_PIN, OUTPUT, PID_UART2_TX, false);
#endif
}
#if defined (CFG_SPI_FLASH_ENABLE)
// Configuration struct for SPI
static const spi_cfg_t spi_cfg = {
.spi_ms = SPI_MS_MODE,
.spi_cp = SPI_CP_MODE,
.spi_speed = SPI_SPEED_MODE,
.spi_wsz = SPI_WSZ,
.spi_cs = SPI_CS,
.cs_pad.port = SPI_EN_PORT,
.cs_pad.pin = SPI_EN_PIN,
#if defined (__DA14531__)
.spi_capture = SPI_EDGE_CAPTURE,
#endif
};
// Configuration struct for SPI FLASH
static const spi_flash_cfg_t spi_flash_cfg = {
.chip_size = P25Q11U_CHIP_SIZE,
.jedec_id = P25Q11U_JEDEC_ID,
};
#endif
#if defined (CFG_PRINTF_UART2)
// Configuration struct for UART2
static const uart_cfg_t uart_cfg = {
.baud_rate = UART2_BAUDRATE,
.data_bits = UART2_DATABITS,
.parity = UART2_PARITY,
.stop_bits = UART2_STOPBITS,
.auto_flow_control = UART2_AFCE,
.use_fifo = UART2_FIFO,
.tx_fifo_tr_lvl = UART2_TX_FIFO_LEVEL,
.rx_fifo_tr_lvl = UART2_RX_FIFO_LEVEL,
.intr_priority = 2,
};
#endif
void periph_init(void)
{
#if defined (__DA14531__)
// In Boost mode enable the DCDC converter to supply VBAT_HIGH for the used GPIOs
syscntl_dcdc_turn_on_in_boost(SYSCNTL_DCDC_LEVEL_3V0);
#else
// Power up peripherals' power domain
SetBits16(PMU_CTRL_REG, PERIPH_SLEEP, 0);
while (!(GetWord16(SYS_STAT_REG) & PER_IS_UP));
SetBits16(CLK_16M_REG, XTAL16_BIAS_SH_ENABLE, 1);
#endif
// ROM patch
patch_func();
// Initialize peripherals
#if defined (CFG_PRINTF_UART2)
// Initialize UART2
uart_initialize(UART2, &uart_cfg);
#endif
#if defined (CFG_SPI_FLASH_ENABLE)
// Configure SPI Flash environment
spi_flash_configure_env(&spi_flash_cfg);
// Initialize SPI
spi_initialize(&spi_cfg);
#endif
// Set pad functionality
set_pad_functions();
// Enable the pads
GPIO_set_pad_latch_en(true);
}
/**
****************************************************************************************
*
* @file user_config.h
*
* @brief User configuration file.
*
* Copyright (C) 2015-2025 Renesas Electronics Corporation and/or its affiliates.
* All rights reserved. Confidential Information.
*
* This software ("Software") is supplied by Renesas Electronics Corporation and/or its
* affiliates ("Renesas"). Renesas grants you a personal, non-exclusive, non-transferable,
* revocable, non-sub-licensable right and license to use the Software, solely if used in
* or together with Renesas products. You may make copies of this Software, provided this
* copyright notice and disclaimer ("Notice") is included in all such copies. Renesas
* reserves the right to change or discontinue the Software at any time without notice.
*
* THE SOFTWARE IS PROVIDED "AS IS". RENESAS DISCLAIMS ALL WARRANTIES OF ANY KIND,
* WHETHER EXPRESS, IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. TO THE
* MAXIMUM EXTENT PERMITTED UNDER LAW, IN NO EVENT SHALL RENESAS BE LIABLE FOR ANY DIRECT,
* INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE, EVEN IF RENESAS HAS BEEN ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGES. USE OF THIS SOFTWARE MAY BE SUBJECT TO TERMS AND CONDITIONS CONTAINED IN
* AN ADDITIONAL AGREEMENT BETWEEN YOU AND RENESAS. IN CASE OF CONFLICT BETWEEN THE TERMS
* OF THIS NOTICE AND ANY SUCH ADDITIONAL LICENSE AGREEMENT, THE TERMS OF THE AGREEMENT
* SHALL TAKE PRECEDENCE. BY CONTINUING TO USE THIS SOFTWARE, YOU AGREE TO THE TERMS OF
* THIS NOTICE.IF YOU DO NOT AGREE TO THESE TERMS, YOU ARE NOT PERMITTED TO USE THIS
* SOFTWARE.
*
****************************************************************************************
*/
#ifndef _USER_CONFIG_H_
#define _USER_CONFIG_H_
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "app_user_config.h"
#include "arch_api.h"
#include "app_default_handlers.h"
#include "app_adv_data.h"
#include "co_bt.h"
/*
* LOCAL VARIABLES
****************************************************************************************
*/
/*
****************************************************************************************
*
* Privacy / Addressing configuration
*
****************************************************************************************
*/
/*************************************************************************
* Privacy Capabilities and address configuration of local device:
* - APP_CFG_ADDR_PUB No Privacy, Public BDA
* - APP_CFG_ADDR_STATIC No Privacy, Random Static BDA
* - APP_CFG_HOST_PRIV_RPA Host Privacy, RPA, Public Identity
* - APP_CFG_HOST_PRIV_NRPA Host Privacy, NRPA (non-connectable ONLY)
* - APP_CFG_CNTL_PRIV_RPA_PUB Controller Privacy, RPA or PUB, Public Identity
* - APP_CFG_CNTL_PRIV_RPA_RAND Controller Privacy, RPA, Public Identity
*
* Select only one option for privacy / addressing configuration.
**************************************************************************
*/
#define USER_CFG_ADDRESS_MODE APP_CFG_ADDR_PUB
/*************************************************************************
* Controller Privacy Mode:
* - APP_CFG_CNTL_PRIV_MODE_NETWORK Controler Privacy Network mode (default)
* - APP_CFG_CNTL_PRIV_MODE_DEVICE Controler Privacy Device mode
*
* Select only one option for controller privacy mode configuration.
**************************************************************************
*/
#define USER_CFG_CNTL_PRIV_MODE APP_CFG_CNTL_PRIV_MODE_NETWORK
/******************************************
* Default sleep mode. Possible values are:
*
* - ARCH_SLEEP_OFF
* - ARCH_EXT_SLEEP_ON
* - ARCH_EXT_SLEEP_OTP_COPY_ON
*
******************************************
*/
static const sleep_state_t app_default_sleep_mode = ARCH_EXT_SLEEP_ON;
/*
****************************************************************************************
*
* Advertising configuration
*
****************************************************************************************
*/
static const struct advertise_configuration user_adv_conf = {
.addr_src = APP_CFG_ADDR_SRC(USER_CFG_ADDRESS_MODE),
/// Minimum interval for advertising
.intv_min = MS_TO_BLESLOTS(687.5), // 687.5ms
/// Maximum interval for advertising
.intv_max = MS_TO_BLESLOTS(687.5), // 687.5ms
/**
* Advertising channels map:
* - ADV_CHNL_37_EN: Advertising channel map for channel 37.
* - ADV_CHNL_38_EN: Advertising channel map for channel 38.
* - ADV_CHNL_39_EN: Advertising channel map for channel 39.
* - ADV_ALL_CHNLS_EN: Advertising channel map for channel 37, 38 and 39.
*/
.channel_map = ADV_ALL_CHNLS_EN,
/*************************
* Advertising information
*************************
*/
/// Host information advertising data (GAPM_ADV_NON_CONN and GAPM_ADV_UNDIRECT)
/// Advertising mode :
/// - GAP_NON_DISCOVERABLE: Non discoverable mode
/// - GAP_GEN_DISCOVERABLE: General discoverable mode
/// - GAP_LIM_DISCOVERABLE: Limited discoverable mode
/// - GAP_BROADCASTER_MODE: Broadcaster mode
.mode = GAP_GEN_DISCOVERABLE,
/// Host information advertising data (GAPM_ADV_NON_CONN and GAPM_ADV_UNDIRECT)
/// - ADV_ALLOW_SCAN_ANY_CON_ANY: Allow both scan and connection requests from anyone
/// - ADV_ALLOW_SCAN_ANY_CON_WLST: Allow both scan req from anyone and connection req from
/// White List devices only
.adv_filt_policy = ADV_ALLOW_SCAN_ANY_CON_ANY,
/// Address of peer device
/// NOTE: Meant for directed advertising (ADV_DIRECT_IND)
.peer_addr = {0x1, 0x2, 0x3, 0x4, 0x5, 0x6},
/// Address type of peer device (0=public/1=random)
/// NOTE: Meant for directed advertising (ADV_DIRECT_IND)
.peer_addr_type = 0,
};
/*
****************************************************************************************
*
* Advertising or scan response data for the following cases:
*
* - ADV_IND: Connectable undirected advertising event.
* - The maximum length of the user defined advertising data shall be 28 bytes.
* - The Flags data type are written by the related ROM function, hence the user shall
* not include them in the advertising data. The related ROM function adds 3 bytes in
* the start of the advertising data that are to be transmitted over the air.
* - The maximum length of the user defined response data shall be 31 bytes.
*
* - ADV_NONCONN_IND: Non-connectable undirected advertising event.
* - The maximum length of the user defined advertising data shall be 31 bytes.
* - The Flags data type may be omitted, hence the user can use all the 31 bytes for
* data.
* - The scan response data shall be empty.
*
* - ADV_SCAN_IND: Scannable undirected advertising event.
* - The maximum length of the user defined advertising data shall be 31 bytes.
* - The Flags data type may be omitted, hence the user can use all the 31 bytes for
* data.
* - The maximum length of the user defined response data shall be 31 bytes.
****************************************************************************************
*/
/// Advertising data
#define USER_ADVERTISE_DATA ""
/// Advertising data length - maximum 28 bytes, 3 bytes are reserved to set
#define USER_ADVERTISE_DATA_LEN (sizeof(USER_ADVERTISE_DATA)-1)
/// Scan response data
#define USER_ADVERTISE_SCAN_RESPONSE_DATA ""
/// Scan response data length- maximum 31 bytes
#define USER_ADVERTISE_SCAN_RESPONSE_DATA_LEN (sizeof(USER_ADVERTISE_SCAN_RESPONSE_DATA)-1)
/*
****************************************************************************************
*
* Device name.
*
* - If there is space left in the advertising or scan response data the device name is
* copied there. The device name can be anytime read by a connected peer, if the
* application supports it.
* - The Bluetooth device name can be up to 248 bytes.
*
****************************************************************************************
*/
/// Device name
#define USER_DEVICE_NAME "Wireless_emb"
/// Device name length
#define USER_DEVICE_NAME_LEN (sizeof(USER_DEVICE_NAME)-1)
/*
****************************************************************************************
*
* GAPM configuration
*
****************************************************************************************
*/
static const struct gapm_configuration user_gapm_conf = {
/// Device Role: Central, Peripheral, Observer, Broadcaster or All roles. (@see enum gap_role)
.role = GAP_ROLE_PERIPHERAL,
/// Maximal MTU. Shall be set to 23 if Legacy Pairing is used, 65 if Secure Connection is used,
/// more if required by the application
.max_mtu = 23,
/// Device Address Type
.addr_type = APP_CFG_ADDR_TYPE(USER_CFG_ADDRESS_MODE),
/// Duration before regenerate the random private address when privacy is enabled
.renew_dur = 15000, // 15000 * 10ms = 150s is the minimum value
/***********************
* Privacy configuration
***********************
*/
/// Private static address
// NOTE: The address shall comply with the following requirements:
// - the two most significant bits of the address shall be equal to 1,
// - all the remaining bits of the address shall NOT be equal to 1,
// - all the remaining bits of the address shall NOT be equal to 0.
// In case the {0x00, 0x00, 0x00, 0x00, 0x00, 0x00} null address is used, a
// random static address will be automatically generated.
.addr = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
/// Device IRK used for resolvable random BD address generation (LSB first)
.irk = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f},
/****************************
* ATT database configuration
****************************
*/
/// Attribute database configuration (@see enum gapm_att_cfg_flag)
/// 7 6 5 4 3 2 1 0
/// +-----+-----+----+-----+-----+----+----+----+
/// | DBG | RFU | SC | PCP | APP_PERM |NAME_PERM|
/// +-----+-----+----+-----+-----+----+----+----+
/// - Bit [0-1]: Device Name write permission requirements for peer device (@see device_name_write_perm)
/// - Bit [2-3]: Device Appearance write permission requirements for peer device (@see device_appearance_write_perm)
/// - Bit [4] : Slave Preferred Connection Parameters present
/// - Bit [5] : Service change feature present in GATT attribute database.
/// - Bit [6] : Reserved
/// - Bit [7] : Enable Debug Mode
.att_cfg = GAPM_MASK_ATT_SVC_CHG_EN,
/// GAP service start handle
.gap_start_hdl = 0,
/// GATT service start handle
.gatt_start_hdl = 0,
/**************************************************
* Data packet length extension configuration (4.2)
**************************************************
*/
/// Maximal MPS
.max_mps = 0,
/// Maximal Tx octets (connInitialMaxTxOctets value, as defined in 4.2 Specification)
.max_txoctets = 0,
/// Maximal Tx time (connInitialMaxTxTime value, as defined in 4.2 Specification)
.max_txtime = 0,
};
/*
****************************************************************************************
*
* Parameter update configuration
*
****************************************************************************************
*/
static const struct connection_param_configuration user_connection_param_conf = {
/// Connection interval minimum measured in ble double slots (1.25ms)
/// use the macro MS_TO_DOUBLESLOTS to convert from milliseconds (ms) to double slots
.intv_min = MS_TO_DOUBLESLOTS(10),
/// Connection interval maximum measured in ble double slots (1.25ms)
/// use the macro MS_TO_DOUBLESLOTS to convert from milliseconds (ms) to double slots
.intv_max = MS_TO_DOUBLESLOTS(20),
/// Latency measured in connection events
.latency = 0,
/// Supervision timeout measured in timer units (10 ms)
/// use the macro MS_TO_TIMERUNITS to convert from milliseconds (ms) to timer units
.time_out = MS_TO_TIMERUNITS(1250),
/// Minimum Connection Event Duration measured in ble double slots (1.25ms)
/// use the macro MS_TO_DOUBLESLOTS to convert from milliseconds (ms) to double slots
.ce_len_min = MS_TO_DOUBLESLOTS(0),
/// Maximum Connection Event Duration measured in ble double slots (1.25ms)
/// use the macro MS_TO_DOUBLESLOTS to convert from milliseconds (ms) to double slots
.ce_len_max = MS_TO_DOUBLESLOTS(0),
};
/*
****************************************************************************************
*
* Default handlers configuration (applies only for @app_default_handlers.c)
*
****************************************************************************************
*/
static const struct default_handlers_configuration user_default_hnd_conf = {
// Configure the advertise operation used by the default handlers
// Possible values:
// - DEF_ADV_FOREVER
// - DEF_ADV_WITH_TIMEOUT
.adv_scenario = DEF_ADV_FOREVER,
// Configure the advertise period in case of DEF_ADV_WITH_TIMEOUT.
// It is measured in timer units (3 min). Use MS_TO_TIMERUNITS macro to convert
// from milliseconds (ms) to timer units.
.advertise_period = MS_TO_TIMERUNITS(180000),
// Configure the security start operation of the default handlers
// if the security is enabled (CFG_APP_SECURITY)
// Possible values:
// - DEF_SEC_REQ_NEVER
// - DEF_SEC_REQ_ON_CONNECT
.security_request_scenario = DEF_SEC_REQ_NEVER
};
/*
****************************************************************************************
*
* Central configuration (not used by current example)
*
****************************************************************************************
*/
static const struct central_configuration user_central_conf = {
/// GAPM requested operation:
/// - GAPM_CONNECTION_DIRECT: Direct connection operation
/// - GAPM_CONNECTION_AUTO: Automatic connection operation
/// - GAPM_CONNECTION_SELECTIVE: Selective connection operation
/// - GAPM_CONNECTION_NAME_REQUEST: Name Request operation (requires to start a direct
/// connection)
.code = GAPM_CONNECTION_DIRECT,
/// Own BD address source of the device:
.addr_src = APP_CFG_ADDR_SRC(USER_CFG_ADDRESS_MODE),
/// Scan interval
.scan_interval = 0x180,
/// Scan window size
.scan_window = 0x160,
/// Minimum of connection interval
.con_intv_min = 100,
/// Maximum of connection interval
.con_intv_max = 100,
/// Connection latency
.con_latency = 0,
/// Link supervision timeout
.superv_to = 0x1F4,
/// Minimum CE length
.ce_len_min = 0,
/// Maximum CE length
.ce_len_max = 0x5,
/**************************************************************************************
* Peer device information (maximum number of peers = 8)
**************************************************************************************
*/
/// BD Address of device
.peer_addr_0 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
/// Address type of the device 0=public/1=random
.peer_addr_0_type = 0,
/// BD Address of device
.peer_addr_1 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
/// Address type of the device 0=public/1=random
.peer_addr_1_type = 0,
/// BD Address of device
.peer_addr_2 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
/// Address type of the device 0=public/1=random
.peer_addr_2_type = 0,
/// BD Address of device
.peer_addr_3 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
/// Address type of the device 0=public/1=random
.peer_addr_3_type = 0,
/// BD Address of device
.peer_addr_4 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
/// Address type of the device 0=public/1=random
.peer_addr_4_type = 0,
/// BD Address of device
.peer_addr_5 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
/// Address type of the device 0=public/1=random
.peer_addr_5_type = 0,
/// BD Address of device
.peer_addr_6 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
/// Address type of the device 0=public/1=random
.peer_addr_6_type = 0,
/// BD Address of device
.peer_addr_7 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
/// Address type of the device 0=public/1=random
.peer_addr_7_type = 0,
};
/*
****************************************************************************************
*
* Security related configuration
*
****************************************************************************************
*/
static const struct security_configuration user_security_conf = {
// IO Capabilities
#if defined (USER_CFG_FEAT_IO_CAP)
.iocap = USER_CFG_FEAT_IO_CAP,
#else
.iocap = GAP_IO_CAP_NO_INPUT_NO_OUTPUT,
#endif
// OOB Capabilities
#if defined (USER_CFG_FEAT_OOB)
.oob = USER_CFG_FEAT_OOB,
#else
.oob = GAP_OOB_AUTH_DATA_NOT_PRESENT,
#endif
// Authentication Requirements
#if defined (USER_CFG_FEAT_AUTH_REQ)
.auth = USER_CFG_FEAT_AUTH_REQ,
#else
.auth = GAP_AUTH_NONE,
#endif
// LTK size
#if defined (USER_CFG_FEAT_KEY_SIZE)
.key_size = USER_CFG_FEAT_KEY_SIZE,
#else
.key_size = KEY_LEN,
#endif
// Initiator key distribution
#if defined (USER_CFG_FEAT_INIT_KDIST)
.ikey_dist = USER_CFG_FEAT_INIT_KDIST,
#else
.ikey_dist = GAP_KDIST_NONE,
#endif
// Responder key distribution
#if defined (USER_CFG_FEAT_RESP_KDIST)
.rkey_dist = USER_CFG_FEAT_RESP_KDIST,
#else
.rkey_dist = GAP_KDIST_ENCKEY,
#endif
// Security requirements (minimum security level)
#if defined (USER_CFG_FEAT_SEC_REQ)
.sec_req = USER_CFG_FEAT_SEC_REQ,
#else
.sec_req = GAP_NO_SEC,
#endif
};
#endif // _USER_CONFIG_H_
![[DA1453xMOD] Advertising Undirected and Non-connectable](https://prod.hackster-cdn.online/assets/transparent-a0c1e3063bcabc548a5f3fa7328f3c1c97f747e6e764da4c14439567baa79ae1.gif)




Comments