KAGA-FEI-LOGO

KAGA FEI EVBnRF528101.2 Multi Sensor Board Beacon Firmware

KAGA-FEI-EVBnRF528101-2-Multi-Sensor-Board-Beacon-Firmware-PRODUCT

Introduction

  • This document provides an overview of the development resources for the KFEI Sensor Kit Beacon firmware application.
  • It outlines the general architecture and use of the firmware.

Requirements
To send sensor data using BLE using the Multi-Sensor Board Beacon application, you need the following.

  • Nordic SDK
  • Segger Embedded Studio and NRF board support package (For installation and setup procedures, register the product according to the sheet provided when purchasing the evaluation board/evaluation KIT, and download the “SES
  • NRF52 Quickstart Guide x.xx EN.pdf” for Segger Embedded Studio’s NRF quick start guide.).
  • IF pluggable interface board(EY1SENSOR-SKT)
  • Sensors for the desired operation
  • J-link Lite
  • Supported following module

KAGA-FEI-EVBnRF528101-2-Multi-Sensor-Board-Beacon-Firmware-FIG-1

Resource Description
The software of the Multi Sensor Board Beacon application is configured as shown in the block diagram below. For BLE communication, Soft Device provided by Nordic is used, and it is set to be written together with the application when writing using SES.

KAGA-FEI-EVBnRF528101-2-Multi-Sensor-Board-Beacon-Firmware-FIG-2

  • The following folders and files are included in the project for the Multi Sensor Board Beacon application. The function of each file is as follows.

KAGA-FEI-EVBnRF528101-2-Multi-Sensor-Board-Beacon-Firmware-FIG-3

Nordic SDK Settings

  • The project for the Multi Sensor Board Beacon application uses NordicSDK. Copy the folder where you downloaded and decompressed the following version of Nordic SDK into the “sdk” folder.
  • The following SDK version is used in the project of the Multi Sensor Board Beacon application, but please consider the latest version when using it for development.
  • [SDK info]
  • SDK Version:17.1.0 nRF5 SDK
  • Download URL:https://www.nordicsemi.com/Software-and-tools/Software/nRF5-SDK/Download#infotabs
  • Nordic source code copyright belongs to Nordic

KAGA-FEI-EVBnRF528101-2-Multi-Sensor-Board-Beacon-Firmware-FIG-4

Application Overview
During initialization, the application prepares any connected sensors as well as the Softdevice and BLE stack. Once complete, a background timer is started that triggers at a preset interval and BLE advertising is started. The event triggered by the timer updates the BLE advertising data with new sensor data.

KAGA-FEI-EVBnRF528101-2-Multi-Sensor-Board-Beacon-Firmware-FIG-5

Application Timer
The timer responsible for triggering update events can be configured to faster or slower intervals. Care should be taken to ensure that the timer interval is sufficiently long that all sensor reads can be completed before the next interval. The value for configuring this timer can be found in the configuration header src/config/app_config.h.

KAGA-FEI-EVBnRF528101-2-Multi-Sensor-Board-Beacon-Firmware-FIG-6

BLE Advertising

  • The device is configured to operate as a non-connectable beacon advertising at regular intervals with no timeout. The device is configured to transmit a primary advertising packet and a scan response packet using the format described in Figure 6.
  • The rate at which advertising data is transmitted from the BLE radio can be set in the configuration header. The field ADV_INTERVAL_MS controls the rate at which packets are transmitted.

Advertising Formats
The primary advertising packet contains a series of sensor data fields aggregated under a Manufacturer Specific Data fragment. The secondary scan response packet contains the device name under a Complete Device Name fragment. The field contents are shown in Figure 6.

KAGA-FEI-EVBnRF528101-2-Multi-Sensor-Board-Beacon-Firmware-FIG-7

  • The firmware contains a global structure that matches the format of the packet contents.

KAGA-FEI-EVBnRF528101-2-Multi-Sensor-Board-Beacon-Firmware-FIG-8

  • This struct is used for holding sensor data read during the timer update events, and is transmitted over BLE radio at advertising intervals.
  • For the final product, it is necessary to obtain a new company ID and set it.

Hardware Overview

Each supported board has its own configuration in the Segger Embedded Studio project. You can select the target board for compiling the application using the configuration drop-down box in SES. These configurations are set to target the relevant chip type and soft device required for the application.

KAGA-FEI-EVBnRF528101-2-Multi-Sensor-Board-Beacon-Firmware-FIG-9

Pin Assignment

  • Due to the arrangement of pins on each board variant, the IF board will connect to a different set of pins.
  • Pin assignments are predefined to maintain compatibility with the various layouts.
  • The default pin assignments for each of the supported boards can be found in Application/boards/boards.h.

KAGA-FEI-EVBnRF528101-2-Multi-Sensor-Board-Beacon-Firmware-FIG-10

  • The table below shows the various pin connections for each board.
  • AIN represents an analog-capable pin for use with ADC-based sensors.
  • NFC represents pins that can be used for Near Field Communication, however this is disabled by default.

KAGA-FEI-EVBnRF528101-2-Multi-Sensor-Board-Beacon-Firmware-FIG-11

Note: ADC inputs vary from board to board (i.e. AIN0/AIN1). While the boards.h header contains predefined assignments for simple configuration, care should be taken to ensure the correct ADC is selected to prevent hardware damage.
The attached sensor uses the pins described in the table below. Must be connected to the GPIO Pin of the board used.

KAGA-FEI-EVBnRF528101-2-Multi-Sensor-Board-Beacon-Firmware-FIG-12

NFC and Reset Pin Configuration
Some pins are configurable for use with NFC or GPIO. Some devices use the shared pins to connect with the IF board, so by default, this application configures the pins for GPIO use. The reset button located on the board is also configured to reset the device when pushed.
This functionality is controlled using the CONFIG_GPIO_AS_PINRESET and CONFIG_NFCT_PINS_AS_GPIOS definitions located in the Project Options → Common [configuration] → Preprocessor → Preprocessor Definitions.

KAGA-FEI-EVBnRF528101-2-Multi-Sensor-Board-Beacon-Firmware-FIG-13

The relevant source code is located in the Startup/system_nrf52.c. The desired configuration options are written to the UICR registers as part of the board startup process.
Note: once written, UICR registers cannot be cleared by software. To change the functionality, a chip erase must first be performed.

KAGA-FEI-EVBnRF528101-2-Multi-Sensor-Board-Beacon-Firmware-FIG-14

Sensor configuration

  • The interface board (IF) has two connectors for attaching various sensors. To use the sensors, a user must add the specific pin configuration in this file src/config/user_config.h
  • Each board has different pin configurations and sensor connectors, in which you can refer to from the board connector document to be able to understand on how to configure the sensors.
  • For example, the ADC pin of board EC2832AAx-EVB is in connector CN4 Pin 4 (CN4_4), while board EJ2832AAx-EVB is in connector CN3 Pin 4 (CN3_4).
  • Users can add/remove the sensor pin assignments to suit their specific application requirements. A set of example pins is already configured in the user_config.h header.

KAGA-FEI-EVBnRF528101-2-Multi-Sensor-Board-Beacon-Firmware-FIG-15

  • The Application/main.c/sensors_init function contains the initialization functions for the sensors that can be connected to the IF board.
  • As an example, all of the available functions are listed (commented by default). Only the sensors that are connected are included in the application.

KAGA-FEI-EVBnRF528101-2-Multi-Sensor-Board-Beacon-Firmware-FIG-16

  • Users can uncomment/comment the functions as required, or remove unused code.
  • Likewise, the Application/main.c/on_timer_evt function contains the sensor reading functions. Sensors connected to the board are read during this function and the advertising data is updated.

KAGA-FEI-EVBnRF528101-2-Multi-Sensor-Board-Beacon-Firmware-FIG-17

  • As with the initialization function, the user must comment or remove unused features.

KAGA-FEI-EVBnRF528101-2-Multi-Sensor-Board-Beacon-Firmware-FIG-18

Drivers

  • This section describes the existing peripheral and sensor drivers included in the Sensorkit application.

Peripheral Drivers
The Nordic SDK includes peripheral drivers suitable for most applications (e.g. TWI, GPIO). These drivers are the ones typically used by the sensor drivers. A small number of custom peripheral drivers have been included alongside the SDK. They are located in the Application/peripheral folder.

ADC
The ADC driver provides a single adc_read function to sample the voltage on a specified analog input. The function will block until the conversion is completed. The conversion is performed using 10 bit resolution and returns the average result of 16 samples. The operation will take approximately 640us.

KAGA-FEI-EVBnRF528101-2-Multi-Sensor-Board-Beacon-Firmware-FIG-19

Software TWI
The TWI peripheral on NRF devices has a minimum clock frequency of 100KHz. Devices like the SHT temperature sensor may not operate at this frequency. A GPIO-based software TWI driver is prepared that operates at ~40KHz. The TWI transaction is performed in a blocking method.KAGA-FEI-EVBnRF528101-2-Multi-Sensor-Board-Beacon-Firmware-FIG-20

KAGA-FEI-EVBnRF528101-2-Multi-Sensor-Board-Beacon-Firmware-FIG-21

Adding New Sensors

Beacon Packet Structure
When adding a new sensor that is not in the KFEI Sensor Kit beacon format, it is necessary to set the data of the sensor to be added to the packet. Figure 18: Set new sensor data in Sensor Data shown in beacon packet. In the source code, set new sensor data in the location shown in Figure 19 in the maic.c file.

KAGA-FEI-EVBnRF528101-2-Multi-Sensor-Board-Beacon-Firmware-FIG-22

  • To use sensors in your application, the driver must include at least the following functions: Also, since the function created in the following procedure is called from main.c, also create a header file that defines the added function (see
  • Figure 20: Example of driver header).
  • Also, to maintain portability between different board types, the pin assignment and ADC port are passed from the upper application to the driver in the current structure. Pins and ports are selected based on the connector and board selected for compilation.
  • Also, the sample code is included in the folder (sdk / examples / peripheral) of Nordic SDK downloaded in “1.3 Nordic SDK Settings”, so please use it as a reference for the driver to be created.

[structure of .c file]

  1. Initializer – prepare the peripheral, and preconfigure the sensor as required (e.g. set any control registers or enable sampling)
  2. Read – read a data sample from the sensor
  3. [optional] Converter – convert the data sample into a format suitable for the beacon. This can also be included as part of the read

KAGA-FEI-EVBnRF528101-2-Multi-Sensor-Board-Beacon-Firmware-FIG-23

Event Handler

  • As described in Section 0, A background timer fires at regular intervals.
  • This timer calls an event handler on_timer_evt which updates the BLE advertising data.
  • An associated event handler function for each connected sensor should be included in this timer event.
  • This function should read the latest sensor value and store it in the advertising data.
  • While the sensor data should be stored in the most appropriate positional field according to the KFEI Sensor Kit format described in Section 1.4.3, it is up to the developer’s discretion over which field is used in the case where the sensor does not match one of the preset placeholders.

KAGA-FEI-EVBnRF528101-2-Multi-Sensor-Board-Beacon-Firmware-FIG-24

Add to Project

  • When adding a sensor driver file to a project, it is easier to manage by placing the file in the path Application/sensors / new_driver_folder / driver_name.c / h according to the structure of the project file.

KAGA-FEI-EVBnRF528101-2-Multi-Sensor-Board-Beacon-Firmware-FIG-25

  • After that, include the new header file to src/sensors/sensors.h in order to get included in the project.

KAGA-FEI-EVBnRF528101-2-Multi-Sensor-Board-Beacon-Firmware-FIG-26

Adding to Application

To utilize the new sensor in the application:

  1. Include the driver’s pin configuration and any required DEFINE labels to the user_config.h
  2. Add the driver’s init function to the sensor_init function called during main().
  3. Add the event handler’s function call to the on_timer_evt() function

KAGA FEI Co., Ltd. 20-Jan.2024Ver1.1 20/20 Copyright 2024 KAGA FEI Co., Ltd.

Documents / Resources

KAGA FEI EVBnRF528101.2 Multi Sensor Board Beacon Firmware [pdf] User Guide
EVBnRF52810ES2810AA2, EVBnRF528101.2, EVBnRF528101.2 Multi Sensor Board Beacon Firmware, EVBnRF528101.2, Multi Sensor Board Beacon Firmware, Sensor Board Beacon Firmware, Board Beacon Firmware, Beacon Firmware, Firmware

References

Leave a comment

Your email address will not be published. Required fields are marked *