RSL10 Firmware Reference
RSL10 Firmware Reference
M-20818-007
October 2017
© SCILLC, 2017
Previous Edition © 2016
“All Rights Reserved”
RSL10 Firmware Reference
ON Semiconductor and are registered trademarks of Semiconductor Components Industries, LLC (SCILLC). ARM and Cortex are trademarks or registered
trademarks of ARM Ltd. Bluetooth is a registered trademark of Bluetooth SIG, Inc. SCILLC owns the rights to a number of patents, trademarks, copyrights, trade secrets, and
other intellectual property. A listing of SCILLC’s product/patent coverage may be accessed at www.onsemi.com/site/pdf/Patent-Marking.pdf. SCILLC reserves the right to
make changes without further notice to any products herein. SCILLC makes no warranty, representation or guarantee regarding the suitability of its products for any particular
purpose, nor does SCILLC assume any liability arising out of the application or use of any product or circuit, and specifically disclaims any and all liability, including without
limitation special, consequential or incidental damages. “Typical” parameters which may be provided in SCILLC data sheets and/or specifications can and do vary in different
applications and actual performance may vary over time. All operating parameters, including “Typicals” must be validated for each customer application by customer’s
technical experts. SCILLC does not convey any license under its patent rights nor the rights of others. SCILLC products are not designed, intended, or authorized for use as
components in systems intended for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which the failure of
the SCILLC product could create a situation where personal injury or death may occur. Should Buyer purchase or use SCILLC products for any such unintended or
unauthorized application, Buyer shall indemnify and hold SCILLC and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims, costs,
damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or
unauthorized use, even if such claim alleges that SCILLC was negligent regarding the design or manufacture of the part. SCILLC is an Equal Opportunity/Affirmative Action
Employer. This literature is subject to all applicable copyright laws and is not for resale in any manner.
Table of Contents
Page
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14
1.1 Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14
1.2 Intended Audience . . . . . . . . . . . . . . . . . . . . . . . . . . .14
1.3 Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14
1.4 Manual Organization . . . . . . . . . . . . . . . . . . . . . . . . . .14
1.5 Further Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . .15
2. Firmware Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16
2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16
2.2 Firmware Components . . . . . . . . . . . . . . . . . . . . . . . . . .16
2.2.1 Firmware Files . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.2.2 Compliance Exceptions . . . . . . . . . . . . . . . . . . . . . . . 21
2.3 Firmware Naming Conventions . . . . . . . . . . . . . . . . . . . . . . .21
2.4 Firmware Resource Usage . . . . . . . . . . . . . . . . . . . . . . . . .22
2.5 Versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22
2.5.1 Hardware Variants and Firmware Compatibility . . . . . . . . . . . . . . . . 22
2.5.2 Firmware Versions . . . . . . . . . . . . . . . . . . . . . . . . . 22
3. Hardware Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
3.1 Register and Register Bit-field Definition . . . . . . . . . . . . . . . . . . . .24
3.2 Memory Map Definition . . . . . . . . . . . . . . . . . . . . . . . . .25
3.3 Non-Volatile Record Memory Map . . . . . . . . . . . . . . . . . . . . . .25
3.3.1 Application Specific Record . . . . . . . . . . . . . . . . . . . . . . 26
3.3.2 Bond Information Record . . . . . . . . . . . . . . . . . . . . . . . 26
3.3.3 Device Configuration Record. . . . . . . . . . . . . . . . . . . . . . 27
3.3.4 Manufacturing Records . . . . . . . . . . . . . . . . . . . . . . . 27
3.4 Interrupt Vector Definition . . . . . . . . . . . . . . . . . . . . . . . . .29
4. Event Kernel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31
4.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31
4.1.1 Feature List . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.1.2 Top-Level Objects . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.1.3 Include Files . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.1.4 API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.1.4.1 Kernel_Init . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.1.4.2 Kernel_Schedule . . . . . . . . . . . . . . . . . . . . . . . 32
4.1.5 Kernel Environment . . . . . . . . . . . . . . . . . . . . . . . . 32
4.2 Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33
4.2.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.2.2 Message Format . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.2.3 Message Identifier . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.2.4 Parameter Management . . . . . . . . . . . . . . . . . . . . . . . 34
4.2.5 Message Queue Object . . . . . . . . . . . . . . . . . . . . . . . . 34
4.2.6 Message Queue Primitives . . . . . . . . . . . . . . . . . . . . . . 34
4.2.6.1 Message Allocation . . . . . . . . . . . . . . . . . . . . . . . 34
4.2.6.2 Message Send . . . . . . . . . . . . . . . . . . . . . . . . 35
www.onsemi.com
3
RSL10 Firmware Reference
www.onsemi.com
4
ON Semiconductor
www.onsemi.com
5
RSL10 Firmware Reference
www.onsemi.com
6
ON Semiconductor
www.onsemi.com
7
RSL10 Firmware Reference
www.onsemi.com
8
ON Semiconductor
www.onsemi.com
9
RSL10 Firmware Reference
www.onsemi.com
10
ON Semiconductor
www.onsemi.com
11
RSL10 Firmware Reference
www.onsemi.com
12
ON Semiconductor
www.onsemi.com
13
CHAPTER 1
1. Introduction
1.1 PURPOSE
This manual describes the firmware for RSL10. The firmware provides developers with a convenient software
layer on which to build their applications. It is also responsible for system-level tasks such as coordinating Bluetooth
communications, booting the system and implementing portions of the device security layer. It consists of include
files, libraries, and ROM code. This manual includes descriptions, function listings, and usage examples to help you
to understand the firmware and its parts.
This manual is for developers who are designing and implementing applications for RSL10. Both novice and
experienced developers can benefit from this information.
1.3 CONVENTIONS
The following conventions are used in this manual to signify particular types of information:
monospace font
Assembly code, macros, functions, defines and addresses.
italics
File and path names, or any portion of them.
<angle brackets>
Optional parameters and placeholders for specific information. To use an optional parameter
or replace a placeholder, specify the information within the brackets; do not include the
brackets themselves.
The RSL10 Firmware Reference contains the following chapters and appendices:
• Chapter 1: Introduction describes the purpose of the manual, the intended audience, and the typographical
conventions used; gives an overview of the manual; and lists other related publications.
• Chapter 2: Firmware Overview provides a top-level look at the firmware described in this manual,
including firmware components, and the interoperability of firmware versions with various hardware
revisions.
• Chapter 3: Hardware Definitions describes the hardware register and memory map definitions that are
provided by the firmware include files.
• Chapter 4: Event Kernel describes the messaging and event kernel included to support handling of
message and time related events for both the Bluetooth stack and user applications.
• Chapter 5: Program ROM describes the functions of the Program ROM, including the boot sequence and
function table functionality.
www.onsemi.com
14
ON Semiconductor
• Chapter 6: Bluetooth Stack and Profiles describes the Bluetooth stack library and Bluetooth protocol
libraries provided for RSL10. This includes references to other reference documents for the HCI, GATT, GAP,
and Profile Bluetooth® APIs that are supported by this firmware.
• Chapter 7: Custom Protocols describes a number of custom protocols that have been defined for RSL10 to
support use cases that cannot be supported using existing Bluetooth low energy technology.
• Chapter 8: CMSIS Implementation Library Reference describes the functions implemented in the
standards-compliant CMSIS Implementation library, including a vector table and C startup environment.
• Chapter 9: System Library Reference provides a description of the macros, functions and inline functions in
the system library.
• Chapter 10: Math Library Reference provides a description of the functions and macros in the math library.
• Chapter 11: Flash Library Reference provides a description of the functions and macros in the flash memory
write support library.
• Chapter 12: Calibration Library Reference describes the calibration functions that are provided to calibrate
the power supply and clock components of RSL10 for system settings other than those calculated during
manufacturing.
• Appendix A: Glossary provides definitions of many of the terms defined and used throughout this document.
For more information about the Event Kernel, Bluetooth Stack and Profile library interface specifications, refer to
the documents referenced in Chapter 4, “Event Kernel” on page 31 and Chapter 6, “Bluetooth Stack and Profiles” on
page 49.
For more information about the ARM® Cortex®-M3 processor, refer to the following documents:
www.onsemi.com
15
CHAPTER 2
2. Firmware Overview
2.1 INTRODUCTION
• A thin layer of support between the hardware and the developer. This firmware allows the developer to focus
on application development and reduces the number of details a developer is required to know about the
underlying RSL10 hardware.
• A support layer for common complex operations that will be used by user applications.
• Wireless protocol support functionality for Bluetooth low energy and custom protocol support.
The system firmware provides an interface for common operations that is easier to use and understand than
low-level C or assembly code. For instance, you can control and configure the underlying hardware while avoiding
the use of absolute addresses, which helps you to produce code quickly, with fewer errors. The support and wireless
protocol firmware provide more advanced functionality that can form the basis for any application that has been
developed to take advantage of the hardware provided by the RSL10 SoC.
When multiple programmers are involved in development, using the firmware leads to increased consistency,
which in turn leads to increased overall robustness and correctness of code.
In some cases, depending on the particulars of the application, the firmware implementation might not be
optimal; however, even in these situations, the firmware serves as an example and advanced starting point for
custom-developed functions and macros.
The firmware also encapsulates the details of the hardware such that many changes due to hardware revisions are
transparent at the application level. The encapsulation also provides a basic level of error checking of the hardware
usage. Compatibility information for firmware and hardware revisions is described in Section 2.5, “Versions” on
page 22.
Firmware supporting the RSL10 SoC can be divided into three groups:
System Firmware
This set of firmware provides a layer of support between the application developer and the
underlying hardware. It is a collection of files, macros, functions and libraries designed to
make application development simpler, quicker and more reliable. The firmware serves many
functions, including performing system-level tasks (e.g., switching applications),
implementing part of the security functionality, power mode configuration, and improving
application readability.
• Hardware definitions such as a register description, memory maps, interrupt vectors, and
related components. The firmware applies a layer of names and labels to the underlying
hardware for ease of use. This firmware is described in Chapter 3, “Hardware Definitions”
on page 24.
• A C-startup implementation for applications paired with a Cortex Microcontroller Software
Interface Standard (CMSIS) compliant application template provided by the CMSIS
www.onsemi.com
16
ON Semiconductor
Support Firmware
This set of firmware consists of more complex firmware components that are used to complete
complex tasks which can be used as an extension to an application, or can be used as the
common core functionality of an application.
• An event handler kernel that can be used to exchange and store messages, schedule events,
and register call-back functions that respond to other events that have occurred in the system.
More information about this kernel is provided in Chapter 4, “Event Kernel” on page 31.
• The Program ROM which contains code for ensuring that the system starts and restarts in
known states with known behaviors. The Program ROM loads information for the security
implementations. The Program ROM also integrates the Flash Write Support Library and
provides implementations to a number of ROM vector-based functions that are provided by
the System Library. For more information about the Program ROM, see Chapter 5, “Program
ROM” on page 42.
• A set of functions for erasing and writing the contents of flash memory provided through the
Flash Write Support Library. Reference material for this library is provided in Chapter 11,
“Flash Library Reference” on page 382.
• A set of macros and functions that can be used to calibrate system components to
non-standard target values to supplement the calibration settings calculated during device
manufacturing and provided in NVR4. This functionality is provided by the Supplemental
Calibration Library, and reference material for this library is provided in Chapter 12,
“Calibration Library Reference” on page 388.
This set of firmware also contains include files and libraries implementing ON Semiconductor
defined custom protocols. These protocols can be used as is, or can be used as the starting point
for user-defined custom protocols.
All firmware components listed above execute on the ARM Cortex-M3 processor, and all of these components are
CMSIS-compatible.
www.onsemi.com
17
RSL10 Firmware Reference
The firmware files consist of include files (denoted with .h extensions), and precompiled library binaries (denoted
with .a extensions). Some precompiled libraries are also provided in source code format.
The ARM Cortex-M3 processor firmware include files and libraries for each of the three groups of firmware are
listed in Table 1, Table 2, and Table 3/Table 4. Applications that use the libraries provided must:
Table 1. ARM Cortex-M3 Processor System Firmware Include Files and Libraries
www.onsemi.com
18
ON Semiconductor
Table 1. ARM Cortex-M3 Processor System Firmware Include Files and Libraries (Continued)
Table 2. ARM Cortex-M3 Processor Support Firmware Include Files and Libraries
www.onsemi.com
19
RSL10 Firmware Reference
The event kernel support firmware and the Bluetooth protocol stack are available in the following formats:
www.onsemi.com
20
ON Semiconductor
• Source code
• Debug
• Debug for RSL10 beta revision 1.02 (RSL10_CID = 8102)
• Release
The firmware provided for the ARM Cortex-M3 processor is generally compliant with the MISRA-C:2004 rules, as
required by the CMSIS standard. The RSL10 firmware exceptions in compliance are the same compliance exceptions
that are part of the CMSIS Core standard.
The RSL10 firmware and CMSIS-CORE violate the following MISRA-C:2004 rules:
• Required Rule 8.5, object/function definition in header file. Violated because function definitions in header
files are used to allow “inlining” of functions.
• Required Rule 18.4, declaration of union type or object of union type: {...}. Violated because unions are used
for effective representation of core registers.
• Advisory Rule 19.7, Function-like macro defined. Violated because function-like macros are used to allow for
more efficient code.
For clarity and ease of use, the firmware follows several naming conventions for library functions and macros.
These conventions are compatible with the CMSIS naming requirements.
The macros provided for the ARM Cortex-M3 processor control the registers and peripherals of the processor and
surrounding system. ARM Cortex-M3 processor macros that are implemented using a #define statement use all
capitals in the macro name. These macros are prefixed with an all-capital prefix indicating the library they are
supporting (e.g., SYS_). If the macro supports a specific target component, this prefix is followed by the name of the
component it supports. The rest of the macro name indicates the intended functionality of the macro.
Inline and standard firmware functions for the ARM Cortex-M3 processor use camel-case function names (e.g.,
CalcPhaseCnt). All functions use a prefix to indicate which library provides the function (e.g., Sys_). The remainder
of a function’s name indicates the block they affect and their intended functionality.
www.onsemi.com
21
RSL10 Firmware Reference
The firmware uses the ARM Cortex-M3 processor system stack. It expects that the ARM Cortex-M3 processor
stack pointer points to a valid stack that grows downward (i.e., decreasing memory addresses).
The firmware and sample code also recommend use cases for the non-volatile memory records, as described in
Section 3.3, “Non-Volatile Record Memory Map” on page 25. To take advantage of the firmware design, we
recommend that applications follow the use cases provided by these non-volatile memory records.
2.5 VERSIONS
To simplify identification of systems-on-chips that are compatible with a given set of firmware, the RSL10 SoC
provides chip version information using the AHBREGS_CHIP_ID_NUM register which can be used to calculate the chip
identifier (CID) used by the firmware. Devices that share a CID are compatible with firmware built for that CID.
The CID is a two-byte value with the most significant byte set to the value of the
AHBREGS_CHIP_ID_NUM_CHIP_VERSION bit-field, and the least significant byte set to the value of the
AHBREGS_CHIP_ID_NUM_CHIP_MAJOR_REVISION bit-field. Devices with the same CID but different minor revisions
(readable from the AHBREGS_CHIP_ID_NUM_CHIP_MINOR_REVISION bit-field) are compatible with the same
firmware packages. See the RSL10 Hardware Reference for more information.
When including rsl10.h, specify the CID by using the symbol RSL10_CID. Set this symbol to the target platform
either in the source files or through the project build settings. The following example instructs the system libraries to
provide the CID 101 variant of the constants:
By default, new projects include the correct settings to target CID 101 for the RSL10 chip. To modify the target
CID, update the build settings for your project. You can change the chip ID using build properties or preprocessor
settings.
Version symbols are provided for each major system firmware component and most support firmware components.
The version symbols can be used directly or indirectly to verify the version of the components used to build an
application. There are two types of version symbols available:
www.onsemi.com
22
ON Semiconductor
Constants A constant global variable value included in each library, which contains the version information
for that library
The available version information for each firmware component is listed in Table 6.
The version information contains a major version, minor version and revision. The major version is updated to
indicate significant changes to the component. Significant changes can involve a total redesign of the component,
including its interfaces and functionality. The minor version is updated to indicate minor changes or additions that are
usually backward-compatible. This would generally indicate a change to the interfaces or underlying functionality,
including different register modifications or leaving a different system state. The revision is updated to indicate a fairly
insignificant change to the component. For example, the revision is updated when the interfaces and functionality of the
component remain the same, and some other change has occurred. This can include non-functional changes to the
source code, or optimizations that do not affect the calling application.
The major version, minor version and revision are contained in a 16-bit value. The version is described as
Major.Minor.Revision. For example, Math Library v1.1.0 (0x1100) indicates major version 1, minor version 1, and
revision 0. Table 7 shows the bit fields in the version symbols.
www.onsemi.com
23
CHAPTER 3
3. Hardware Definitions
The ARM Cortex-M3 processor on the RSL10 chip is supported by a set of header files and system library
functions. These provide a description that defines the ARM Cortex-M3 processor subsystem of the RSL10 SoC. This
includes:
• Register and bit descriptions for control and configuration registers in the ARM Cortex-M3 core memory
map
• A memory map for the non-volatile records (NVR*) areas accessible to the ARM Cortex-M3 processor
• Interrupt vector table descriptions
• Macros that support basic ARM Cortex-M3 core functionality
The format and configuration of all of these firmware components conform to CMSIS compatibility
requirements. Therefore, most of the system library consists of inline functions that are defined within the library
header files.
The top-level include file for the system library, rsl10.h, combines all of the system hardware definition, system
support macro and system library firmware components provided for the ARM Cortex-M3 processor subsystem of
the RSL10 chip. If an application includes this file and defines SL1_CID to match the chip identifier of RSL10, then
all of the support macros and system library functions that are available to support ARM Cortex-M3 processor
development on the RSL10 chip are made accessible to that application.
Hardware definition files are integral to the system firmware. The hardware definitions apply a layer of data
structures and address mappings to the underlying hardware, so that every control register and bit field in the system
is easily accessible from C code.
Using the hardware definition files allows you to refer to system components by C structures and preprocessor
symbols instead of by addresses and bit fields. This greatly improves the readability, reliability and maintainability of
your application code. The use of hardware definitions in an application also means that some hardware changes,
such as changes to addresses or bit field values, are transparent to your application code.
Hardware register descriptions for components that are linked to the RSL10 ARM Cortex-M3 processor
peripheral bus are defined in the file rsl10_hw.h and rsl10_hw_cid*.h. Register descriptions for standard
ARM Cortex-M3 processor peripherals, such as NVIC and SysTick, are defined in the core CMSIS header file,
core_cm3.h.
Hardware descriptions in the register include files provide definitions for the components listed in Table 8.
Bit-Field Mask DIO_CFG_DRIVE_Mask Defines a bit mask for any bit-field of more than one bit within a
register
www.onsemi.com
24
ON Semiconductor
Memory map definitions from the perspective of the ARM Cortex-M3 processor are provided in rsl10_map.h.
Specifically, this file defines the locations of the following structures:
For more information on the ARM Cortex-M3 processor memory map see the RSL10 Hardware Reference.
A second set of memory map definitions are provided in rsl10_map_nvr.h for the non-volatile records (NVR)
sections of flash that are used to hold system information, including:
www.onsemi.com
25
RSL10 Firmware Reference
We recommend that information stored to non-volatile record 1 (NVR1) relate to a single user application or user
application set. The defined fields described in Table 9 must be defined for the user application or user application set.
Data in all other locations from NVR1 are not used by the firmware and should be application defined.
Information stored to non-volatile record 2 (NVR2) includes data to be used for bonded device information. Each
bonded device has a record of BondInfo_Type, accessible through BOND_INFO as defined in rsl10_map_nvr.h. This
record contains all of the stored values needed to create a whitelist or otherwise identify a bonded device. This is limited
by SIZEOF_WHITELIST = 28. A description of the records stored is provided in Table 10. See the Bluetooth Core
Specification v5.0 (https://www.bluetooth.com/specifications/adopted-specifications) for more information.
The stored bond information is valid if the INDEX is not all zeros or all ones.
www.onsemi.com
26
ON Semiconductor
Information stored to non-volatile record 3 (NVR3) includes data to be used for device configuration. This includes
the device’s Bluetooth (MAC) address, the device lock configuration and key, and an optional initialization function that
can be used to load configurations calibrated during manufacturing. A description of the records stored is provided in
Table 11. The use of data in all unused locations in NVR3 are defined by the user’s device and application.
CAUTION: The DEVICE_INFO_BLUETOOTH_ADDR value is set during testing to a unique EUI-48 MAC address for
each device. Take care when erasing and writing NVR3 to preserve and restore this address if the device expects to use
it as its Bluetooth device address.
Information stored to non-volatile record 4 (NVR4) consists of information from test and manufacturing. This data
is stored with hardware redundancy and cannot be written outside of manufacturing. Data stored to the manufacturing
records includes:
www.onsemi.com
27
RSL10 Firmware Reference
A description of the calibration records stored is provided in Table 12. All calibration records are split between a
16-bit calibration target value and a 16-bit trim setting that should be applied to the appropriate register to get the target
calibration for a power supply or clock. Up to four records can be stored for each element that is calibrated.
Table 13 lists the pre-loaded calibration records that are calculated for each part during manufacturing. The default
values from this table are loaded by the default implementation of the manufacturing initialization function stored to the
device configuration record (see Table 11 on page 27).
www.onsemi.com
28
ON Semiconductor
Information stored to other manufacturing records is not intended for direct use by user applications, and their
records are not described here.
Interrupt vector definitions are defined in rsl10_vectors.h for both internal and external interrupts. These definitions
have the form <interrupt_name>_IRQn. You can use these definitions with the NVIC-related functions included
with the core CMSIS (and defined in core_cm3.h). For a complete list of interrupts, see the RSL10 Hardware Reference.
The CMSIS Implementation library also provides default weakly defined interrupt handlers for each of these
vectors. These interrupt handlers have the form <interrupt_name>_IRQHandler(). If a user application defines a
www.onsemi.com
29
RSL10 Firmware Reference
function with this same name, the user application’s definition of the interrupt handler will replace the default (empty)
handlers.
www.onsemi.com
30
CHAPTER 4
4.Event Kernel
4.1 OVERVIEW
The RSL10 Kernel is a small and efficient event and message handling system that can be used as a Real Time
Operating System (RTOS) or as a process executed under an RTOS, offering the following features:
• Exchange of messages
• Message saving
• Timer functionality
• The kernel also provides an event functionality used to defer actions
The purpose of the event kernel is to provide messages (such as the ones in Section 4.2, “Messages” on page 33)
and timed tasks to keep RF traffic on schedule and aligned with the specification requirements.
To use the services offered by the kernel, include the header file rsl10_ke.h.
In addition to the header file, always include the object file libkelib.a.
File Description
ke.h Contains the kernel environment definition
ke_config.h Contains all the constants that can be changed in order to tailor the kernel
ke_event.h Contains the event handling primitives
ke_mem.h Contains the implementation of the heap management module
ke_misc.h This file contains the kernel initialization function and defines related to the environment definition.
ke_msg.h This file contains the scheduler primitives called to create or delete a task. It also contains the
scheduler itself
ke_task.h Contains the implementation of the kernel task management
ke_timer.h Contains the scheduler primitives called to create or delete a timer task. It also contains the timer
scheduler itself
The event kernel is supported by two primary functions as described in Table 15.
www.onsemi.com
31
RSL10 Firmware Reference
4.1.4.1 Kernel_Init
Initialize the event kernel for use within an application.
Type Function
Include File #include <rsl10_ke.h>
Template void Kernel_Init(uint32_t mode)
Description Initialize the event kernel for use within an application.
Inputs mode = Kernel initialization mode; set to 1 if using the kernel without the Bluetooth low
energy stack, 0 otherwise.
Outputs None
Assumptions None
Example /* Initialize the kernel and Bluetooth stack */
Kernel_Init(0);
BLE_InitNoTL(0);
BLE_Reset();
4.1.4.2 Kernel_Schedule
Execute any pending events that have been scheduled with the event kernel.
Type Function
Include File #include <rsl10_ke.h>
Template void Kernel_Schedule(void)
Description Execute any pending events that have been scheduled with the event kernel.
Inputs None
Outputs None
Assumptions None
Example /* Main application loop:
* - Run the kernel scheduler
* - Refresh the watchdog and wait for an interrupt before continuing */
while (1)
{
Kernel_Schedule();
The kernel environment structure contains the queues used for event, timer and message management:
www.onsemi.com
32
ON Semiconductor
4.2 MESSAGES
4.2.1 Overview
Message queues provide a mechanism to transmit one or more messages to a task. (Queue names and purposes are
defined in Section 4.1.5, “Kernel Environment” on page 32.)
A message is identified by a unique ID composed of the task type and an increasing number. The macro in Figure 1
builds the first message ID of a task.
A message has a list of parameters that is defined in a structure (see Section 4.2.2, “Message Format”).
www.onsemi.com
33
RSL10 Firmware Reference
• The message identifier must be defined by task type in one file only to avoid multiple identical definitions.
During message allocation, the size of the parameter is passed and memory is allocated in the kernel heap. In order
to store this data, the pointer on the parameters is returned. The scheduler frees this memory after the transition
completion. For example:
Parameters:
www.onsemi.com
34
ON Semiconductor
Return: Pointer to the parameter member of the ke_msg. If the parameter structure is empty, the pointer will point
to the end of the message and must not be used (except to retrieve the message pointer or to send the message).
Description: This primitive allocates memory for a message that has to be sent. The memory is allocated
dynamically on the heap, and the length of the variable parameter structure must be provided in order to allocate the
correct size.
Parameters:
Return: None
Description: Send a message previously allocated with any ke_msg_alloc()-like functions. The kernel will take
care of freeing the message memory.
Once the function has been called, it is not possible to access its data any more as the kernel might have copied the
message and freed the original memory.
Parameters:
www.onsemi.com
35
RSL10 Firmware Reference
Return: None
Description: Send a message that has a zero length parameter member. No allocation is required as this will be
performed internally.
void
ke_msg_forward(void const *param_ptr, ke_task_id_t const dest_id, ke_task_id_t const src_id)
Parameters:
Return: None
Description: Forward a message to another task by changing its destination and source task IDs.
Parameters:
Return: None
www.onsemi.com
36
ON Semiconductor
4.3 SCHEDULER
4.3.1 Overview
• The scheduler is called in the main loop of the user application using the Kernel_Schedule() function.
• In the user application’s main loop, the kernel checks if the event field is non-null, and executes the event
handlers for which the corresponding event bit is set.
4.3.2 Requirements
First Msg
Msg0 Kernel
Free
ed
um Message
ns Pool
Co
ge
sa
es
M
First Saved
Message Saved Msg
3: According to the status
returned by the message
MsgStatus? Msg0 NULL
handler, the kernel performs the Msg6 Msg9 Msg0
required action
Do
not
hin
g
The kernel does nothing, it leaves the
responsibility to the receiver task to
free the message later
www.onsemi.com
37
RSL10 Firmware Reference
4.4 TASKS
4.4.1 Definition
• Its task type, i.e. a constant value defined by the kernel, unique for each task
• Its task descriptor, which is a structure containing all the information about the task:
• The messages that it is able to receive in each of its states
• The messages that it is able to receive in the default state
• The number of instances of the task
• The number of states of the task
• The current state of each instance of the task
The kernel keeps a pointer to each task descriptor, which is used to handle the scheduling of the messages
transmitted from one task to another.
4.5.1 Overview
www.onsemi.com
38
ON Semiconductor
First Tmr
Prototype:
Parameters:
www.onsemi.com
39
RSL10 Firmware Reference
Return: None
Description: The function first cancels the timer if it exists; then it creates a new one. The timer can be one-shot, or
periodic (i.e. it will be automatically set again after each trigger).
Prototype:
Parameters:
Return: None
Description: This function searches for the timer element identified by its timer and task identifiers. If found, it is
stopped and freed, otherwise an error message is returned.
Prototype:
Parameters:
Return: TRUE if the timer identified by Timer Id is active for the Task id, FALSE otherwise
Description: This function pops the first timer from the timer queue and notifies the appropriate task by sending a
kernel message. If the timer is periodic, it is set again; if it is one-shot, the timer is freed. The function also checks the
next timers, and processes them if they have expired or are about to expire. Figure 4 shows the process flow for
handling expired timers.
www.onsemi.com
40
ON Semiconductor
First Tmr
1: Upon gross target timer expiry,
a kernel event is scheduled in
background. In the event Tmr0 Tmr1 Tmr2 Tmr3 NULL
scheduler, the kernel pops the
first timer from the queue
First Tmr
4: The kernel programs the HW
gross target time to match the
target time of the next timer Tmr1 Tmr2 Tmr3 NULL
• Builds the task identifier from the type and the index of that task:
#define KE_BUILD_ID(type, index) ( (ke_task_id_t)(((index) << 8)|(type)) )
www.onsemi.com
41
CHAPTER 5
5. Program ROM
5.1 OVERVIEW
The goal of the program ROM is to efficiently boot an application or restore an application from sleep to a known
state, to handle soft resets cleanly, and to ensure that all applications behave as expected once started, as the
underlying portions of the system they depend on are re-initialized.
The Program ROM for the RSL10 SoC is implemented in the ROM at the base of the ARM Cortex-M3 core
memory space, and contains the following features:
The program ROM contains a minimal vector table located at the base of memory. This vector table is described
in Table 24.
The Program ROM version (PROGRAM_ROM_VERSION) is stored in, and is accessible from, the address
immediately following this simple vector table (0x0000001C).
These three initialization sets each perform a specific task to ensure that the system is in a good state for
whatever application code or other tasks will follow. A description of each initialization can be found in the following
sub-sections.
www.onsemi.com
42
ON Semiconductor
The base system initialization function is used to ensure that key functional elements of the system are in their
power-on reset state after a soft reset or other non-wakeup boot. This is generally not required, but provides an option
for safely putting the system into a known good state at startup, to ensure proper behavior of everything that executes
after this function.
The base system initialization function reconfigures the following components to their default configurations:
• ARM Cortex-M3 processor fault handlers promoted to the hard fault handler
• ARM Cortex-M3 processor external interrupt handlers disabled and all pending interrupts cleared
• LPDSP32 DSP disabled and reset
• All DMA channels disabled
• All digital I/Os disabled (no I/O, weak pull-up resistor enabled)
• Watchdog set to the maximum time out and refreshed
• Clock distribution divisors reset
• Flash timing reset for compatibility with the default clock settings
• Power supply configurations reset
• All memories powered and enabled in normal mode
The base system initialization function is accessible for use in a user application through the program ROM
function table, as described in Section 5.5, “Function Table” on page 47.
The user-defined system initialization function is used to verify that the manufacturing initialization function
included in the device configuration record (described in Section 3.3.3, “Device Configuration Record” on page 27) is
valid, and to execute that function if it is. This function is intended to load calibration information for the device to
provide a calibrated environment for the application code that follows.
The manufacturing initialization function can be replaced by a user-defined manufacturing initialization function to
change the default behavior of this system initialization. The default manufacturing initialization function loads default
calibration values for a number of clocks and power supplies from the base of their array of calibrated trim values.
Elements that are configured using this function include:
1. The bandgap, which is trimmed using the default trim setting from MANU_INFO_BANDGAP.
2. The DC-DC convertor, which is trimmed using the default trim setting from MANU_INFO_DCDC.
3. The digital power supplies VDDC and VDDM (including retention trim settings), which are trimmed using the
default trim settings from MANU_INFO_VDDC, MANU_INFO_VDDC_STANDBY, MANU_INFO_VDDM, and
MANU_INFO_VDDM_STANDBY.
4. The RF power supplies VDDRF and VDDPA, which are trimmed using the default trim settings from
MANU_INFO_VDDRF and MANU_INFO_VDDPA.
5. The RC startup oscillator, which is trimmed to the default multiplied configuration using the default trim
setting from MANU_INFO_OSC_RC_MULT with the flash delay timing parameters configured to match the
declared frequency for proper system behavior.
6. The 32 kHz RC oscillator, which is trimmed using the default trim setting from MANU_INFO_OSC_32K.
NOTE: Generally, only replace the manufacturing initialization function if you want to boot with
calibration targets other than the default targets.
www.onsemi.com
43
RSL10 Firmware Reference
For more information about each of these blocks, see the power supply and clocking chapters of the RSL10
Hardware Reference. For default trim targets for each of these power supplies and clock frequencies, refer to the
datasheet for RSL10.
NOTE: No power supply or clocking elements are enabled by this initialization routine.
1. Specifies a length (MANU_INFO_LENGTH) that fits within the device configuration record. No error
(SYS_INIT_ERR_NONE) is reported if the 16-bit length value stored at MANU_INFO_LENGTH is set to 0x0000
or 0xFFFF to indicate that there is no manufacturing initialization function. An error code of
SYS_INIT_ERR_INVALID_BLOCK_LENGTH is returned if the specified length extends beyond the end of the
device configuration record sector.
2. Includes a CRC-CCITT calculated over the MANU_INFO_LENGTH field and a code section of the specified
length (in bytes). If the CRC calculation indicates that the CRC value is incorrect, the
SYS_INIT_ERR_BAD_CRC error code is returned to indicate this failure.
The manufacturing initialization function uses no parameters, and does not respond with any return code. If
execution completes and returns, the user-defined system initialization function reports that no error was encountered
using the SYS_INIT_ERR_NONE error code.
The user-defined system initialization function is accessible for use in a user application through the program ROM
function table, as described in Section 5.5, “Function Table” on page 47.
The RSL10 program ROM starts execution in the reset vector after initial startup, after a soft or core reset, and after
returning from a system wakeup event. This boot and wakeup initialization routine is designed to reboot and reconfigure
the system as efficiently as possible for a device that quickly needs to return to sleep or another low power state.
Prior to anything else, the ROM reset vector loads the value of ASC_WAKEUP_CTRL, and clears the
ACS_WAKEUP_CTRL_BOOT_SELECT bit from this register. The loaded value is used to determine what path is used
through the boot and wakeup initialization routine - and this value is cleared after being loaded to ensure that the system
defaults back to a regular boot from flash memory in case of a failure during boot.
IMPORTANT: Prior to switching to the 48 MHz clock, a user application that is using BOOT_XTAL_ENABLE
needs to verify that the XTAL oscillator has completed its initialization by confirming that the
RF_REG39_ANALOG_INFO_CLK_DIG_READY bit from the RF_REG39 register is set
(ANALOG_INFO_CLK_DIG_READY).
2. The flash is configured for correct behavior upon startup, given the current clock source configuration. The
flash itself is not enabled.
www.onsemi.com
44
ON Semiconductor
To restore a running application the ROM uses the following wakeup sequence:
IMPORTANT: The reset vector does not modify or access the stack prior to determining if the system is exiting
a low-power mode. This will ensure that an application returning from these modes can continue from a known
or fixed location without needing to reset the contents of the stack.
4. If the value loaded from ASC_WAKEUP_CTRL indicates that the device is rebooting (the
ACS_WAKEUP_CTRL_BOOT_FLASH_APP_REBOOT bit is set to BOOT_FLASH_APP_REBOOT_ENABLE), the
following initialization sequence is followed:
a. Clear the ACS_WAKEUP_CTRL_BOOT_SELECT, ACS_WAKEUP_CTRL_BOOT_XTAL_EN, and
ACS_WAKEUP_CTRL_BOOT_FLASH_APP_REBOOT bits from the ACS_WAKEUP_CTRL register, to ensure
that if the boot fails, the system does not attempt to reboot again.
b. Enable all of the memories in the RSL10 system, except the DSP_PRAM instances.
c. Read the memory power configuration from SYS_INFO_START_MEM_CFG in the application specific
record (described in Section 3.3.1, “Application Specific Record” on page 26).
d. If SYS_INFO_START_MEM_CFG would enable the PRAM, flash, and DRAM0 memory instances (bits 0, 1,
and 6 are set in the value read), enable the memories specified and disable all memory retention settings.
Otherwise, enable all of the memories in the RSL10 system, disabling all memory retention settings.
5. If the program ROM has found that the device is not rebooting, the following initialization sequence is
followed:
a. Enable all of the memories in the RSL10 system, disabling all memory retention settings.
b. Switch to the RC clock as the source for SYSCLK.
c. Load the default VCC = 1.25 V trim setting.
d. Load the calibrated bandgap and VDDM settings from the manufacturing records in NVR4. If either read
reports an ECC error, repeat the read using increasing power supply values until no error is reported, and
use the last loaded values as the bandgap and VDDM configuration settings.
e. Once valid bandgap and VDDM settings are found, write them to the ACS_BG_CTRL and
ACS_VDDM_CTRL_VDDM_TRIM registers. If no valid trim settings can be loaded from the manufacturing
www.onsemi.com
45
RSL10 Firmware Reference
records, the ROM defaults to a fail-safe, high trim setting for these registers that is used to guarantee that
memory access is reliable after this step.
f. Execute the base system initialization function described in Section 5.3.1, “Base System Initialization”.
6. The debug port lock information is loaded using the following sequence:
a. The value of LOCK_INFO_SETTING setting is loaded from the device configuration record (described in
Section 3.3.3, “Device Configuration Record” on page 27)
b. If an error has been observed, the VDDM setting is set to the nominal value for 1.25 V and this value is
reloaded.
c. The loaded value from LOCK_INFO_SETTING is written to SYSCTRL_DBG_LOCK. If this register is set to
DBG_ACCESS_LOCK, debug port accesses remain restricted. If this register is set to any other, full access to
the debug port will be available following this step.
d. The 128-bit debug port unlock key is read from LOCK_INFO_KEY and copied to the four DBG_LOCK_KEY
registers. This key will be valid once the last value is written, and can be written over the debug port while
access to the debug port remains restricted to clear SYSCTRL_DBG_LOCK and unrestrict the debug port.
7. If the program ROM has found that the device is rebooting, the vector table is set to point to the value indicated
by SYS_INFO_START_ADDR from the application specific record (see Section 3.3.1, “Application Specific
Record” on page 26) and execution continues from this rebooted application’s reset vector.
8. If the program ROM has found that the device is not rebooting:
a. The user-defined system initialization function described in Section 5.3.2, “User-Defined System
Initialization” is executed.
b. The application pointed to by SYS_INFO_START_ADDR is verified from the application specific record
(see Section 3.3.1, “Application Specific Record”), using the application validation routine defined in
Section 5.4, “Application Validation and Boot”. If this is a valid application, execution continues from this
application’s reset vector.
c. The application located at the base of flash memory is verified using the application validation routine
defined in Section 5.4, “Application Validation and Boot”. If this is a valid application, execution
continues from this application’s reset vector.
d. If no valid application has been found, the error code from the application verification is written to
VAR_BOOTROM_ERROR (located at the base of DRAM0) and the ROM hard fault handler is executed. The
hard fault handler continues to execute until a watchdog reset triggers a power-on reset of the RSL10
system.
The RSL10 program ROM contains a set of functions that are used to validate and boot applications.
The program ROM only boots an application if the system is not returning from sleep mode. (If the device fails on
return from sleep mode, the system triggers a reset which forces a boot.) An application is booted only after all system
initialization, as described in Section 5.3, “Initialization Support”, has completed. The program ROM first attempts to
boot the application pointed to by SYS_INFO_START_ADDR (see Section 3.3.1, “Application Specific Record” on
page 26). If this application fails to boot, the ROM then attempts to boot an application starting from the base of flash as
a fail-safe measure. If the application at the base of flash also fails, the ROM records an error code and waits in the
hard-fault handler for a watchdog reset to reset the system.
The ROM considers an application valid if it starts with its vector table, and no errors that would prevent boot are
detected. Possible errors, and the error codes reported for these errors, are described in Table 25. If neither the
application pointed to by SYS_INFO_START_ADDR nor an application located at the base of flash successfully boots,
the boot ROM writes this error code to VAR_BOOTROM_ERROR (located at the base of DRAM0).
www.onsemi.com
46
ON Semiconductor
1. Sets the VTOR bit-field in the ARM Cortex-M3 processor’s SCB register to point to the application’s vector
table
2. Loads the initial stack pointer value from the application’s vector table to the ARM Cortex-M3 processor’s SP
register
3. Pushes the application’s status code to the top of the newly defined stack (valid error codes for a booted
application are “None” and “Bad CRC” - as described in Table 25)
4. Branches to the beginning of the reset handler, as indicated by the reset vector in the application’s vector table
The Program ROM contains the implementation of a set of firmware functions that are exposed through a function
table. A list of functions provided by the ROM can be found in Table 26.
www.onsemi.com
47
RSL10 Firmware Reference
All program ROM functions are exposed through the system library’s ROM vector support (rsl10_romvect.h). For
more information on these functions and the rest of the system library, see Chapter 9, “System Library Reference” on
page 197.
All flash library functions are exposed through the flash library’s ROM implementation (rsl10_flash_rom.h). For
more information on the flash library, see Chapter 11, “Flash Library Reference” on page 382.
IMPORTANT: We recommend that all functions provided by the flash library be executed from RAM or ROM,
as executing them from flash can result in hidden, flash-access-related failures. As such, the flash library is
provided as part of the ROM to allow erasing and writing to the flash without having to instantiate the flash
library functions in RAM.
www.onsemi.com
48
CHAPTER 6
6. Bluetooth Stack and Profiles
6.1 INTRODUCTION
This chapter explains how the Bluetooth stack, including the HCI, GATT and GAP, is implemented for RSL10.
This chapter also provides a description of the Bluetooth profile libraries that are provided with the RSL10 system to
support standard use cases.
IMPORTANT: The default Bluetooth stack is built to support four Bluetooth links, as a balance between system
flexibility and power/memory optimization. If your user application requires more links than the default
Bluetooth stack library build supports, contact your ON Semiconductor Customer Service Representative for
assistance.
In the include folder of the RSL10 installation directory, rsl10_bb.h and rsl10_ble.h list all the Bluetooth low
energy technology and Baseband support header files — refer to Table 27. The object files are described in Table 28
on page 50 and Table 29 on page 52.
Table 27. RSL10 Bluetooth Low Energy and Baseband Support Files
Bluetooth Baseband
rsl10_ble.h rsl10_bb.h
#include #include <bb\rwble_config.h> #include <bb\co_math.h>
<ble\rwble_hl_config.h>
#include #include <bb\rwble.h> #include <bb\co_utils.h>
<ble\rwble_hl_error.h>
#include <ble\rwble_hl.h> #include <bb\rwip.h> #include <bb\dbg.h>
#include <ble\rwprf_config.h> #include <bb\rwip_config.h> #include <bb\dbg_task.h>
#include <ble\prf.h> #include <bb\_reg_ble_em_cs.h> #include <bb\dbg_swdiag.h>
#include <ble\ahi.h> #include <bb\_reg_ble_em_ral.h> #include <bb\dbg_mwsgen.h>
#include <ble\ahi_task.h> #include <bb\_reg_ble_em_rx_buffer.h> #include <bb\ea.h>
#include <ble\att.h> #include <bb\_reg_ble_em_rx_desc.h> #include <bb\em_buf.h>
#include <ble\attc.h> #include #include <bb\em_map.h>
<bb\_reg_ble_em_tx_buffer_cntl.h>
#include <ble\attm.h> #include #include <bb\em_map_ble.h>
<bb\_reg_ble_em_tx_buffer_data.h>
#include <ble\attm_db.h> #include #include <bb\ll.h>
<bb\_reg_ble_em_tx_buffer_data.h>
#include <ble\atts.h> #include <bb\_reg_ble_em_tx_desc.h> #include <bb\llc.h>
#include <ble\ecc_p256.h> #include <bb\_reg_ble_em_wpb.h> #include <bb\llc_ch_asses.h>
#include <ble\gap.h> #include <bb\_reg_ble_em_wpv.h> #include <bb\llc_llcp.h>
#include <ble\gapc.h> #include <bb\reg_blecore.h> #include <bb\llc_task.h>
#include <ble\gapm_int.h> #include <bb\reg_access.h> #include <bb\llc_util.h>
#include <ble\gapc_task.h> #include <bb\reg_assert_mgr.h> #include <bb\lld.h>
#include <ble\gapm.h> #include <bb\reg_common_em_et.h> #include <bb\lld_pdu.h>
#include <ble\gapm_task.h> #include <bb\reg_ble_em_cs.h> #include <bb\lld_wlcoex.h>
www.onsemi.com
49
RSL10 Firmware Reference
Table 27. RSL10 Bluetooth Low Energy and Baseband Support Files (Continued)
Bluetooth Baseband
rsl10_ble.h rsl10_bb.h
#include <ble\gapm_util.h> #include <bb\reg_ble_em_ral.h> #include <bb\lld_evt.h>
#include <ble\gatt.h #include <bb\reg_ble_em_rx_buffer.h> #include <bb\lld_sleep.h>
#include <ble\gattc.h> #include <bb\reg_ble_em_rx_desc.h> #include <bb\lld_util.h>
#include <ble\gattc_task.h> #include #include <bb\llm.h>
<bb\reg_ble_em_tx_buffer_cntl.h>
#include <ble\gattm.h> #include #include <bb\llm_task.h>
<bb\reg_ble_em_tx_buffer_data.h>
#include <ble\gattm_task.h> #include #include <bb\llm_util.h>
<bb\reg_ble_em_tx_buffer_data.h>
#include <ble\h4tl.h> #include <bb\reg_ble_em_tx_desc.h> #include <bb\rf.h>
#include <ble\hci.h> #include <bb\reg_ble_em_wpb.h> #include <bb\rwip_task.h>
#include <ble\l2cc.h> #include <bb\reg_ble_em_wpv.h>
#include <ble\l2cc_pdu.h> #include <bb\compiler.h>
#include <ble\l2cc_task.h> #include <bb\arch.h>
#include <ble\l2cm.h> #include <bb\co_bt.h>
#include #include <bb\co_bt_defines.h>
<ble\smp_common.h>
#include <ble\smpc.h> #include <bb\co_endian.h>
#include <ble\smpc_api.h> #include <bb\co_error.h>
#include <ble\smpc_crypto.h> #include <bb\co_hci.h>
#include <ble\smpc_util.h> #include <bb\co_list.h>
#include <ble\smpm_api.h> #include <bb\co_llcp.h>
#include <ble\prf_types.h> #include <bb\co_lmp.h>
#include <ble\prf_utils.h> #include <bb\co_version.h>
Profile Library
Profile Name Profile Profile Description
Name
Alert Notification ANP libanpc This profile enables a client device to receive different types of
Profile alerts and event information, as well as information on the count of
new alerts and unread items, which exist in the server device.
Alert Notification ANS libanps Alert Notification service exposes: The different types of alerts with
Service the short text messages, The count of new alert messages, The
count of unread alerts.
Battery Service BAS libbasc The Battery Service exposes the state of a battery within a device.
libbass
Blood Pressure BLP libblpc This profile enables a device to connect and interact with a Blood
Profile Pressure Sensor device for use in consumer and professional
health care applications.
Blood Pressure BLS libblps This service exposes blood pressure and other data from a blood
Service pressure monitor for use in consumer and professional healthcare
applications.
www.onsemi.com
50
ON Semiconductor
Table 28. Bluetooth GATT-Based Profile and Service Object Files (Continued)
Profile Library
Profile Name Profile Profile Description
Name
Cycling Power CPP libcppc This profile enables a Collector device to connect and interact with
Profile a Cycling Power Sensor for use in sports and fitness applications.
Cycling Power CPS libcpps This service exposes power- and force-related data and optionally
Service speed- and cadence-related data from a Cycling Power sensor
intended for sports and fitness applications.
Cycling Speed and CSCP libcscpc This profile enables a Collector device to connect and interact with
Cadence Profile a Cycling Speed and Cadence Sensor for use in sports and fitness
applications.
Cycling Speed and CSCS libcscps This service exposes speed-related and cadence-related data
Cadence Service from a Cycling Speed and Cadence sensor intended for fitness
applications.
Current Time CTS libtipc This Bluetooth® service defines how the current time can be
Service exposed using the Generic Attribute Profile (GATT).
Device Information DIS libdisc This service exposes manufacturer and/or vendor information
Service libdiss about a device.
Find me Profile FMP libfindl The Find Me profile defines the behavior when a button is pressed
libfindt on one device to cause an alerting signal on a peer device.
Glucose Profile GLP libglpc This profile enables a device to connect and interact with a
glucose sensor for use in consumer healthcare applications.
Glucose Service GLS libglps This service exposes glucose and other data from a personal
glucose sensor for use in consumer healthcare applications.
HID over GATT HOGP libhogpd This profile defines how a device with Bluetooth low energy
Profile libhogpbh wireless communications can support HID services over the
Bluetooth low energy protocol stack using the Generic Attribute
libhogprh
Profile.
Heart Rate Profile HRP libhrpc This profile enables a Collector device to connect and interact with
a Heart Rate Sensor for use in fitness applications.
Heart Rate Service HRS libhrps This service exposes heart rate and other data from a Heart Rate
Sensor intended for fitness applications.
Health Thermometer HTP libhtpc This profile enables a Collector device to connect and interact with
Profile a Thermometer sensor for use in healthcare applications.
Health Thermometer HTS libhtpt This service exposes temperature and other data from a
Service Thermometer intended for healthcare and fitness applications.
Immediate Alert IAS libproxm This service exposes a control point to allow a peer device to
Service libproxr cause the device to immediately alert.
Link Loss Service LLS libproxm This service defines behavior when a link is lost between two
libproxr devices.
Location and LNP liblanc This profile enables a Collector device to connect and interact with
Navigation Profile a Location and Navigation Sensor for use in outdoor activity
applications.
Location and LNS liblans This service exposes location and navigation-related data from a
Navigation Service Location and Navigation sensor intended for outdoor activity
applications.
Next DST Change NDCS libtipc This service defines how the information about an upcoming DST
Service libtips change can be exposed using the Generic Attribute Profile (GATT)
www.onsemi.com
51
RSL10 Firmware Reference
Table 28. Bluetooth GATT-Based Profile and Service Object Files (Continued)
Profile Library
Profile Name Profile Profile Description
Name
Phone Alert Status PASP libpaspc This profile enables a PUID device to alert its user about the alert
Profile status of a phone connected to the PUID device.
Phone Alert Status PASS libpasps This service exposes the phone alert status when in a connection.
Service
Proximity Profile PXP libproxm The Proximity profile enables proximity monitoring between two
libproxr devices.
Running Speed and RSCP librscpc This profile enables a Collector device to connect and interact with
Cadence Profile a Running Speed and Cadence Sensor for use in sports and
fitness applications.
Running Speed and RSCS librscps This service exposes speed, cadence and other data from a
Cadence Service Running Speed and Cadence sensor intended for fitness
applications.
Reference Time RTUS libtipc This service defines how a client can request an update from a
Update Service libtips reference time source from a time server using the Generic
Attribute Profile (GATT).
Scan Parameters SCPP libscppc This profile defines how a Scan Client device with Bluetooth low
Profile energy wireless communications can write its scanning behavior to
a Scan Server, and how a Scan Server can request updates of a
Scan Client scanning behavior.
Scan Parameters SCPS libscpps This service enables a GATT Client to store the LE scan
Service parameters it is using on a GATT Server device so that the GATT
Server can utilize the information to adjust behavior to optimize
power consumption and/or reconnection latency.
Time Profile TIP libtipc The Time profile enables the device to get the date, time, time
libtips zone, and DST information and control the functions related the
time.
Profile Library
Profile Name Profile Profile Description
Name
Wireless Power WPTC libwptc This profile implements the Alliance for Wireless Power (A4WP)
Transfer Profile WPTS libwpts wireless power transfer system for transferring power from a
single Power Transmitter Unit (PTU) to one or more Power
Receiver Units (PRUs).
All of the individual profile libraries use the Bluetooth low energy stack through the profile’s specified interfaces.
These interfaces are documented in the interface specifications. Because the Bluetooth low energy stack itself requires a
reciprocal link in order to find all of the profile components, the stack library has been built with an object factory that
instantiates calls to each of the profiles. If a profile is used by an application, the Bluetooth stack should use the
specified profile library. If a profile is not used by an application, an empty templated version of the necessary functions
that the Bluetooth stack’s factory is looking for is provided by the weak profile (weakprf.a) library.
CAUTION: The weak profile library must be the last library linked into an application, to prevent the weakly-defined
function definitions provided by this library from overriding the complete function definitions provided by the
individual profile libraries.
www.onsemi.com
52
ON Semiconductor
The RSL10 device supports a Bluetooth stack through a combination of hardware and firmware resources. The
hardware components of the Bluetooth stack are described in the RSL10 Hardware Reference. The firmware
components of the Bluetooth stack are accessible through a Bluetooth library and associated header files.
Table 30 describes the Bluetooth stacks provided with RSL10 and their associated object files.
The profile-based database and environment will not exceed 1.2 KB.
NOTE: If you want a different Bluetooth stack configuration from the ones listed in Table 30, contact
your ON Semiconductor Customer Support representative.
The Bluetooth stack library includes a set of support functions that augment the stack firmware, as described in
Table 31. All other stack APIs are described in their reference documentation, with support for specific Bluetooth layers
described in the following documents:
GAP RW-BLE-GAP-IS_2mbps.pdf
GATT RW-BLE-GATT-IS.pdf
L2CAP RW-BLE-L2C-IS.pdf
Profiles RW-BLE-PRF-*-IS.pdf
www.onsemi.com
53
RSL10 Firmware Reference
6.1.3.1 BLE_Init
Initialize the Bluetooth stack for use within an application.
Type Function
Include File #include <rsl10_bb.h>
#include <rsl10_ble.h>
Template void BLE_Init(uint32_t error)
Description Initialize the Bluetooth stack for use within an application. If the stack is being re-initialized due to an error,
raise a message to the local Bluetooth host to help ensure that error recovery is handled well.
NOTE: This initialization function also initializes the custom application host interface (AHI)
and the related required transport layer hooks. If not using this interface, use
BLE_InitNoTL() (see Section 6.1.3.2, “BLE_InitNoTL”).
Inputs error = Indicate why the Bluetooth stack is being re-initialized; should be set to 0
(RESET_NO_ERROR) if no error had occurred, and otherwise should use one
of the defined reset errors from the bb\arch.h include file.
Outputs None
Assumptions None
Example /* Initialize the kernel and Bluetooth stack */
Kernel_Init(0);
BLE_Init(0);
BLE_Reset();
6.1.3.2 BLE_InitNoTL
Initialize the Bluetooth stack for use within an application.
Type Function
Include File #include <rsl10_bb.h>
#include <rsl10_ble.h>
Template void BLE_InitNoTL(uint32_t error)
Description Initialize the Bluetooth stack for use within an application. If the stack is being re-initialized due
to an error, raise a message to the local Bluetooth host to help ensure that error recovery is
handled well.
www.onsemi.com
54
ON Semiconductor
Inputs error = Indicate why the Bluetooth stack is being re-initialized; should be set to 0
(RESET_NO_ERROR) if no error had occurred, and otherwise should use one
of the defined reset errors from the bb\arch.h include file.
Outputs None
Assumptions None
Example /* Initialize the kernel and Bluetooth stack */
Kernel_Init(0);
BLE_InitNoTL(0);
BLE_Reset();
6.1.3.3 BLE_Reset
Reset the underlying Bluetooth hardware.
Type Function
Include File #include <rsl10_bb.h>
#include <rsl10_ble.h>
Template void BLE_Reset(void)
Description Reset the underlying Bluetooth hardware. Ensures that the Bluetooth stack firmware is
synchronized to the hardware.
Inputs None
Outputs None
Assumptions None
Example /* Initialize the kernel and Bluetooth stack */
Kernel_Init(0);
BLE_Init(0);
BLE_Reset();
6.1.3.4 BLE_Power_Mode_Enter
Safely enter into a non-running power mode, maintaining the existing Bluetooth stack state and adhering to
required Bluetooth low energy timing.
Type Function
Include File #include <rsl10_bb.h>
#include <rsl10_ble.h>
Template bool BLE_Power_Mode_Enter(void *power_mode_env, uint8_t power_mode)
Description Safely enter into a non-running power mode, maintaining the existing Bluetooth stack state and adhering to
required Bluetooth low energy timing.
Inputs power_mode_env = Parameters and configurations for the desired power mode
power_mode = Desired power mode; use POWER_MODE_[SLEEP | STANDBY]
Outputs return value = Returns true if it was safe to switch to the desired power mode, false otherwise.
www.onsemi.com
55
RSL10 Firmware Reference
Assumptions None
Example /* Main application loop:
* - Run the kernel scheduler
* - Refresh the watchdog, switch to sleep mode until the next event
* should occur, and wait for an interrupt after waking up before
* continuing */
while (1)
{
Kernel_Schedule();
6.2 HCI
The role of the HCI is to provide a uniform interface method of accessing a Bluetooth low energy controller’s
capabilities from the host. The HCI layer is part of the Bluetooth low energy 4.2 protocol stack, as shown in Figure 5 on
page 57.
www.onsemi.com
56
ON Semiconductor
Application
Profiles
GATT GAP
L2CAP
HCI (optional)
Lower Layers
The HCI layer can be included in three kinds of systems: a full stack system, a host, or a controller. The full stack
system contains both host and controller layers. In this case, the role of the HCI is to convey the information from one
part to the other by following the rules defined in the HCI standard. For a host or controller only system, the HCI will
need to interface with a transport layer that manages the reception and transmission of messages over a physical
interface, such as USB or UART.
As shown in Figure 6 on page 58, the two main configurations are supported by the HCI software.
www.onsemi.com
57
RSL10 Firmware Reference
The HCI software supports the two working modes as illustrated in Figure 6. RSL10 has both a full stack system,
and compatibility with an external system.
The HCI software is an interface communication block (depicted in Figure 7 on page 59) that can be used for 3
main purposes:
www.onsemi.com
58
ON Semiconductor
Host Tasks
kernel message
HCI UART
LLM LLC LM LC
Controller Tasks
www.onsemi.com
59
RSL10 Firmware Reference
As described in Figure 8 on page 59, the HCI provides two main processing blocks for RSL10: routing, and
external interface packet management. When both host and controller stack parts are present (full stack mode), the
external interface feature is optional and the routing system auto-detects whether the lower layers are used by the
internal or the external host. The first main challenge of the HCI software is to route the messages to/from the internal
task and to/from the external interface. Several types of messages are used to carry the information. These messages
might carry some basic control information for the Bluetooth low energy technology operations, in which case they will
be conveyed to the main management tasks (LLM/GAPM - Link Layer Manager/ Generic Access Profile Manager). But
the messages can also carry link dedicated information, and in that case they will need to be conveyed to the link
specific tasks (LLC/GAPC/L2CC - Link Layer Controller/ Generic Access Profile Controller/ Logical Link Protocol).
For RSL10, the communication blocks do not have communication with external controllers; however, the
capability of communication with an external host is possible. During reception from the external interface, the HCI
also manages the buffer allocation with the kernel memory heap. This is so that after unpacking, an internal kernel
message is ready for processing by an internal task.
The huge number of control messages means that the HCI software defines descriptor tables, so that each
message’s descriptor is referred to during processing. The data packets need a specific buffer allocation policy managed
by the IP software. More details are given in the following sections.
Routing Packing/Unpacking
1 byte
2 bytes 1 byte 4 bytes 4 bytes
3:0 5:4 6 7
Opcode LL ID HL ID SpU SpP Size PARAM FORMAT RET PAR FORMAT
www.onsemi.com
60
ON Semiconductor
IMPORTANT: For standard commands, all fields used for parameter packing or unpacking relate directly to
the Bluetooth standard specification.
The fields for parameter packing or unpacking are present only if an external interface is supported. In a
full stack system that does not support an external interface, only the routing fields are present in the command
descriptors. The command group (OGF) allows classifying the descriptors in separate tables.
For instance, Figure 10 on page 62 shows some examples of HCI command descriptors within the Link Control
commands group.
www.onsemi.com
61
RSL10 Firmware Reference
OGF 1 Opcode LL ID HL ID SpU SpP Size PARAM FORMAT RET PAR FORMAT
0 0x0401 LM N/A N N 5 "3BBB" NULL
1 0x0402 LM N/A N N 0 NULL "B"
2 0x0403 LM N/A N N 9 "HH3BBB" "B"
… … … … … … …
Another example of HCI command descriptors within the controller and baseband command group is shown in
Figure 11.
OGF 3 OCF LL ID HL ID SpU SpP Size PARAM FORMAT RET PAR FORMAT
0 0x0C01 LM/LLM GAPM N N 8 "8B" "B"
1 0x0C02 LM N/A N N 0 NULL "B"
2 0x0C03 LM/LLM GAPM Y N 9 pointer to function "B"
… … … … … … …
At any time, the HCI software can obtain a descriptor associated with a command by using a unique common table
referencing all the groups present in the HCI software, as shown in Figure 12 on page 63.
www.onsemi.com
62
ON Semiconductor
OGF 1 Opcode LL ID HL ID SpU SpP Size PARAM FORMAT RET PAR FORMAT
0 0x0401 LM N/A N N 5 "3BBB" NULL
1 0x0402 LM N/A N N 0 NULL "B"
2 0x0403 LM N/A N N 9 "HH3BBB" "B"
… … … … … … …
OGF Pointer to cmd desc tables OGF x OCF LL ID HL ID SpU SpP Size PARAM FORMAT RET PAR FORMAT
0
0 Link Control desc_link_ctrl 1
1 Link Policy desc_link_pol … … … … … … …
N
2 Controller & Baseband desc_ctrl_bb
desc_info_par OGF 3 OCF LL ID HL ID SpU SpP Size PARAM FORMAT RET PAR FORMAT
3 Informational Parameters
0 0x0C01 LM/LLM GAPM N N 8 "8B" "B"
4 Status Parameters desc_stat_par 1 0x0C02 LM N/A N N 0 NULL "B"
2 0x0C03 LM/LLM GAPM Y N 9 pointer to function "B"
5 Testing desc_testing
6 LE Controller desc_le_ctrl … … … … … … …
… … …
N 0x0C6D LM N/A N N 2 "BB" "B"
N Vendor Specific desc_vendor_spec
OGF x OCF LL ID HL ID SpU SpP Size PARAM FORMAT RET PAR FORMAT
0
1
… … … … … … …
N
www.onsemi.com
63
RSL10 Firmware Reference
The HCI software assigns one event descriptor to each of these sub-events, called LE events. As a result, a second
table is present with all LE events described and indexed by their LE event subcodes, as shown in Figure 14.
NOTE: The fields for parameter packing or unpacking are present only if an external interface is
supported. In a full stack system that does not support an external interface, only the routing
fields are present in the event descriptors.
All HCI commands are internally carried through a unique kernel message filled with the following data shown in
Figure 15:
www.onsemi.com
64
ON Semiconductor
Table 34 shows the kernel message contents. Thanks to the information contained in the kernel messages, each task
receiving such messages can retrieve the HCI command information.
NOTE: Each lower layer task that might receive HCI commands must implement one HCI command
message handler as a unique entry point. The HCI command message is responsible for
processing and freeing the kernel message, and is also responsible for replying to each HCI
command it receives.
6.2.1.4 Events
The controller stack can send an event to the host at any moment. It sends a kernel message that can be one of four
types:
www.onsemi.com
65
RSL10 Firmware Reference
6.2.1.4.2 LE Event
All HCI meta events are internally carried through a unique kernel message filled with the following data shown in
Figure 17, and in Table 36:
Figure 18. Kernel Message for Carrying HCI Command Complete Events
www.onsemi.com
66
ON Semiconductor
Figure 19. Kernel Message for Carrying HCI Command Status Events
Figure 20. Kernel Message for Carrying HCI LE ACL RX Data Information
www.onsemi.com
67
RSL10 Firmware Reference
Figure 21. Kernel Message for Carrying HCI LE ACL TX Data Information
www.onsemi.com
68
ON Semiconductor
TASK X
cmd1_handler
cmd2_handler
TASK Z
cmdN_handler
transmit message
HCI cmd_handler
H4 TL TASK Y
cmd desc
cmd1_handler
table
rx_state_machine
cmd2_handler
cmdN_handler
cmd_handler
HCI handlers
table
As seen in Figure 22, for each message transiting through the HCI (command, event, RX data, TX data), the HCI
software needs to find the destination task within lower or higher layers. For example, UART Transport Layer sends the
state machine to be unpacked and then rerouted to its respective task.
Control messages that are not dedicated to a specific Bluetooth low energy connection are sent to the main LL
manager task (LM/LLM), which is a single instantiated task. Bluetooth low energy technology implements a manager
task and is able to handle the messages specific to its own protocol. The messages related to common management of
the device (e.g. HCI_Reset_Cmd, HCI_Read_Local_Version_Information_Cmd) are sent to the Bluetooth low
energy controller task in Bluetooth low energy technology stand-alone configuration.
When a message is specific to a Bluetooth low energy connection (ACL data or link-specific control messages), the
HCI needs to find the associated instance of the Bluetooth low energy controller task. The mechanism is mainly based
on a per-connection value named “connection handle”, which is allocated by the controller at link establishment, and
freed at link disconnection. Link-specific messages generally include the connection handle as part of their parameters.
The connection handle is indicated to the host by the controller when the connection has been established, thanks to
the HCI LE Connection Complete event (Bluetooth low energy asynchronous connection).
www.onsemi.com
69
RSL10 Firmware Reference
A connection is considered closed by the HCI when the HCI Disconnection Complete event is transferred.
This section assumes that the connection handle is chosen by the internal controller so that it is possible for a link
identifier to derive a connection handle.
To be able to route all link-oriented messages to the right Bluetooth low energy controller task instance, the HCI
maintains internal data organized as shown in Figure 23.
idx State
0 …
1 …
BLE links
… …
M-1 …
Figure 23. Table for Link Identification (Messages Received from External Host)
The purpose of associating a status with each link is to filter the potential wrong connection handles received from
the host. A message is transferred to a Bluetooth low energy controller task instance if and only if the connection handle
is in the possible range and the associated link exists.
The filling of these tables is accomplished by the controller tasks themselves at link establishment or disconnection,
as shown in Figure 24.
Register (linkID)
Unregister (linkID)
As seen in Figure 24, when a link-oriented command is transferred through the HCI, the HCI checks whether there
is an active link that could match on the based “State” flag and the connection handle or BD address. If no link identifier
matches, a command complete event or command status is sent back to the host with the error code Unknown Link
www.onsemi.com
70
ON Semiconductor
Identifier. If a matching link identifier is found, the destination task instance is built from the associated link
identifier.
Communication between the internal host and the controller implies that the device is in full stack configuration,
and then in Bluetooth low energy single mode, as the full stack mode is supported in Bluetooth low energy single mode
only. In both directions, the HCI retrieves the command opcode or event code from the kernel message, and translates it
to a higher layers or lower layers destination type. The manager task just depends on the direction (LLM task in
controller, or GAPM task in host).
As aforementioned, the full stack configuration involves an internal controller only, where the connection handle
allocation rules are considered known (see Section 6.2.3, “Proprietary Rules for Connection Handle Allocation” on
page 71). Then, the connection handle can be directly associated with a link identifier without the need of any
association table, and it is assumed that the internal host or controller never tries to transmit a message with an incorrect
connection handle. Therefore, when composing the controller task destination (LLC task in controller, or GAPC task in
host), the instance selection is the link ID derived from the connection handle.
The Bluetooth low energy controller IP internally allocates a link identifier in the range [0 : M-1], where M is the
number of Bluetooth low energy links supported. The proprietary rule to create a connection handle from the link ID is:
These rules are given as information; they are not standard. To be compatible with third-party systems, the HCI
software stores any connection handle in the link identification table as described above.
The HCI software handles the message routing of any message received by the transport layer to a destination block
within the controller layers. Additionally, it handles command parameter unpacking, depending on the receiving system
structure padding and endianness policies.
When receiving an HCI command from an external system, the transport might proceed in one or several steps.
After a complete packet has been received, packet management is delegated to the HCI layer. For example, to receive a
command over UART, TL gets a packet in two steps for commands with no parameters, or three steps for commands
with parameters, as shown in Figure 25 on page 72.
www.onsemi.com
71
RSL10 Firmware Reference
CMD ID
- start reception of the header interruption
function call
CMD HEADER OS message/event
Set an OS event
- check the parameter size with HCI check param size
-allocate memory buffer for payload
- start reception of the payload (returns a status) - check size
CMD PAYLOAD
Set an OS event
- indicate the reception to HCI command received
- free payload buffer -decrement nb free cmd
- start reception of next packet ID - allocate command kernel message
- unpack parameters
- find the destination task (LLM/LLC)
- send message CMD
Process the command
allocate event Kernel message(response)
free command Kernel message
CC / CS EVT send message
- push to HCI TX queue
-increment nb free cmd
- pack parameters / build packet
send packet - give to H4TL
- transmit packet
TX DONE
Set an OS event
- inform HCI TX done
- pop HCI TX queue
- free event Kernel message
Figure 25. HCI Command Reception Flow Over UART (Command with Parameters)
As seen in Figure 22 on page 69, the UART transport layer generally works under interrupt. The command header
and payload reception triggers an OS event for background processing. In background, the TL calls the HCI software to
delegate the header and payload reception. Then it restarts the reception over the physical interface. A packet is
considered fully received at header reception for parameter-less commands, otherwise it is considered received once the
payload is received. For each command which has parameters and is checked as valid by the HCI, the transport Layer
must allocate a memory with the appropriate space for receiving the payload.
The processing performed by the HCI at packet reception is based on the HCI command opcode. For each known
packet, the HCI builds a kernel message and sends it to the right task within the Bluetooth low energy controller stack.
N
parameters buffer from TL PARAMS pk
2 2 2 2 N + padding
message allocation by HCI MSGID LM/LC HCI LEN kernel message parameters buffer (empty)
www.onsemi.com
72
ON Semiconductor
NOTE: the kernel message parameters size handles the space needed by the parameters on a C structure
basis. This means that for any compiler, the space reserved is the size of the final structure. Some
compilers include padding between structure fields. For that reason, the allocated size is based on
the parameters format string available in the descriptor rather than the received parameters size.
Each HCI command will be replied to with an HCI command status or command complete event. These two events
are particularly selected responses to HCI commands. Then their transmission through the HCI increments the current
number of HCI commands the system can handle. Their special parameters manipulation is explained in the following
section.
In the case of external routing, the HCI pushes the message in a transmission queue. Once a transport layer TX
channel is available, the HCI builds the HCI packet and transmits the buffer to the TL. The kernel message buffer is
used by the HCI to build the HCI event packet, to transmit over the transport layer. It is not freed right after being posted
to the HCI, but only after the TL has confirmed the transmission (HCI TX Done), as shown in Figure 27.
H4TL HCI LL
interruption
function call allocate event Kernel message(response)
EVT send message
OS message/event
- push to HCI TX queue
send packet -pack parameters / build packet
- give to H4TL
- transmit packet
TX DONE
Set an OS event
- inform HCI TX done
- pop HCI TX queue
- free event Kernel message
The events are classified in four different categories: Legacy, Command Complete, Command Status, and LE
events. Each has a specific packet format and potentially specific parameter manipulation.
The HCI manages a TX FIFO for queueing several events/data for transmission. When several events are queued,
the completion of one event transmission triggers the transmission of the next event. The HCI always works in OS
background. The end of transfer interrupt from the physical layer triggers an OS event. Then the TL calls the HCI
from the background.
www.onsemi.com
73
RSL10 Firmware Reference
1 1 N
packet built by HCI CODE L PARAMS pk
The packet building is performed thanks to the legacy event descriptor table that contains descriptors for each
supported event.
To send a CC event, a controller task composes a CC event message to the HCI. When receiving this message, the
HCI performs the following actions:
• Increments the number of free commands the HCI can receive (HCI flow control)
• Packs return parameters
• Fills other fields
• Pushes to the HCI TX queue
Data manipulation over the kernel message buffer is shown in Figure 26 on page 72.
1 1 1 2 N
packet built by HCI 0x0E L NB OPCODE RET PARAMS pk
The packet parameter unpacking is performed thanks to the original command descriptor found in the command.
To send a CS event, a controller task composes a CS event message to the HCI. When receiving this message, the
HCI performs the following actions:
• Increments the number of free commands the HCI can receive (HCI flow control)
• Builds the packet
www.onsemi.com
74
ON Semiconductor
1 1 1 1 2
packet built by HCI 0x0F L STAT NB OPCODE
6.2.5.4 LE Events
All LE events are managed in a common way. The controller task that needs to send an LE event to the host uses the
LE event message. When receiving this message, the HCI performs the following actions:
• Packs parameters
• Builds the packet
• Pushes to the HCI TX queue
1 1 1 N
packet built by HCI 0x3E L SUB PARAMS pk
The packet building is performed thanks to the LE event descriptor table that contains descriptors for each
supported LE event. HCI LE events packet building is shown in Figure 31above.
www.onsemi.com
75
RSL10 Firmware Reference
ACL ID
- start reception of the header interruption
function call
ACL HEADER OS message/event
acl alloc
- request buffer to HCI
(returns a buffer) - allocate ACL TX buffer
- start reception of the payload
ACL PAYLOAD
- indicate the reception to HCI acl received
- start reception of next packet ID - allocate ACL TX kernel message
- find the destination task (LLCi)
- send message ACL TX
free ACL TX Kernel message
Transmits data to peer device
free ACL TX buffer
Figure 29 on page 74 shows the behavior of the HCI in a normal case, when a correct packet is received from the
host, and buffers are available. However, two error cases are possible when the transport layer receives the HCI data
packet header:
If the field received in the HCI header exceeds the maximum buffer size, the reception over the physical
interface is considered erroneous. In this case, the HCI returns a NULL pointer, and the TL resets its reception
path.
2. Buffer overflow:
If there are no more available buffers within the stack, the HCI allocates a buffer from the RAM heaps. It frees
the buffer once the TL indicates the payload reception.
www.onsemi.com
76
ON Semiconductor
ALLOC
BT BLE
conhdl ?
NOT FOUND
YES
YES size > size BT/BLE max ? YES
size > size BT max ? NO size > size BLE max ?
NO NO
Allocate from Kernel Heap
Allocate from BLE buffers
Allocate from BT buffers
END
YES NO NO YES
OK ? OK ?
END
END
END
Figure 33 shows the algorithm executed when trying to allocate a buffer for TX data. Possible results are:
Then, after reception of the payload through the TL, the action taken by the HCI follows the result of the buffer
allocation, as shown in Figure 34 on page 78:
www.onsemi.com
77
RSL10 Firmware Reference
RECEIVED
YES
BLE buffer?
NO
Create message and send to LLC
YES
BT buffer?
NO
Create message and send to LC
END
H4TL HCI LL
interruption
allocate ACL RX buffer
function call receive data
OS message/event allocate ACL RX Kernel message
ACL RX send message
- push to HCI TX queue
send packet - build packet
- give to H4TL
- transmit packet
TX DONE
Set an OS event
- inform HCI TX done
- pop HCI TX queue
- free ACL RX Kernel message
- free ACL RX buffer
The kernel message used for managing the ACL packet transmission and its associated data buffer is freed when
the packet has been confirmed by the physical interface.
For several reasons, including portability, code size and flexibility, the HCI software preferentially uses a common
method of packing and unpacking the parameters according to the needs of both sides:
www.onsemi.com
78
ON Semiconductor
• The HCI interface, which deals with byte streams where the parameters are packed and the bytes are serialized
in a specific order
• The internal system, which has its own processor and memory constraints (endianness, data alignment,
structure padding)
An SW utility package is included within the HCI layer. It defines generic packer and unpacker functions explained
below.
It parses the input format string up to the end. For each element, it computes the read position (where the unpacked
data is located), taking into account the current compiler alignment constraint. Then it copies the data to the write
position within the restrictions of the processor endianness. The write location is incremented by the length of the
copied data. An example of data packing for an ARM processor is shown in Figure 36 on page 80.
NOTE: The generic unpacker can also be used to determine the size of the packed data. If no buffer is
given to the function, the algorithm performs a space computation without any data copy. This
can be useful to check packet consistency when the TL has received the header.
www.onsemi.com
79
RSL10 Firmware Reference
aligned on 32-bits
B H B L
unpacked data
A B C D
packed data A B C D
The unpacker parses the input format string up to the end. For each element, it computes the write position (where
the unpacked data has to be written), taking into account the current compiler alignment constraint. Then it copies the
data to the write position within the restrictions of the processor endianness. The read location is incremented by the
length of the copied data. An example of data unpacking for an ARM processor is shown in Figure 37.
NOTE: The generic unpacker can also be used to determine the size of the unpacked data. If no buffer is
given to the function, the algorithm performs a space computation without any data copy. This
can be useful at buffer allocation time before receiving the data from the TL.
aligned on 32-bits
B H B L
packed data A B C D
unpacked data A B C D
www.onsemi.com
80
ON Semiconductor
These macros or functions must be adapted to each compiler/processor on which they are used.
6.3 GATT
The GATT is the gateway used by the Attribute Protocol to discover, read, write and obtain indications of the
attributes present in the server attribute, and to configure the broadcasting of attributes. The GATT lies above the
Attribute Protocol and communicates with the Generic Access Profile (GAP), higher layer profiles, and applications.
The architecture of the GATT is shown in Figure 38.
6.3.1.1 Roles
The GATT client is the device that initiates commands and requests to the GATT server, and can receive responses,
indications and notifications from the GATT server. The GATT server is the device that accepts incoming commands
and requests from the GATT client, and sends responses, indications and notifications to the GATT client. These roles
are not fixed to the devices on which they run, and a device’s affiliation to the role is stopped as soon as the role-specific
procedure ends. A device can act in both roles simultaneously.
www.onsemi.com
81
RSL10 Firmware Reference
6.3.1.3.1 Service
The service definition contains a service declaration, and contains both include and characteristic definitions. The
service declaration is an attribute with the attribute type set to UUID for primary service (as shown in Figure 40), or
secondary service (as seen in Figure 41 on page 83).
Primary Service
Handle: 16-bit UUID
Type: 0x2800
Value: 16 or 128 bit UUID
Permission: Read Only, No Authen, No Author
www.onsemi.com
82
ON Semiconductor
Secondary Service
Handle: 16-bit UUID
Type: 0x2801
Value: 16 or 128 bit UUID
Permission: Read Only, No Authen, No Author
When multiple services exist, definitions of the services must be grouped together, according to the Bluetooth
UUID type (2, 4 or 16 octets).
Include
Handle: 16-bit UUID
Type: 0x2802
Value: Included Svc Hndl, End Grp Offset, Svc UUID
Permission: Read Only, No Authen, No Author
The Include declaration is an attribute with its attribute type set to 0x2802. This value is set to the attribute handle,
End group offset and UUID for the service (2, 4 or 16 octets). If the attribute client detects a circular reference or nested
include declarations to a greater level than it expects, it will terminate the ATT Bearer.
6.3.1.3.3 Characteristics
The characteristic definition contains a characteristic declaration, value, and might contain a characteristic
descriptor declaration, as seen in Figure 43.
Characteristic
Handle: 16-bit UUID
Type: 0x2803
Value: Properties, Attr Hndl, Char UUID
Permission: Read Only, No Authen, No Author
The characteristic declaration is an attribute with the attribute UUID type set to 0x2803, and the attribute value set
to the characteristic properties, value attribute handle, and value UUID (2, 4 or 16 octets).
www.onsemi.com
83
RSL10 Firmware Reference
The characteristic extended properties declaration is a descriptor that gives more characteristic information, as
shown in Figure 44. The descriptor is an attribute with type set to 0x2900, and the attribute value equal to a set
characteristic extended properties bit field.
The descriptor is an attribute with type set to 0x2901, and the value set to user description UTF-8 format, as seen
above in Figure 45.
www.onsemi.com
84
ON Semiconductor
The descriptor is an attribute with type set to 0x2902, and the value set to characteristic descriptor value, as seen
above in Figure 46.
The descriptor is an attribute with type set to 0x2903, and the value set to characteristic descriptor value, as shown
above in Figure 47.
NOTE: Service data in advertising data is managed by application using the GAP interface.
www.onsemi.com
85
RSL10 Firmware Reference
Characteristic Format
Handle: 16-bit UUID
Type: 0x2904
Value: Format, Exponent, Unit, Name Space, Desc
Permission: Higher layer specified
The access permissions are profile- or implementation-defined. The bit ordering is little-endian. Format
components are shown below in Figure 49.
The attribute value is a list of attribute handles, which is the concatenation of multiple 16-bit attribute handle
values. The list contains at least two attribute handles for characteristic presentation format declaration.
6.3.1.4 L2CAP
Table 42 on page 87 shows the GATT requirements for L2CAP.
www.onsemi.com
86
ON Semiconductor
The attribute protocol is used to read and write values from the database of a peer device, called the attribute server.
To do this, first the list of attributes in the database on the server are discovered. Once the attributes have been found,
they can be read and written as required by the client.
q y
The Attribute Block is composed of three entities: attribute server, attribute client and attribute manager, as show
above in Figure 51.
The Attribute Server (ATTS) handles the server-based request messages and prepares responses for the received
requests.
The Attribute Client (ATTC) handles the client-related request messages for the attribute server.
The Attribute Manager (ATTM) is responsible for storing the attribute database of the device.
NOTE: The attribute toolbox is not task oriented, and can only be used by generic attribute tasks.
www.onsemi.com
87
RSL10 Firmware Reference
Element Information
Handle The attribute handle is a 16-bit value that is assigned by
each server to its own attributes to allow a client to
reference those attributes. The attribute handle on any
given server shall have unique, non-zero values.
Type An attribute type identified by a UUID specifies what the
attribute represents. This is for the client to understand the
meaning of the attributes exposed by a server. The UUID
that identifies the attribute is considered unique over all
space and time.
UUID is 128-bits in size, and for efficiency’s sake, UUIDs
can be shortened to 16-bits or 32-bits.
NOTE: 16-bits and 32-bits UUIDs are
assigned by Bluetooth SIG. 32-bits
UUIDs are reserved for proprietary
profiles. 128-bits UUIDs can be
used for any proprietary profiles
without any fees.3
Value The attribute value is an octet array that can be either fixed-
or variable-length. This is the actual value of the attribute
and might contain a value that is too large to fit in a single
Packet Data Unit (PDU), which will be transmitted using
multiple PDUs.
Permission An attribute can have a set of permission values associated
with it.
1. Read, Write Access Permission
2. Indications or notifications permission
3. Security Access Requirement: Authentication
required or not
Unsolicited pdus
notifications
indication
command
server client server client
confirmation
request response
www.onsemi.com
88
ON Semiconductor
1. Requests – PDUs which are sent to a server by a client and invoke responses
2. Responses – PDUs which are sent in reply to an attribute client’s requests
3. Commands – PDUs which are sent to a server by a client
4. Notifications – PDUs which are unsolicited sent to a client by a server
5. Indications – PDUs which are unsolicited sent to a client by a server, and invoke confirmations
6. Confirmation – PDUs which are sent to a server to confirm receipt of an indication to a client
Multi-octet fields within the attribute protocol are transmitted with the least significant octet first (little endian).
Attribute PDUs may or may not contain signatures, as shown in Figure 53 (without a signature), and in Figure 54 (with
a signature).
1 octet Up to (MTU-1)
Opcode Parameters
L2CAP attribute protocol PDU messages are described in the Core Specification.
It is possible for an attribute server to receive a command, send an indication back, and then the response to the
original command. The flow control of commands is not affected by the transmission of the indication.
6.3.2.3.3 Transaction
An Attribute Protocol command and response pair is considered a single transaction.
A transaction starts when the request is sent by the attribute client. A transaction is completed when the response is
received by the attribute client.
www.onsemi.com
89
RSL10 Firmware Reference
Similarly, a transaction starts when an indication is sent by the attribute server. A transaction is completed when the
confirmation is received by the attribute server. A transaction must be completed within 30 seconds, or else it is
considered to have timed out. If a transaction has not completed before it times out, then this transaction is considered to
have failed, and the local higher layers are informed of this failure. No more ATT transactions will be accepted for the
link.
This memory block contains a pointer to the next service (NEXT_SVC_PTR), its start handle, and the last handle
value, followed by an array of attribute definitions (Section 6.3.2.5.1, “Attribute Definition” on page 91). The first
attribute in the service memory block describes the services (see Section 6.3.2.5.3, “Service Permission Field” on
page 92). It is used to determine service permissions and the number of attributes present in the service. It is forbidden
www.onsemi.com
90
ON Semiconductor
to have multiple services attributes in a service memory block. Finally, the end of memory block is used to retrieve
32-bit or 128-bit UUIDs and attribute values that can be read from the database.
NOTE: Services handle mapping must be fixed to prevent the collector from performing discovery at
each connection.
• Service task ID
• Pointed handle
• Maximum attribute length
• Value
• Value offset
NOTE: If the attribute UUID is a 32- or 128-bit UUID, the UUID value contains the offset where it can
be found in the service block.
NOTE: Figure 56 on page 91 describes the attribute types specified by the Core Specification.
www.onsemi.com
91
RSL10 Firmware Reference
• Task handler
• Service permissions
• Number of attributes in service
• Service UUID
16 bits UUID or offset where 32 or
128 bits UUID could be found
NOTE: If service UUID is a 32- or 128-bit UUID, the UUID value contains the offset where it can be
found in the service block.
SVC PERM
Instantiated
Target Task Multi
Key Size
Encrypt
Service
Disable
00 - 16 bits 00 - NO_AUTH
01 - 32 bits 01 - UNAUTH
10 - 128 bits 10 - AUTH
11 - RFU 11 – SEC_CON
www.onsemi.com
92
ON Semiconductor
ATT PERM
EXT WS I N WR WC RD B NP IP WP RP
Notify
Properties
Extended
Response
Write Without
Notify
Broadcast
Indicate
Write
Read
Request
Write
Signed Writes
Authenticated
Indicate Read
Perm Perm Perm Perm
MAX_LEN if RI = 1
RI UUID_LEN EKS
DATA_OFFSET if RI = 0
In
Indication
TTrigger Read
Key Size
Encrypt
00 - 16 bits
01 - 32 bits 12 bits of maximum length or data offset
10 - 128 bits (4095 bytes max)
11 - RFU
The following field is used to generate the value of the characteristic declaration property:
NOTE: For an attribute value, permissions are used to generate the characteristic description property
value.
OR
www.onsemi.com
93
RSL10 Firmware Reference
• DATA_OFFSET: data offset of the attribute value in the service memory block (valid only if RI = 0)
The discovery procedure is rescheduled in the kernel several times before completion. An incomplete response is
kept in a cache variable and is fulfilled at the end of the search, or if the MTU is exceed.
www.onsemi.com
94
ON Semiconductor
This procedure also uses data caching of the ATTS to accelerate the read (6.3.2.6.1.4).
• Write Request
• Write Command
www.onsemi.com
95
RSL10 Firmware Reference
• Write Signed
• Write Long/Multiple
www.onsemi.com
96
ON Semiconductor
www.onsemi.com
97
RSL10 Firmware Reference
NOTE: The write request is always send to the profile that manages the handle. It requires a confirmation
of write event whether a message is triggered to a peer device or not.
www.onsemi.com
98
ON Semiconductor
NOTE: Notification/Indication data is present in the event message. This event message can be used to
update the database value (if the attribute value is present in the database).
Response cache: Until the executed procedure is finished, a partial procedure response is stored in the attribute
server environment.
Prepare write cache: For a non-atomic write, a cache is required. This cache is fed by the prepare write and flushed
during the execute write requests.
Read attribute cache: In the attribute database, to speed up read procedures, the value of the latest attribute read is
kept until:
NOTE: The attribute value is put in the cache if the value is not present in the attribute database.
www.onsemi.com
99
RSL10 Firmware Reference
www.onsemi.com
100
ON Semiconductor
NOTE: Discovery and read procedures, using UUID as input, support 16-, 32- and 128-bit UUIDs.
Profile
APP GATTC ATTC L2CC
GATTC_DISC_CMD(ALL_SVC)
ÆGenerate read by group type
req PDU
attc_send_pdu_handler(pdu)
www.onsemi.com
101
RSL10 Firmware Reference
Profile
APP GATTC ATTC L2CC
GATTC_DISC_CMD(SVC_UUID)
ÆGenerate find by type
Req PDU
attc_send_pdu_handler(pdu)
www.onsemi.com
102
ON Semiconductor
Profile
APP GATTC ATTC L2CC
GATTC_DISC_CMD(INC_SVC)
ÆGenerate read by type
Req PDU
attc_send_pdu_handler(pdu)
www.onsemi.com
103
RSL10 Firmware Reference
Profile
APP GATTC ATTC L2CC
GATTC_DISC_CMD(CHAR)
ÆGenerate read by type
Req PDU
attc_send_pdu_handler(pdu)
Figure 73. Discover Peer Characteristics (All or With Specific UUID) MSC
NOTE: The same procedure is used both when discovering all characteristics, and with a specific UUID.
The filtering of the UUID is performed by the client side and not by the service side.
www.onsemi.com
104
ON Semiconductor
Profile
APP GATTC ATTC L2CC
GATTC_DISC_CMD(DESC)
ÆGenerate find info Req PDU
attc_send_pdu_handler(pdu)
attc_send_pdu_handler(pdu)
Start 30s Timer
L2CC_DATA_SEND_REQ(ATT_FIND_INFO_REQ)
L2CC_DATA_SEND_RSP(status)
Nothing To Do
L2CC_PDU_RECV_IND(ATT_FIND_INFO_RSP)
attc_rcv_pdu_handler(pdu)
Stop 30s Timer
Check received pdu – OK
Check status = Not Found – OK
GATT_CMP_EVT(status)
www.onsemi.com
105
RSL10 Firmware Reference
www.onsemi.com
106
ON Semiconductor
www.onsemi.com
107
RSL10 Firmware Reference
www.onsemi.com
108
ON Semiconductor
www.onsemi.com
109
RSL10 Firmware Reference
Profile
APP GAPC GATTC ATTC L2CC
GATTC_WRITE_CMD(WRITE_SIGNED, handle, value)
Generate PDU
attc_send_pdu_handler(pdu)
Request GAP to sign packet
GAP_SIGN_CMD(pdu) No Timer started
Calculate Signature
L2CC_DATA_SEND_REQ(ATT_WRITE_SIGNED_CMD)
L2CC_DATA_SEND_RSP(status)
GATT_CMP_EVT(status)
NOTE: By default the application is informed of any received events if no registration has been
performed.
Profile GATTC
GATTC_REG_TO_PEER_EVT_CMD(shdl, ehdl)
Æ Check if range not already registered
ÆAllocate new registration structure
GATT_CMP_EVT(status) Æ Put it in registration list
Profile
APP GATTC L2CC
L2CC_PDU_RECV_IND(ATT_HDL_VAL_NTF)
www.onsemi.com
110
ON Semiconductor
Profile
APP GATTC L2CC
L2CC_PDU_RECV_IND(ATT_HDL_VAL_IND)
GATTC_EVENT_CFM()
L2CC_PDU_SEND_REQ(ATT_HDL_VAL_CFM)
MTU REQUEST
The MTU exchange procedure, shown above in Figure 84, is a sub-procedure of the server configuration. This is
launched by the attribute client to configure the attribute protocol. At the end of the exchanges, both the attribute client
and server will have a common set MTU, which is the minimum value exchanged.
www.onsemi.com
111
RSL10 Firmware Reference
The “Discover All Primary Services” sub-procedure is used by the client to discover all the primary services on a
server. The “Discover Primary Services by Service UUID” sub-procedure is used by the client to discover a specific
primary service on a server when only the service UUID is identified. The functions are completed in two ways: either
the application receives an error code (Attribute Not Found) or the application cancels the search (in case the desired
primary service is already found).Insufficient Authentication errors and Read Not Permitted errors shall
not occur (service declaration is readable and requires no authentication or authorization).
The “Find Included Services” sub-procedure is used by the client to find include service declarations in the attribute
server database, as shown in Table 45. The function is completed in two ways: either the application receives an error
code (Attribute Not Found) or the read by type response has enough unused data to contain another result
indicating that no further results exist.Insufficient Authentication errors and Read Not Permitted errors
shall not occur (Include declaration is readable and requires no authentication or authorization).
www.onsemi.com
112
ON Semiconductor
The “Discover All Characteristic of a Service” sub-procedure is used to find all the characteristic declarations
within a service definition on a server, when only the service handle range is known. The “Discover Characteristic by
UUID” sub-procedure is used to discover service characteristics on the attribute server, when only the service handle
range and characteristic UUID are known. The functions are completed in two ways: either the application receives an
error code (Attribute Not Found) or the application cancels the search (in case the desired characteristic is already
found). Insufficient Authentication errors and Read Not Permitted errors shall not occur (characteristic
declaration is readable and requires no authentication or authorization).
The “Discover All Characteristic Descriptors” sub-procedure is used by a client to find all the attribute handles and
types of the characteristic descriptor within the characteristic definition, and only when the handle range is known. (See
Table 47, above.) The function is completed in two ways: either the application receives an error code (Attribute
Not Found) or the application cancels the search (in case the desired characteristic descriptor is already found).
www.onsemi.com
113
RSL10 Firmware Reference
The “Read Characteristic Value” sub-procedure is used to read a characteristic value from a server when the client
knows the Characteristic Value Handle. The “Read Using Characteristic UUID” sub-procedure is used to read a
Characteristic Value from a server when the client only knows the characteristic UUID and does not know the handle of
the characteristic. The “Read Long Characteristic values” sub-procedure is used to read a characteristic value from a
server when the client knows the Characteristic Value Handle, and the length of the characteristic value is longer than
can be sent in a single read response attribute protocol message. The “Read Multiple Characteristic values”
sub-procedure is used to read multiple characteristic values from an attribute server when the client knows the
Characteristic Value Handles.
NOTE: Read Blob means reading a specific part of an attribute, starting from an offset and the end of the
attribute value or MTU size.
www.onsemi.com
114
ON Semiconductor
The “Write Without Response” sub-procedure is used to write a Characteristic value to a server when the client
knows the Characteristic Value Handle and the client does not need an acknowledgement that the write was successfully
done. The “Signed Write without Response” sub-procedure is used to write a Characteristic value to a server when the
client knows the Characteristic Value Handle and the ATT Bearer is not encrypted. The “Write Characteristic Value”
sub-procedure is used to write a Characteristic value to a server when the client knows the Characteristic Value Handle.
The “Write Long Characteristic Values” sub-procedure is used to write a Characteristic value to a server when the client
knows the Characteristic Value Handle, but the length of the Characteristic value is longer than can be sent in a single
write request attribute protocol message. The “Characteristic Value Reliable Writes” sub-procedure is used to write a
characteristic value to an attribute server when the client knows the Characteristic Value Handle, and assurance is
required that the correct characteristic value is going to be written by transferring the characteristic value to be written in
both directions before the write is performed.
The “Notifications” sub-procedure is used when a server is configured to notify a characteristic value to a client
without expecting any attribute protocol layer acknowledgement that the notification was successfully received.
www.onsemi.com
115
RSL10 Firmware Reference
The “Indications” sub-procedure is used when a server is configured to indicate a characteristic value to a client and
expects an attribute protocol layer acknowledgement that the indication was successfully received.
The “Read Characteristic Descriptor Value Read” sub-procedure is to read a characteristic descriptor from a server
when the client knows the attribute handle of the characteristic declaration. The “Read Long Characteristic Descriptors”
sub-procedure is used to read a characteristic descriptor from a server when the client knows the attribute handle of the
characteristic descriptor declaration, and the length of the characteristic value is more than will fit in a single read
response attribute protocol message.
The “Write Characteristic Descriptors” sub-procedure is used to write a characteristic descriptor value to a server
when the client knows the characteristic descriptor handle.
The “Write Long Characteristic Descriptors” sub-procedure is used to write a characteristic descriptor value to a
server when the clients knows the characteristic descriptor handle of the characteristic descriptor declaration, and the
length of the characteristic value is more than will fit in a single write response attribute protocol message.
www.onsemi.com
116
ON Semiconductor
The service discovery must be a generic feature used by client profiles to discover a peer device database,
illustrated in Figure 85 on page 117. By using a generic method of service discovery, it prevents code duplication in
client profiles. This discovery will be able to be performed for all services types, or for only some of them. With this
feature, an application can decide if discovery is performed by the client profiles or by the application itself.
NOTE: The client profile verifies whether the peer device service can be used by its implementation.
For each discovered service, this procedure is in charge of finding included services, characteristics and descriptors.
(See Figure 86 on page 118.) When a full service is discovered, this operation triggers a message containing all the
information.
NOTE: Since this procedure can be very long, it can be aborted by the application through a Cancel API.
Profile
APP GAPC GATTC
GATTC_SDP_SVC_DISC_CMD(svc_uuid)
GATTC_DISC_CMD(svc, svc_uuid)
GATTC_DISC_SVC_IND(shdl, ehdl)
GATTC_CMP_EVT(status)
GATTC_CMP_EVT(status)
…
GATTC_CMP_EVT(status)
GATTC_DISC_CHAR_DESC_IND(hdl, uuid)
GATTC_DISC_CHAR_DESC_IND(hdl, uuid)
…
GATTC_CMP_EVT(status)
GAPC_CMP_EVT(status)
www.onsemi.com
117
RSL10 Firmware Reference
The GATT profile service, shown in Figure 87 below, is a single-instantiated primary service which is exposed on a
GATT server. The profile service has a service changed characteristic.
The “Service Changed” characteristic is a control point attribute that is used to notify connected devices that GATT
services have been changed. The value cannot be read nor written but can be notified at any time.
Table 54 and Table 55 explain the environment variables associated with both the GATT manager and controller
respectively. By accessing these values, you can make modifications to the structure as needed.
www.onsemi.com
118
ON Semiconductor
This profile states the requirements on names, values and coding schemes used for names of parameters and
procedures experienced on the user interface level. This profile describes the general procedures that can be used for
establishing connections to other Bluetooth low energy technology devices that are able to accept connections and
service requests.
GAP defines two parties (A and B) in establishing Bluetooth low energy technology communication:
• A-Party: the device that is either scanning in the link layer scanning state, or initiating in the link layer
initiating state
• B-Party: the device that is either advertising in the link layer advertising state, or accepting the link request
The GAP allows minimal functionality in absence of other profiles and provides an API when other profiles are
present.
GAP introduces three device types based on supported Core Configurations, as shown below in Figure 88.
www.onsemi.com
119
RSL10 Firmware Reference
BR/EDR
BR/EDR LE only
and LE
Stand-alone
Low Energy
Devices of type LE-only and BR/EDR/LE are capable of operating over an LE physical channel.
Moreover, GAP defines different modes of operation which are generic and can be used by profiles and by devices
implementing multiple profiles (see Table 56 on page 120).
In addition to functions shown in Figure 89, a peripheral is able to broadcast data, and a central is able to enter in
observable mode. A device can support all roles at the same time, so that it can act both as a central (scan + master of a
link) and peripheral (advertise + slave of a link).
www.onsemi.com
120
ON Semiconductor
A device supporting all modes cannot start two non-connected operations (such as advertising, scanning or
connection init) at the same time.
Broadcasting
Discovery Connection Bonding
and Observing
GAP defines the general procedures that can be used for discovering identities, names, and basic capabilities of
other Bluetooth low energy technology devices that are discoverable. It also describes the ability of a device to be
connected and discovered by another device. See Figure 90 on page 121 for low energy operational modes.
6.4.2.1.1 Conditions
A broadcaster is a device operating in broadcast mode. It sends data in either non-connectable undirected or
discoverable undirected advertising events. All data sent by a broadcaster is considered unreliable since there is no
acknowledgement from any device that might have received data. No support for encryption.
An observer is a device operating in scan mode. It uses either passive or active scanning in receiving advertising
events. No support for encryption.
www.onsemi.com
121
RSL10 Firmware Reference
NOTE: When this operation is on-going, an application can modify advertise and scan response data to
update ongoing broadcast data.
www.onsemi.com
122
ON Semiconductor
NOTE: This is the only mode that can be used by a broadcaster device.
www.onsemi.com
123
RSL10 Firmware Reference
NOTE: This is the only mode that can be used by an observer device.
www.onsemi.com
124
ON Semiconductor
6.4.2.4 Connection
There are two modes for LE connections defined in GAP (see Figure 94).
• Connectable: permits a device to make connections to or accept connections from another device.
• Non-connectable: prohibits a device from accepting connections from another device.
www.onsemi.com
125
RSL10 Firmware Reference
www.onsemi.com
126
ON Semiconductor
www.onsemi.com
127
RSL10 Firmware Reference
www.onsemi.com
128
ON Semiconductor
NOTE: When device is in this mode, it is not possible to modify the whitelist.
www.onsemi.com
129
RSL10 Firmware Reference
NOTE: When device is in this mode, it is not possible to modify the whitelist.
www.onsemi.com
130
ON Semiconductor
When a slave initiates a connection parameter update without knowing the remote features, a parameter update
must first be started through the HCI. If it fails due to any of the following reasons, legacy negotiation over L2CAP
must be used instead (see Figure 100 on page 132):
NOTE: Operation completion messages for a legacy parameter update initiated by a slave (on a slave
device) have to be triggered before GAPM_PARAM_UPDATE_IND, to ensure that the master device
did not use the connection param request.
www.onsemi.com
131
RSL10 Firmware Reference
Figure 101 shows legacy parameter update negotiation initiated by a slave and rejected by a master.
If a parameter update request is supported by a peer device, the connection parameter initiated by a master or a
slave is a little bit different. It is requested for the peer device to accept or reject new parameters. This parameter update
is only performed through LLCP even if it is initiated by a slave or a master of the link. Figure 102 on page 133 shows
a parameter update with remote update request support accepted by the responder. In Figure 103 on page 133, the
update is rejected by the responder.
www.onsemi.com
132
ON Semiconductor
Figure 102. Parameter Update with Remote Update Request Support Accepted by Responder
Figure 103. Parameter Update with Remote Update Request Support Rejected by Responder
6.4.2.5 Bonding
Bonding is the function where devices exchange and store security and identity information to create a secure
relationship. It occurs at the first connection between devices or the first service that requires security or authorization.
(See Figure 104 on page 134, and Figure 105 on page 134.) Two types of bonding procedures are defined:
• Dedicated bonding occurs when the user initiates SM pairing with the explicit purpose of creating a bond (i.e.,
a secure relationship) between two devices.
• General bonding occurs when the user is requested to pair before accessing a service, since the devices did not
share a bond beforehand.
www.onsemi.com
133
RSL10 Firmware Reference
i 8 C i bli h ih k d i ( b dd )
Figure 104. Connection Establishment With a Known Device (Recover Bond Data)
Figure 105. Recover Bond Data of a Peer Device with a Random Address
Security mode and level defines the safety requirements of a device, or of access to services offered by the device.
www.onsemi.com
134
ON Semiconductor
Level 1: No Security
Level 4: Authenticated LE
Secure Connections pairing
with encryption
• Authenticated pairing: Perform pairing procedure with authentication set to MITM protection
• Unauthenticated pairing: Perform pairing procedure with authentication set to No MITM protection
www.onsemi.com
135
RSL10 Firmware Reference
6.4.3.5 Privacy
6.4.3.5.1 Host Managed Privacy (1.1)
The host managed privacy feature provides a specific level of security from attackers, to keep them from tracking
an LE device over a certain period of time. This is an optional feature for all GAP roles. (See Table 57.)
NOTE: If a device has all roles, it cannot use both Resolvable address for an air activity and
Non-Resolvable address for another air activity. A privacy error will be triggered in that case.
6.4.3.5.3 LE Address
There are two types of Bluetooth low energy addresses:
1. Static Address
• Two most significant bits are equal to 1
• All the other bits are neither “all 0s” nor “all 1s”
2. Private Address
a. Non-resolvable Address
• Two most significant bits are equal to 0
• All the other bits are neither “all 0s” nor “all 1s”
a. Resolvable Address
• Two most significant bits are equal to 01
• 22 remaining bits of prand are neither “all 0s” nor “all 1s”
• 24-bit hash section is derived from IRK, prand and ah func
www.onsemi.com
136
ON Semiconductor
www.onsemi.com
137
RSL10 Firmware Reference
The Bluetooth low energy security manager allows two devices to set up a secure relationship, either by encrypting
a link, by bonding (exchanging information about each other), or by signature use over a plain link. (See Figure 112,
below.) Refer to the Bluetooth Core Specification v5.0 for the SM requirements and protocol methods.
Application
Profiles
GAPM
GAPC GATTC
Control
PDU PDU
Control
L2CAP
Link Layer
A few key concepts must be presented for a clearer understanding of the SM:
• Pairing: this procedure allows two devices to agree upon features that will allow them to establish a certain
level of security.
www.onsemi.com
138
ON Semiconductor
• Bonding: this procedure involves at least one device sending some sort of identification or security information
to the other device, to be used in future connections. This can be an encryption key, signature key, or
identification resolution key. If both devices are bondable, the transport key distribution phase following
pairing will occur. Otherwise no bonding information will be exchanged, and if any is sent, it is a violation of
protocol. Pairing might occur without necessarily bonding, but the features exchanged during pairing are
essential to the existence of a bonding stage. If one of the devices is not bondable, no information about the
peer should be stored (not even the BD address or other non-security related information).
• Unauthentication/authentication: unauthentication is NOT lack of any security, but an intermediary level
between no security and the authenticated security level. The relationship between two devices is said to be
(un)authenticated when the key(s) being used for their link encryption/signing/etc. have a security property that
confirms (un)authentication. This security property is bestowed on a key during pairing, as a function of the
STK method generation used. For both Passkey Entry and OOB Methods, all keys generated and exchanged
afterwards have the authenticated (MITM) property (a pin key/ larger OOB key was used, which enforces
security). If the Just Works method was used, all keys will have the unauthenticated (NO MITM) property.
There can also be the no security property, which applies when the link is plain.
• LE secure connection: This pairing method allows a greater security level than the normal pairing method. It
uses the private/public keys (P-256 elliptic curve) security algorithm to prevent any man-in-the-middle attack.
This secure connection is a fully new pairing method that can be used for Just Works pairing, OOB or pin code
entry. With this method, except Just Works pairing, the security level of the link is considered a “secure
connection authenticated” link.
The Security Manager (SM) toolbox is in charge of Bluetooth secure communication issues: encrypted links,
identity or private address resolution, and signed unencrypted messages. The functionalities of the SM are enforced by
clearly specified pairing and key distribution methods, and the protocol that is to be respected for their correct
implementation. An additional cryptographic toolbox of functions based on the AES-128 algorithm supports key
generation, private address generation and resolution, and message signing and signature resolution.
The architecture decided for the implementation of the security manager is visible in Core Spec 4.1 Vol. 3 Part C,
Chap. 10. Since the different functionalities may be required simultaneously for several connections that a device might
have, those functionalities have been implemented in the toolbox called SMPC: the Security Manager Protocol
Controller. SMPC toolbox is only available using GAPC API.
However, certain higher and lower layer modules have a unique instance, handled by the GAPM task through its
API, SMPM toolbox – Security Manager Protocol Manager – which will monitor SMPC’s requests and responses
without overloading those modules.
The dialogue between SMPM and SMPCs through GAPM and GAPC’s API is limited to a few basic requests and
responses. The communication between SMPCs, higher and lower layers is much richer and also allows a device to
proceed with link encrypting procedures at different stages with the different peers it possesses.
www.onsemi.com
139
RSL10 Firmware Reference
RFC-44931 defines the Cipher-based Message Authentication Code (CMAC) that uses AES-128 as the block
cipher function, also known as AES-CMAC. The inputs to AES-CMAC are:
The 128-bit message authentication code (MAC) is generated as follows: MAC = AES-CMACk(m)
A device can implement AES functions in the Host or can use the HCI_LE_Encrypt command (see Bluetooth [Vol
2] Part E, Section 7.8.22) to use the AES function in the Controller.
www.onsemi.com
140
ON Semiconductor
This specification uses the same notation and terminology as the IETF RFC except for the Message Authentication
Code (MAC) that in this specification is called the Message Integrity Check (MIC) to avoid confusion with the term
Media Access Controller.
CCM has two size parameters, M and L. The Link Layer defines these to be:
www.onsemi.com
141
RSL10 Firmware Reference
CCM requires a new temporal key whenever encryption is started. CCM also requires a unique nonce value for
each Data Channel PDU protected by a given temporal key. The CCM nonce shall be 13 octets.
• Signing own data with own CSRK in view of transmission to peer which is supposed to have received the
CSRK during phase 3, and would thus interpret the received message
• Verification of received signed messages, using CSRK received from peer during previous Phase 3. The same
algorithm is used to generate the signature of the received message and check it against the received signature.
• No LTK is available for this connection, or the existing security information does not have the requested
security properties => pairing must be initiated.
• An LTK is available for this connection, with security properties matching the request => start encrypting the
link directly without pairing.
• Send the slave a Pairing Failed PDU, advising that the master does not support pairing at that moment.
• Static address
• Private address
The three figures below (Figure 113, Figure 114, and Figure 115) give the structure of each kind of private address:
www.onsemi.com
142
ON Semiconductor
The random address generation procedure, shown in Figure 116 on page 143, will be the same, whatever kind of
random address is requested. However, in the case of a resolvable private address, the IRK used to generate the address
shall be kept by the higher layers so that it can be distributed to a peer device.
1. If the address type is not valid, a GAPM_CMP_EVT message with a GAP_ERR_INVALID_PARM status error is
sent.
2. If an error status is returned by the controller, a GAPM_CMP_EVT message with a GAP_ERR_LL_ERROR status
error is sent.
3. prand = LSB22(randnb) || LSB2(addr_type)
4. prand’ = 0104 || prand
5. If an error status is returned by the controller, a GAPM_CMP_EVT message with a GAP_ERR_LL_ERROR status
error is sent, else the status will be GAP_ERR_NO_ERROR.
www.onsemi.com
143
RSL10 Firmware Reference
The GAP provides several IRKs for a same address. The hash part of this address is regenerated using the IRK and
the prand part of the address. If the generated hash part is the same as the hash part of the provided address, the address
is considered resolved, else another IRK shall be sent.
www.onsemi.com
144
ON Semiconductor
• If an error status is received from the controller, the GAPM_CMP_EVT message with a GAP_ERR_LL_ERROR
status is directly sent to the requested layer.
6.4.4.4.4 Pairing
• Phase 1 – pairing feature exchange: It is used to exchange IO capabilities, OOB authentication data,
authentication requirements and which keys to distribute.
• Legacy phase 2 – authentication and encryption: information exchanged during the phase 1 is used to
determine which method will be used to encrypt the link (Just Works, Passkey Entry, Out Of Band).
• LE secure connections Phase 2: – authentication and encryption: information exchanged during the phase 1 is
used to determine which method will be used to encrypt the link (Just Works, Numeric Comparison, Passkey
Entry, Out Of Band). The outcome of this pairing is Long Term Key (LTK) generation.
• Phase 3 – transport keys distribution: This phase is optional and depends on the key distribution features shared
during phase 1.
www.onsemi.com
145
RSL10 Firmware Reference
If the slave device doesn't support pairing, it responds using the pairing failed message with the error code
Pairing Not Supported upon reception of a pairing request message. If a device receives a command with invalid
parameters, it responds with a pairing failed command with the error code Invalid Parameters. The minimum and
maximum encryption key length parameters shall be between 7 bytes and 16 bytes in 1 byte steps. The smaller value of
the initiating and the responding device’s maximum encryption key length will be used as the encryption key size. If the
resultant encryption key size is smaller than the minimum key size parameter, the device responds with pairing failed
command with the error code Encryption Key Size.
www.onsemi.com
146
ON Semiconductor
www.onsemi.com
147
RSL10 Firmware Reference
If the Just Works method is used, no TK will be required (0 is used) from the application. If a generated Sconfirm or
Mconfirm value doesn't match with the received confirm value from the peer device, the device aborts the pairing
procedure by sending a pairing failed message with a Confirm Value Failed error code.
If it is not possible to enter a passkey or do a numeric comparison, this method applies, as seen in Figure 122 on
page 148:
LLCP_SMP_PAIRING_PUB_KEY(PKb)
LLCP_SMP_CODE_PAIR_CFM(Cb)
LLCP_SMP_CODE_PAIR_RAND(Na)
LLCP_SMP_CODE_PAIR_RAND(Nb)
If both devices have display capability, numeric comparison must be chosen, as seen in Figure 123 on page 149.
www.onsemi.com
148
ON Semiconductor
LLCP_SMP_PAIRING_PUB_KEY(PKb)
LLCP_SMP_CODE_PAIR_CFM(Cb)
LLCP_SMP_CODE_PAIR_RAND(Na)
LLCP_SMP_CODE_PAIR_RAND(Nb)
GAPC_BOND_CFM
Do Numeric smpc_paring_cfm(NUM_VAL, OK) GAPC_BOND_CFM
smpc_paring_cfm(NUM_VAL, OK) (NUM_VAL, OK)
(NUM_VAL, OK) Comparison
At the end of the pairing, the link is considered secure connection authenticated.
If both devices have pin code entry possible, passkey entry is chosen, as shown in Figure 124 on page 150:
www.onsemi.com
149
RSL10 Firmware Reference
LLCP_SMP_PAIRING_PUB_KEY(PKb)
GAPC_BOND_REQ_IND(TK_EXCH) GAPC_BOND_REQ_IND(TK_EXCH)
ra = rb = TK ra = rb = TK
ra = ra1|ra2|…|ra20
rb = rb1|rb2|…|rb20
Cai = f4(PKa, PKb, Nai, rai) Cbi = f4(PKb, PKa, Nbi, rbi)
LLCP_SMP_CODE_PAIR_CFM(Cai)
LLCP_SMP_CODE_PAIR_CFM(Cbi) Loop
LLCP_SMP_CODE_PAIR_RAND(Nai)
For i = 1 to 20
Check if Cai = f4(PKa, PKb, Nai, rai)
LLCP_SMP_CODE_PAIR_RAND(Nbi)
During Passkey entry, LLCP_SMP_PASS_KEY_ENTRY message can be sent to a peer device using a
GAPC_BOND_CFM(PASSKEY_ENTRY) message to inform the peer device that the user is entering the password.
At the end of the pairing, the link is considered secure connection authenticated.
If OOB Data can be sent by one or both devices, the Out Of Band pairing method is chosen, as seen in Figure 125
on page 151:
www.onsemi.com
150
ON Semiconductor
LLCP_SMP_PAIRING_PUB_KEY(PKb)
If rb != 0: If ra != 0:
Check if Cb = f4(PKb, PKb, rb, 0) Check if Ca = f4(PKa, PKa, ra, 0)
Generate Na Generate Nb
LLCP_SMP_CODE_PAIR_RAND(Na)
LLCP_SMP_CODE_PAIR_RAND(Nb)
At the end of the pairing, the link is considered secure connection authenticated.
After the LE secure connection authentication Stage 2, the LTK is generated according to pairing information, as
seen in Figure 126 on page 152. Then the link is encrypted. If encryption succeeds and the BOND bit is present in the
pairing feature exchange, the generated LTK is provided to the upper application.
www.onsemi.com
151
RSL10 Firmware Reference
LLCP_SMP_CHECK_DHKEY(Ea)
LLCP_SMP_CHECK_DHKEY(Eb)
www.onsemi.com
152
ON Semiconductor
GAPC_BOND_REQ_CFM
(LTK, Ediv, Rand) smpc_paring_cfm_handler
(LTK, Ediv, Rand) LLCP_SMP_CODE_ENC_INFO(LTK)
LLCP_SMP_CODE_MST_ID(Ediv, Rand)
GAPC_BOND_IND(LTK, Ediv, Rand))
GAPC_BOND_REQ_IND(IRK_EXCH)
Application provides new IRK only for
GAPC_BOND_REQ_CFM Controller Managed Privacy
(IRK) smpc_paring_cfm_handler(IRK)
LLCP_SMP_CODE_ID_INFO(IRK)
LLCP_SMP_CODE_ID_ADDR_INFO(BD_ADDR)
GAPC_BOND_IND(IRK, BD_ADDR)
GAPC_BOND_REQ_IND(CSRK_EXCH)
GAPC_BOND_REQ_CFM
(CSRK) smpc_paring_cfm_handler(CSRK)
LLCP_SMP_CODE_SIGN_INFO(CSRK)
GAPC_BOND_IND(CSRK)
When Privacy is managed by the host (privacy 1.1), the IRK value is already set in the GAP environment. But for a
controller managed privacy (privacy 1.2), the IRK will be unique for each bonded device, and so the new IRK will be
generated and retrieved from the application. The LTK and the CSRK need to be retrieved from the application. On
legacy paring, the application is responsible for generating the transport keys (CSRK, IRK, LTK, Ediv, Rand) by any
means. Figure 127 shows the distribution of the transport keys. The GAPM_USE_ENC_BLOCK_CMD message can be used
through the GAP API. On secure connection pairing, the application is responsible for generating only CSRK and IRK;
the LTK is generated by the pairing algorithm.
www.onsemi.com
153
RSL10 Firmware Reference
GAPC_BOND_IND(Bondable, Auth)
GAPC_BOND_IND (Bondable, Auth)
GAPC_CMP_EVT(status)
The pairing procedure is considered to be over in the following cases, as shown in Figure 128:
6.4.4.4.5 Encryption
The master device must have the security information (LTK, EDIV, and Rand) distributed by the slave device to set
up an encrypted session. An encrypted session is always initiated by the master.
www.onsemi.com
154
ON Semiconductor
The slave requires establishment of an encrypted session by sending a security request. Upon reception of this
request, the master device will check whether it can retrieve the LTK distributed by the device. If a key is found, the
master will start the encryption procedure, else it will start a pairing procedure.
www.onsemi.com
155
RSL10 Firmware Reference
Figure 131. Start Encryption Procedure (Slave Does not Support Encryption)
www.onsemi.com
156
ON Semiconductor
1. SMPC module receive a PDU message to sign from the GATTC, it uses the SMPM encryption block through
the GAPM API.
2. After using the encryption block several times, it generates the MAC signature and appends it to the PDU.
3. The signed PDU message is conveyed to L2CC with the GATTC task as source ID to prevent a kernel
reschedule. The application is also informed that the sign counter has been increased.
www.onsemi.com
157
RSL10 Firmware Reference
1. The SMPC module receives a GATTC_WRITE_REQ_IND message with as signature to verify from the GATTC;
it uses the SMPM encryption block through the GAPM API.
2. After using the encryption block several times, it generates the MAC signature and compares it to the provided
signature.
3. The GATTC_WRITE_REQ_IND message is sent to the targeted profile GATTC task as the source ID to prevent a
kernel reschedule. The application is also informed that the remote sign counter has been increased. If an error
occurs during signature, the GATTC_WRITE_REQ_IND message is dropped and the GATTC is informed that
signature verification has failed.
www.onsemi.com
158
ON Semiconductor
The Bluetooth specification [1] requires the implementation of a mechanism: “When a pairing procedure fails a
waiting interval shall pass before the verifier will initiate a new Pairing Request command or Security Request
command to the same claimant, or before it will respond to a Pairing Request command or Security Request command
initiated by a device claiming the same identity as the failed device. For each subsequent failure, the waiting interval
shall be increased exponentially.” Figure 135 presents the mechanism implemented to rapidly detect an attack from a
malicious device. The minimal interval value is set to 2 s and the maximal interval value is set to 30 s. Thus, according
to the procedure described in Figure 135, a repeated attempt attack will be detected after five attempts.
LSB MSB
1 byte Up to 22 bytes
Code Data
www.onsemi.com
159
RSL10 Firmware Reference
Code Description
0x00 Reserved
0x01 Pairing Request
0x02 Pairing Response
0x03 Pairing Confirm
0x04 Pairing Random
0x05 Pairing Failed
0x06 Encryption
Information
0x07 Master Identification
0x08 Identity Information
0x09 Identity Address
Information
0x0A Signing Information
0x0B Security Request
0x0C Public Key
0x0D DHKey Check
0x0E Keypress
Notification
To ensure there is no lag during the procedure, an SM Timer is implemented allowing maximum 30 seconds of
delay between PDU transmissions on a device. This timer is reset and started upon transmission or reception of a pairing
request command. It is reset every time a command is queued for transmission. If the timer expires, failure is indicated
to the host and no more SMP exchanges are allowed. A new SM procedure starts once the physical link has been
re-established.
The LE credit based connection, also called the connection oriented channel (COC), is an L2CAP feature managed
by GAP. It allows an LE service to create a dedicated channel on a specific link. The Peer service client must connect to
this LE credit based connection before exchanging any packets.
The GAPM manages the list of LE credit based channels created by a profile service. (A peer device cannot
connect to an LE credit based channel if it does not exist on manager.)
NOTE: The maximum number of LECB connection that can be established for a device is configurable
for the device (see Section 6.4.5.11.2, “Device Configuration” on page 175).
www.onsemi.com
160
ON Semiconductor
The manager environment of variables that manages an LE credit based channel is allocated in ATT_DB heap. (See
Figure 137.) It contains:
SEC_LVL
00 – NO_AUTH
01 – UNAUTH
10 - AUTH
11 – SEC_CON
The environment of variables that manages an LE credit based connection is allocated in the ATT_DB heap. (See
Figure 139.) It contains:
www.onsemi.com
161
RSL10 Firmware Reference
NOTE: The LE_PSMs are automatically unregistered when the application requests one of the device
initialization procedures (see Section 6.4.5.11, “Device initialization” on page 175).
If no links are using a specified LE_PSM (no LECB connection established), the application or profile can
de-register it (see Figure 141).
www.onsemi.com
162
ON Semiconductor
Profile
APP GAPC GAPM L2CC
GAPM_LE_CREDIT_CON_CREATE_CMD(LE_PSM, SEC_LVL, TASK_ID)
ÆAllocate new LE Credit Base Channel Manager
structure
GAPM_CMP_EVT(status)
L2CC_RECV_IND(SIG_LE_CREDIT_CHAN_CONNECTION_REQ
(LE_PSM, DST_CID, Credit, MTU))
Æ Check LE_PSM – OK
Æ Check Auth – OK
Æ Check EKS – OK
Æ Allocate new LE Credit Base Channel Controller structure
Æ Register channel
Æ Register the lowest MTU of both devices
GAPC_LE_CREDIT_CON_CONNECT_REQ_IND(LE_PSM, max_sdu_size) Æ Store dest_id and dest _credit
Figure 142 shows different steps of LE credit based connection creation on the service side.
MTU + MPS – 1
• The initial number of credits for the local device must be at least floor --------------------------------------------- + 1 . This is for
MPS
receiving at least an SDU with max packet size.
• If the local CID is set to zero, the GAPC module will find and allocate the first available LECB channel
identifier.
NOTE: When the LE credit based connection is established, the application is informed about the
maximum SDU size allowed (MTU - 2).
NOTE: Several connections can be opened on the same LE_PSM, but the local and peer channel
identifier has to be different each time. This is the role of the application to accept or reject an
incoming connection if one already exists for specific LE_PSM.
www.onsemi.com
163
RSL10 Firmware Reference
NOTE: Channel local MTU and MPS sizes for a connection cannot exceed Maximum MTU and MPS
sizes configured for the device (see Section 6.4.5.11, “Device initialization” on page 175).
Profile
APP GAPC L2CC
L2CC_RECV_IND(SIG_LE_CREDIT_CHAN_CONNECTION_REQ
(LE_PSM, DST_CID, Credit, MTU))
2 Æ Check LE_PSM – OK
Æ Check Auth – KO (link not encrypted, sec_lvl >= UNAUTH)
L2CC_SEND_REQ(SIG_LE_CREDIT_CHAN_CONNECTION_RSP
(LE_PSM, SRC_CID, Credit, MTU, insufficient encryption)
3 Æ Check LE_PSM – OK
Æ Check Auth – KO (Link UNAUTH, sec_lvl = AUTH)
L2CC_SEND_REQ(SIG_LE_CREDIT_CHAN_CONNECTION_RSP
(LE_PSM, SRC_CID, Credit, MTU, insufficient authentication)
4 Æ Check LE_PSM – OK
Æ Check Auth – OK
Æ Check EKS – KO (12 bytes instead of 16 LTK)
L2CC_SEND_REQ(SIG_LE_CREDIT_CHAN_CONNECTION_RSP
(LE_PSM, SRC_CID, Credit, MTU, insufficient encryption key size)
Æ Check LE_PSM – OK
5/6 Æ Check Auth – OK
Æ Check EKS - OK
GAPC_LE_CREDIT_CON_CONNECT_REQ_IND(LE_PSM, dst_credit)
GAPC_LE_CREDIT_CON_CONNECT_CFM(LE_PSM, reject
No resources or not authorized) L2CC_SEND_REQ(SIG_LE_CREDIT_CHAN_CONNECTION_RSP
(LE_PSM, SRC_CID, Credit, MTU, No resources or not authorized)
Figure 143 shows possible connection creation errors on the service side:
1. LE PSM is unknown.
2. Security level is set to unauthenticated, or set to authenticated but the link is not encrypted.
3. Link is encrypted with insufficient authentication level.
4. Link is encrypted with LTK key < 16 bytes but connection requires a 16-byte LTK.
5. Application cannot accept link connection due to insufficient resources.
6. Application cannot accept link connection because peer device is not authorized.
www.onsemi.com
164
ON Semiconductor
Profile
APP GAPC L2CC
GAPC_LE_CREDIT_CON_CONNECT_CMD(LE_PSM, CID, Credit)
L2CC_SEND_REQ(SIG_LE_CREDIT_CHAN_CONNECTION_REQ
(LE_PSM, SRC_CID, Credit, MTU))
L2CC_RECV_IND (SIG_LE_CREDIT_CHAN_CONNECTION_RSP
(LE_PSM, DST_CID, Credit, MTU, OK))
GAPC_CMP_EVT(SUCCESS)
Figure 144 shows the different steps of LE credit based connection creation on the client side.
• Using LE PSM, its channel ID, credit count, MTU and MPS, a client establishes an LE credit based connection
created by a peer service device.
MTU + MPS – 1
• The initial number of credits for the local device must be at least floor --------------------------------------------- + 1 . This is for
MPS
receiving at least an SDU with max packet size.
• If the local CID is set to zero, the GAPC module will find and allocate the first available LECB channel
identifier.
Figure 145, below, shows a client LE credit connection rejected by a peer device:
Profile
APP GAPC L2CC
GAPC_LE_CREDIT_CON_CONNECT_CMD(LE_PSM, CID, Credit)
L2CC_SEND_REQ(SIG_LE_CREDIT_CHAN_CONNECTION_REQ
(LE_PSM, SRC_CID, Credit, MTU))
L2CC_RECV_IND (SIG_LE_CREDIT_CHAN_CONNECTION_RSP
(LE_PSM, DST_CID, Credit, MTU, REJECTED))
GAPC_CMP_EVT(reject status)
www.onsemi.com
165
RSL10 Firmware Reference
6.4.5.3 Disconnection
Profile
APP GAPC L2CC
GAPC_LE_CREDIT_CON_DISCONNECT_CMD(LE_PSM)
L2CC_SEND_REQ(SIG_DISCONNECT_REQ(DST_CID, SRC_CID))
L2CC_RECV_IND(SIG_DISCONNECT_RESP(DST_CID, SRC_CID))
L2CC_RECV_IND(SIG_DISCONNECT_REQ(SRC_CID, DST_CID))
Figure 146 shows how the LE credit based connection can be stopped from any device. When disconnection is
performed, the corresponding environment variables are free and no more data can be sent or received on this channel.
NOTE: Reason for disconnection is provided to the upper layer, such as:
• Packet transmission
www.onsemi.com
166
ON Semiconductor
When sending a packet, an L2CC Send procedure verifies with the GAPC module (using native functions)
whether there is still available credit on the destination device, and whether the negotiated MTU is not
exceeded. If not enough credit is available on the peer device, the packet is put into a wait queue until new
credit is provided for the peer CID. When the message is in the wait queue, L2CC can send other messages
(ATT, SIG, SMP, or other CID) to the peer. (See Figure 147, below.) When the full packet is transmitted, a
confirmation message is sent to the application with the status of transmission and number of credits used.
Until confirmation is sent, any message to send to the same CID will be rejected.
• Packet reception
When receiving a packet, the L2CC receive procedure verifies with the GAPC module (using native functions)
whether the CID is available. LE frame (segment) per LE frame, the number of local credits is decremented
(see Figure 148 on page 168). At end of the LE frame reception, a mechanism verifies (according to local
MPS) whether some credit can be automatically incremented. Condition: (total number of credits decremented)
< (data length received / MPS).
www.onsemi.com
167
RSL10 Firmware Reference
Between each LE Frame received, the L2CC task can receive messages for other channels (ATT, SMP, SIG or
other CID) Finally, the L2CC task informs the destination task (which registers the LE credit based channel)
that a packet has been received, and how many credits have been used.
www.onsemi.com
168
ON Semiconductor
• One of the devices can increase its local number of credits; when this is done, the peer device will be informed
that the credit number has been updated.
• When the peer device updates its credit count, the local device increases the destination credit count, and the
task that manages the LE credit based connection is informed about the number of relative credits added.
6.4.5.6 LE Ping
The LE ping feature is handled by the lower layers (see Figure 150 on page 170). The application can configure or
retrieve the authenticated payload timeout (10 ms step) through the GAP interface (see Figure 151 on page 170).
www.onsemi.com
169
RSL10 Firmware Reference
APP GAPC LL
GAPC_GET_INFO_CMD(GAPC_GET_LE_PING_TO)
HCI_Read_Authenticated_ Payload_Timeout(conhdl)
HCI_command_comnplete(Read_Authenticated_
GAPC_LE_PING_IND(timeout) Payload_Timeout, status, conhdl, timeout)
GAPC_CMP_EVT(GAPC_GET_LE_PING_TO, OK)
APP GAPC LL
HCI_event(Authenticated Payload Timeout Expired,
conhdl)
GAPC_LE_PING_TO_IND
Figure 151. Inform Application about LE Ping Authenticated Payload Timeout Expiration
When the Link size is updated, GAPC_LE_PKT_SIZE_IND is triggered. It does not change the fragmentation
mechanism in L2CAP since it preferentially uses the fragmentation mechanism provided by the lower layers.
• No authentication required
• Unauthenticated link required
• Authenticated link required
• Secure connection link required
www.onsemi.com
170
ON Semiconductor
The profile manages allocation of its task state array, and its environment memory (static and for each links). The
number of profile tasks managed by the generic access profile is managed by a compilation flag. An overview of a
profile task descriptor is shown in Figure 152.
NOTE: For integration purposes, the customer must allow this to be runtime configurable.
Figure 152. Overview of a Profile Task Descriptor in GAP Profile Task Array
NOTE: When all profile tasks has been affected, an application requesting to use another profile will
receive an Out Of Memory error.
To fix the profile API, instead of using a task number, a profile id (statically set) is used. This ID will be unique and
not be used by another task. Profile task registration is illustrated in Figure 153 on page 172.
www.onsemi.com
171
RSL10 Firmware Reference
APP GAPM
GAPM_PROFILE_TASK_ADD_CMD(PRF_ID, app_task)
Æcheck if a task can be registered
Client
For the GTL, in the GAP environment, a specific array is used to retrieve correspondence between the profile
identifier and the corresponding task id. GAP also provides a native API to retrieve the profile id from the task id, or the
task id from the profile id. When a profile is registered, it is natively informed about link establishment (to allocate
environment) and termination. An example of profile task registration is shown in Figure 154 on page 173.
NOTE: When the system is reset, all registered tasks are remove and profiles are cleaned up.
By default, profile task descriptors are initialized without any handler and without any task id. This ensures that
when a task is not registered, any message kernel to this task will be ignored.
NOTE: If GTL receives a message on a non-registered profile identifier, it will answer with a generic
error message.
www.onsemi.com
172
ON Semiconductor
When an application has to communicate with a profile task, it has to request its task identifier to GAP through its
native API.
CT PH BC/OB
(0x2A00) Device name m m x Name of the device in UTF-8 format (write
optional)
(0x2A01) Appearance m m x Representation of the LE device (write optional)
(0x2A04) Preferred conn par x o x Set of conn parameters preferred by the device
(0x2A06) Central Addr Resolution o o x Central Address Resolution characteristic defines
whether the device supports privacy with address
resolution
Those characteristics values are not present in the database. If a peer device tries to read or write those values, a
request will be sent to the application. It allows the application to manage the memory positions of those fields.
www.onsemi.com
173
RSL10 Firmware Reference
www.onsemi.com
174
ON Semiconductor
NOTE: The device can support all GAP roles (advertising, scanning, initiating and connected)
simultaneously, sharing use of the RF front-end between the different application use cases. For
example, this allows a device to be a master of one connection and a slave of a different
connection, or to start scanning and advertising activity at the same time.
www.onsemi.com
175
RSL10 Firmware Reference
• Device Privacy:
• Device IRK: used to generate random address (only valid for host Privacy 1.1)
• Privacy managed by host (privacy 1.1), by controller (privacy 1.2) or disabled
• Renew address timer duration
• Packet Size: Maximum MTU allowed by device (mini = 23 bytes, max = 2048)
• GAP DB configuration:
• GAP DB start handle (0x0000 – dynamically allocated)
• Appearance write permissions
• Device name write permissions + Device name max length
• Peripheral preferred connection parameters present + read permissions
• GATT DB Configuration:
• GATT DB start handle (0x0000 – dynamically allocated)
• Service changed characteristic present
NOTE: The set device configuration command recreates the GAP and GATT databases.
Bluetooth low energy profiles reside on top of the host protocols and generic profiles (GAP and GATT).
Support of an LE profile depends on its specification availability, from the Bluetooth Special Interest Group (SIG).
The FS of these profile implementations are beyond the scope of this document.
• Due to Bluetooth topology, client and server profiles are multi-instantiated tasks.
• Profiles have to manage environment memory by allocating it in an ATT Heap. Memory is used for dedicated
link and general configuration.
• If not enabled by GAP, the profile RAM footprint will equal zero.
• Service profile will be ready by default; enable message must be used to restore the bond data of a known
device.
• A profile is not aware of its task identifier, the in message handler; the destination id must be used to retrieve
its task identifier, or eventually request it to GAP through the native API.
www.onsemi.com
176
ON Semiconductor
• It is recommended to use the operation mechanism (see Section 6.4.8.2, “Operation Model” on page 178) to
optimize profile memory usage.
NOTE: Profile should be only on top of the GATT API. Management of connection and advertising data
should be handled by the application.
• The upper layer interface uses the API from the lower layer one (it is not allowed for a lower layer interface to
use an upper layer api).
• A request (_REQ suffix) or a command (_CMD suffix) from an API user needs to be answered by the task: a
command (_CMD suffix) is finished by sending a complete event (_CMP_EVT suffix) (see Figure 155), and a
request (_REQ suffix) is finished when a response message (_RSP suffix) is sent (see Figure 156).
USER TASK_XXX
XXX_???_CMD(op, params)
Procedure on-going
Put Task in busy
state
XXX_????_IND(info_data)
One message for
all commands
XXX_CMP_EVT(op, status) Please use
indication to
provide more
information
USER TASK_XXX
XXX_???_REQ(params)
Immediate request
Does not put task in
busy state
XXX_???_RSP(status, result)
A task can inform an upper layer task using an indication message (_IND suffix); or when information is needed by
a task, a request indication message (_REQ_IND suffix) can be raised and shall be answered using a confirmation
message (_CFM suffix) (see Figure 157).
www.onsemi.com
177
RSL10 Firmware Reference
USER TASK_XXX
XXX_???_REQ_IND(params)
Message that
require response XXX_???_CFM(result)
from upper layer
XXX_????_IND(info_data)
Message that just
inform upper layer
task
Figure 157. Message API use by a Task to Communicate with an Upper Layer
Bluetooth host software memory is optimized for allowing the system to shut down some memory blocks when
sleeping between Bluetooth events. This feature can be used thanks to the kernel memory heap segmentation.
www.onsemi.com
178
ON Semiconductor
www.onsemi.com
179
RSL10 Firmware Reference
www.onsemi.com
180
CHAPTER 7
7. Custom Protocols
7.1 OVERVIEW
In addition to standard RF protocol support, a number of custom protocols have been defined for the RSL10
ecosystem. These protocols are designed to handle use cases that are not typically easy to support using Bluetooth
low energy technology. These protocols are supported by header files, libraries, and sample applications that
demonstrate how the protocols can be used in a larger system.
For more information on this custom protocol, see Section 7.2, “Audio Stream Broadcast
Custom Protocol”.
Low-Latency
This is a custom transmission protocol that is used to establish a low-latency bidirectional
connection to provide transfers of data between two devices that contain the RSL10 SoC, with
the minium feasible delay.
For more information on this custom protocol, see Section 7.3, “Low-Latency Custom
Protocol”.
The audio stream broadcast custom protocol enables audio transmission that can carry either a mono or a stereo
audio stream to one or more devices. This protocol is supported by the firmware and sample code listed in Table 65.
www.onsemi.com
181
RSL10 Firmware Reference
The audio stream broadcast custom protocol uses a simple packet structure, which limits the additional packet
transmission information to a minimum beyond what is necessary to transmit the packet payload information. The
packet structure is shown in Figure 159, with information on the included components provided in Table 66.
Header
TransmissionID(2)
ChannelL/R(2)
Preamble(1)
Address(4)
Payload
RFU(4)
CRC(2)
www.onsemi.com
182
ON Semiconductor
For a typical stereo audio transfer, the packet set will consist of four packets:
The left or right channel can be selected through the audioChnl parameter.
If no data is available for the previous transmission interval (as would be the case at the beginning of a transfer), the
data packet for the current transmission interval is used in its place, to ensure consistency of the transmission structure.
To meet these somewhat conflicting requirements, the configuration described in Table 67 on page 184 is used for
this custom protocol.
www.onsemi.com
183
RSL10 Firmware Reference
Table 67. Physical Layer Configuration for THE AUDIO STREAM BROADCAST CUSTOM PROTOCOL
Channel Hop - Predefined hop sequences are used for transmissions and retransmissions, and can be
Sequence configured to ensure that all channels are used by this protocol, and all transmissions or
retransmissions of a given packet are widely spaced across the channel set.
For compatibility with Ezairo 7150 SL implementations, a hop sequence of 7 values is
used.
Whitening - Optional: If used, the whitened data includes the header, payload, and CRC information
of each packet.
Value
Parameter Notes
Transmission 10 ms The time interval between primary transmissions of packet sets; the start of the
Interval transmission interval for a packet set is defined as the synchronization point for the
packet set transmission.
Retransmission 5 ms The time interval between the start of a primary transmission of a packet set, and the
Interval start of the retransmission of that packet set.
Confirmation of link establishment or loss (disconnection) is provided to the application using a callback function.
Prior to transmission:
• Encoded audio data for each channel is placed into a packet (see Section Section 7.2.1, “Audio Stream
Broadcast Packet Structure”).
• Packets of data are collected with data from other channels and previous transfers, as a packet set (see Section
Section 7.2.2.1, “Packet Sets”).
Each packet set is transmitted at the synchronization point, and one retransmission interval later, as shown in the
example transmission sequence provided by Figure 160 on page 185. At the start of the next transmission interval, a
new packet set is created and the transmission process repeats. Each time a packet set is transmitted (including both at
the start of a transmission interval and at the retransmission interval), the channel used for the transmission is updated
www.onsemi.com
184
ON Semiconductor
with a fixed spacing between the transmission and retransmission, and a pre-defined channel hopping sequence is used
for each transmission interval (as described in Section 7.2.2.2, “RF Physical Layer Configuration”).
TransmissionInterval TransmissionInterval
Leftaudiodatafortimeinterval(n1) Rightaudiodatafortimeinterval(n1)
Leftaudiodatafortimeinterval(n) Rightaudiodatafortimeinterval(n)
Leftaudiodatafortimeinterval(n+1) Rightaudiodatafortimeinterval(n+1)
Leftaudiodatafortimeinterval(n+2) Rightaudiodatafortimeinterval(n+2)
To maintain an audio stream, the receiver needs to listen only to those events necessary to obtain a complete set of
data for its channel.
Figure 161 on page 185 shows an example of the receiver behavior when trying to receive one packet. In this
example, the receiver is attempting to receive data for the left channel, and fails to receive data for transmission interval
(n) in both transmission slots of transmission interval (n). This data is then received in transmission interval (n + 1),
along with the data for transmission interval (n+1). The receiver does not listen for more data during the retransmission
interval, and only listens for the data for the (n + 2) interval in the subsequent interval. In this way, the receiver only
listens when new data for its channel is available.
X X
TransmissionInterval
Leftaudiodatafortimeinterval(n)
Leftaudiodatafortimeinterval(n+1)
Leftaudiodatafortimeinterval(n+2)
www.onsemi.com
185
RSL10 Firmware Reference
Only after all four potential transmissions have completed can the device then render its audio data. If this data is
available earlier, it needs to be held back, to maintain consistent timing. When rendering stereo data, the receiving
device also delays its rendering point, so that this point occurs after all packets from the last packet set containing a
given packet have been retransmitted, as shown in Figure 160 on page 185.
The library provides audio data using a rendering delay. This delay timing can be changed using the renderDelay
parameter. The library will automatically adjust the rendering time for the left and right microphones; the application is
not responsible for this. Rendering delay timing allows the left and right microphones to deliver audio data to the
application simultaneously. The time difference between left and right is taken into account in the protocol
implementation.
The library will deliver audio data to the application through a callback function, which also provides the status of
the date.The application has no need to consider timing when no packet is received, because the protocol retains the
timing. At rendering time, the protocol provides one of three different status results for the packet: good packet, bad
CRC packet, or no packet (timeout). Then the application can decide if it wants to use any of the PLC algorithms.
This reference material presents a detailed description of all the external API functions in the audio stream
broadcast custom protocol library (see Table 69), including calling parameters, returned values, and assumptions.
7.2.3.1 RM_Configure
Configure protocol environment based on input from application
Type Function
Include File #include <rm_pkt.h>
Source File rm_event.c
Template uint8_t RM_Configure(struct rm_param_tag param, struct rm_callback
callback)
Description Configure protocol environment based on input from application
Inputs param = Application input parameters
callback = Application call back functions
Outputs return value = 0 if it configures successfully, error value otherwise
www.onsemi.com
186
ON Semiconductor
Assumptions None
Example struct app_env_tag app_env;
struct rm_callback callback;
7.2.3.2 RM_Disable
Disable the protocol
Type Function
Include File #include <rm_pkt.h>
Source File rm_event.c
Template uint8_t RM_Disable(void)
Description Disable the protocol
Inputs None
Outputs return value = 0 if it disables successfully, error value otherwise
Assumptions None
Example /* Disable the custom protocol */
RM_Disable();
7.2.3.3 RM_Enable
Enable the protocol
Type Function
Include File #include <rm_pkt.h>
Source File rm_event.c
Template uint8_t RM_Enable(uint16_t offset)
Description Enable the protocol
Inputs offset = Offset instant in micro second
Outputs return value = 0 if it enables successfully, error value otherwise
Assumptions None
Example /* Configure and enable the custom protocol for use by the application */
RM_Configure(&app_env.cp_param, callback);
RM_Enable(500);
7.2.3.4 RM_EventHandler
Protocol event handler
Type Function
Include File #include <rm_pkt.h>
www.onsemi.com
187
RSL10 Firmware Reference
7.2.3.5 RM_StatusHandler
Protocol status update handler
Type Function
Include File #include <rm_pkt.h>
Source File rm_event.c
Template void RM_StatusHandler(void)
Description Protocol status update handler
Inputs None
Outputs None
Assumptions None
Example /* Main loop: Handle custom protocol events */
while (1)
{
Sys_Watchdog_Refresh();
RM_StatusHandler();
SYS_WAIT_FOR_EVENT;
}
The low-latency custom protocol provides a minimum latency bidirectional connection between two devices based
on the RSL10 SoC. This protocol provides a means for point-to-point audio streaming. The protocol’s main use cases
include, but are not limited to, the following:
The low-latency custom protocol also demonstrates the use of the RSL10 RF front end, making it easier for users to
create and implement their own individual protocols.
All parameters of the protocol are configured through APIs. The target has the lowest possible delay, and the
flushable protocol cannot guarantee data transmission between points, as data that cannot be transmitted in the desired
window is simply discarded. This differs from Bluetooth low energy technology, which guarantees the arrival of all
data. In addition to ensuring that only data that is still relevant is received, transmitting audio data through the
www.onsemi.com
188
ON Semiconductor
low-latency custom protocol instead of Bluetooth low energy ensures that the data remains time synchronized between
the two sides of the link. This significantly simplifies synchronization between data sample across multiple devices.
This symmetric protocol is supported by the firmware and sample code listed in Table 70.
The Low-Latency custom protocol is designed to use the RF characteristics already qualified for use on the RSL10
device with Bluetooth low energy technologies, with some flexibility provided to enable users to meet a variety of use
cases. The physical layer configuration for this protocol is described in Table 71.
Table 71. Physical Layer Configuration for the Low Latency Custom Protocol
Channel Hop - During data transmission, frequency hopping is used, with the number and list of
Sequence channels determined through the provided API. There are two frequency hopping lists:
one for the main transmissions, and one for re-transmissions.
In addition, the connection establishment phase and the connected phase have different
frequency hopping lists, as explained in Section 7.3.3, “Low-Latency Protocol Link Layer
Structure” on page 190.
Preamble (1 octet) Sync word (4 octets) Header (2 octets) Data (variable) CRC (2 octets)
www.onsemi.com
189
RSL10 Firmware Reference
Since the main purpose of this protocol is transmitting audio with low latency, data in the sample code is a
coded audio frame (for example, 16 octets per 2 ms of data at a 64 Kbps coding rate). This audio data can be
replaced as needed by control data, signaled using the one-bit Data bit-field in the header.
• CRC: 2 octets. CRC-CCITT is calculated over the header and data sections of the low-latency protocol packet.
The two peer devices that communicate using this protocol are the master and slave devices. The master device
sends data/audio packets in consecutive transmission intervals, while the channel frequency changes for each interval.
Once the slave receives the master’s audio/data packet, the slave sends back an acknowledgment packet at the same
channel frequency. If the master device does not receive the acknowledgement as expected, the master retransmits the
payload on another frequency channel. Figure 162 illustrates this mechanism.
The low-latency custom protocol uses two sets, each with two lists of frequencies, for controlling the frequency
hopping configuration. In each set, one list is used to select the frequency for the main transmissions, and the second is
used for re-transmissions. The first set includes two lists of four frequencies each, which are used during link
establishment. The second set includes two lists of up to a maximum of 36 frequency channels, which are used while
streaming data.
At the beginning of link establishment, the master device sends packets via channels present on the first list of the
first set, and increments the frequency hop number at every connection interval. During each connection interval
following the main transmission, after a pre-defined inter frame space (IFS), the master device waits to receive an
acknowledgement from the slave device at the same frequency. If no acknowledgement is received after the IFS, the
www.onsemi.com
190
ON Semiconductor
main transmission packet will be sent again, on the same channel index but from the re-transmission list. The master
device continues sending the transmission, cycling through the 8 channels from the transmission and retransmission
lists, and as long as it does not receive any response from the slave device, it repeats the same sequence.
The frequency hop counter is sent in the packet header. Once the slave device receives it, the hop counter sequence
enables the slave device to synchronize with the master device. When the master receives the acknowledgment from the
slave device, it stops transmitting using the first set of channels, and switches to the second set of transmission lists to
send packets (and re-transmit packets) using entries from lists in the second channel frequency set.
While sending data packets, two pre-configured frequency hopping algorithms can be selected. These can be for
either circular or pseudo-random frequency hopping. Since retransmission happens on a different frequency from initial
transmission, the effects of interference and fading are mitigated.
The intent behind this two-stage frequency hopping list is that this scheme makes link establishment faster, and
lowers power consumption, because the receiver has no need to deal with a long channel frequency list.
The low-latency custom protocol is implemented in a static library that can be linked to any application. The
interface between the library and the application is handled through the following steps:
1. Protocol configuration: At the beginning, the application provides the desired parameters to configure the
protocol (library). The application can change the following parameters:
• Protocol role: master or slave
• Mono-directional or bidirectional (currently only mono-directional is supported)
• Four frequency lists for the first and second phases of connection, including main transmission and
retransmission. The first list of the first phase, which can have a maximum of four channels, cannot have
any common channel with the other three lists.
• Frequency hopping step size and hopping algorithm (either the circular or the pseudo- random method can
be selected, but because of timing stability issues, the circular method is suggested)
• Transmission interval
• Radio data rate
• Audio data rate
• Access word and preamble
• Link management parameters (packet lost low and high thresholds)
• Status update callback function (at any change in the link status, the allocated callback function is called)
• Event handling callback function
2. Protocol-application interface: when the protocol needs to obtain data from the application for transmission,
the regarding callback function is called. Once data is received, the registered callback function is called. The
application can be informed of data packet reception through three events: main transmission, re-transmission,
and unsuccessful transmission (timeout). Being informed of data packet reception enables the application to
assess the link. In the case of timeout, the application can call any PLC (packet loss concealment) algorithm, or
receive the previous packet. On the master side, once the protocol requests data from the application for
transmission, the application is responsible for managing its timing to synchronize with the activity of the
radio.
For sampling clock synchronization, the required signals for the audio sink clock counter are generated in the
protocol library, and based on the phase and period interrupts. On the master side, these interrupts can be used
for sampling clock calculations based on the radio frame sync, The application can leverage this to synchronize
its audio peripheral interface, sampling rate converter, and encoding timing.
www.onsemi.com
191
RSL10 Firmware Reference
On the slave side, these interrupts and signals can be used in the same way. Additionally, once a phase interrupt
occurs, a rendering timer can run such that audio is rendered after its expiry. Rendering time needs to be
configured in free run mode, and can be re-synchronized with the ASCC phase interrupt anytime it occurs. In
the case of a missed signal (timeout, retransmission), it continues rendering based on the receiver clock.
The low-latency custom protocol library uses several system blocks as part of the protocol implementation. For
proper system functionality, the user cannot use these blocks elsewhere in their application when the low-latency
custom protocol is active without potentially disrupting the low-latency custom protocol. These blocks include:
• The RF front end module, which prevents the Bluetooth low energy BB (HW) from accessing the RF front end.
The radio block works in the RF front-end’s packet handling mode.
• Two of the general purpose timers (timers 0, 1).
This reference material presents a detailed description of all the external API functions in the low-latency custom
protocol library, including calling parameters, returned values, and assumptions.
7.3.6.1 CP_Configure
Configure protocol environment based on input from application
Type Function
Include File #include <cp_pkt.h>
Source File cp_event.c
Template uint8_t CP_Configure(struct cp_param_tag param, struct cp_callback
callback)
Description Configure protocol environment based on input from application
Inputs param = Application input parameters
callback = Application call back functions
Outputs return value = 0 if it configures successfully, error value otherwise
www.onsemi.com
192
ON Semiconductor
Assumptions None
Example struct app_env_tag app_env;
struct cp_callback callback;
7.3.6.2 CP_Disable
Disable the protocol
Type Function
Include File #include <cp_pkt.h>
Source File cp_event.c
Template uint8_t CP_Disable(void)
Description Disable the protocol
Inputs None
Outputs return value = 0 if it disables successfully, error value otherwise
Assumptions None
Example /* Disable the custom protocol */
CP_Disable();
7.3.6.3 CP_Enable
Enable the protocol
Type Function
Include File #include <cp_pkt.h>
Source File cp_event.c
Template uint8_t CP_Enable(uint16_t offset)
Description Enable the protocol
Inputs offset = Offset instant in micro second
Outputs return value = 0 if it enables successfully, error value otherwise
Assumptions None
Example /* Configure and enable the custom protocol for application use */
CP_Configure(&app_env.cp_param, callback);
CP_Enable(500);
7.3.6.4 CP_EventHandler
Protocol event handler
Type Function
Include File #include <cp_pkt.h>
www.onsemi.com
193
RSL10 Firmware Reference
www.onsemi.com
194
CHAPTER 8
8. CMSIS Implementation Library Reference
This reference chapter presents a description of the functions implemented in the standards-compliant CMSIS
library. This includes calling parameters, returned values, and assumptions.
8.1 SYSTEMCORECLOCKUPDATE
Type Function
Include File #include <rsl10.h>
Source File system_rsl10.c
Template void SystemCoreClockUpdate(void)
Description Updates the variable SystemCoreClock and the FLASH_DELAY_CTRL register. This function must be called
whenever the core clock is changed during program execution.
Inputs None
Outputs None
Assumptions It is safe to treat undefined clock configurations as if they are sourced from the RC oscillator.
EXTCLK and JTCK should be scaled from their maximum frequencies.
It is safe to assume a STANDBYCLK frequency of 32768 Hz
Example /* Switch the system clock source to RF clock (clearing the
* EXTCLK/JTCK divisors), and refresh the system core clock
* variable. */
Sys_Clocks_SystemClkConfig(SYSCLK_CLKSRC_RFCLK);
SystemCoreClockUpdate();
www.onsemi.com
195
RSL10 Firmware Reference
8.2 SYSTEMINIT
Setup the system core clock variable; assumes the ROM has previously initialized the system
Type Function
Include File #include <rsl10.h>
Source File system_rsl10.c
Template SystemInit
Description Setup the system core clock variable; assumes the ROM has previously initialized the system.
Inputs None
Outputs None
Assumptions None
Example /* Initialize the system */
SystemInit();
www.onsemi.com
196
CHAPTER 9
9. System Library Reference
This reference chapter presents a detailed description of all the macros, functions and inline functions defined in
the ARM® Cortex®-M3 processor's system library. For each macro, function or inline function, it describes calling
parameters, modified registers, and returned values.
9.1 SYS_ADC_CLEAR_BATMONSTATUS
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_adc.h
Template void Sys_ADC_Clear_BATMONStatus(void)
Description Clear the battery monitor status
Inputs None
Outputs None
Assumptions None
Example /* Clear ADC new sample ready, overrun condition and battery
* monitoring alarm status. */
Sys_ADC_Clear_BATMONStatus();
www.onsemi.com
197
RSL10 Firmware Reference
9.2 SYS_ADC_GET_BATMONSTATUS
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_adc.h
Template uint32_t Sys_ADC_Get_BATMONStatus(void)
Description Get the battery monitor status
Inputs None
Outputs return value = Current ADC_BATMON_STATUS status; compare with
BATMON_ALARM_[FALSE | TRUE], ADC_OVERRUN_[FALSE | TRUE], and
ADC_READY_[FALSE | TRUE]
Assumptions None
Example /* Read status of ADC and battery monitoring alarm. */
status = Sys_ADC_Get_BATMONStatus();
www.onsemi.com
198
ON Semiconductor
9.3 SYS_ADC_GET_CONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_adc.h
Template uint32_t Sys_ADC_Get_Config(void)
Description Get the control register values from ADC_CFG
Inputs None
Outputs return value = Current ADC control setting; compare with ADC_VBAT_DIV2_[NORMAL |
DUTY], ADC_[NORMAL | CONTINUOUS], and ADC_[DISABLE |
PRESCALE_*]
Assumptions None
Example /* ADC configuration is read. */
status = Sys_ADC_Get_Config();
www.onsemi.com
199
RSL10 Firmware Reference
9.4 SYS_ADC_INPUTSELECTCONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_adc.h
Template void Sys_ADC_InputSelectConfig(uint32_t num, uint32_t cfg)
Description Configure the input selection for an ADC channel
Inputs num = Channel number; use [0 to 7]
cfg = Input selection configuration; use ADC_POS_INPUT_* | ADC_NEG_INPUT_*
Outputs None
Assumptions None
Example /* Configure the input selection of ADC. */
Sys_ADC_InputSelectConfig(0, ADC_POS_INPUT_DIO1);
www.onsemi.com
200
ON Semiconductor
9.5 SYS_ADC_SET_BATMONCONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_adc.h
Template void Sys_ADC_Set_BATMONConfig(uint32_t cfg)
Description Set the battery monitor configuration.
Inputs cfg = ADC_BATMON configuration; use BATMON_ALARM_[NONE | COUNT1 |
COUNT255] or other values shifted to
ADC_BATMON_CFG_ALARM_COUNT_VALUE_Pos,
SUPPLY_THRESHOLD_[LOW | MID | HIGH] or other values shifted to
ADC_BATMON_CFG_SUPPLY_THRESHOLD_Pos, and BATMON_CH[6 | 7]
Outputs None
Assumptions None
Example /* Configure the battery monitoring alarm count value to 1 and low
* voltage threshold to 1V and monitor channel 6. */
Sys_ADC_Set_BATMONConfig(BATMON_ALARM_COUNT1 |
SUPPLY_THRESHOLD_MID |
BATMON_CH6);
www.onsemi.com
201
RSL10 Firmware Reference
9.6 SYS_ADC_SET_BATMONINTCONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_adc.h
Template void Sys_ADC_Set_BATMONIntConfig(uint32_t cfg)
Description Set the battery monitor interrupt configuration
Inputs cfg = ADC_BATMON_INT_ENABLE configuration; use INT_[DIS | EBL]_ADC
ADC_INT_CH*, and INT_[DIS | EBL]_BATMON_ALARM,
Outputs None
Assumptions None
Example /* Enable the ADC and BATMON alarm interrupts assigning channel
* number 6 to trigger the ADC interrupt. */
Sys_ADC_Set_BATMONIntConfig(INT_EBL_ADC |
ADC_INT_CH6 |
INT_EBL_BATMON_ALARM);
www.onsemi.com
202
ON Semiconductor
9.7 SYS_ADC_SET_CONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_adc.h
Template void Sys_ADC_Set_Config(uint32_t cfg)
Description Set the ADC configuration
Inputs cfg = The ADC configuration; use ADC_VBAT_DIV2_[NORMAL | DUTY],
ADC_[NORMAL | CONTINUOUS], and ADC_[DISABLE | PRESCALE_*]
Outputs None
Assumptions None
Example /* Configure ADC to normal mode VBAT dividing and sample the 8
* channels in rate of 200Hz*/
Sys_ADC_Set_Config(ADC_VBAT_DIV2_DUTY |
ADC_NORMAL |
ADC_PRESCALE_800);
www.onsemi.com
203
RSL10 Firmware Reference
9.8 SYS_AES_CIPHER
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_aes.h
Template void Sys_AES_Cipher(void)
Description Run AES-128 cipher engine
Inputs None
Outputs None
www.onsemi.com
204
ON Semiconductor
Assumptions The baseband block should be enabled. Sys_AES_CiphConfig() has been called.
Example /*
Key (16-octet value MSO to LSO):
0x4C68384139F574D836BCF34E9DFB01BF
Plaintext_Data (16-octet value MSO to LSO):
0x0213243546576879ACBDCEDFE0F10213
Encrypted_Data (16-octet value MSO to LSO):
0x99AD1B5226A37E3E058E3B8E27C2C666
*/
/* Plain-text data */
uint32_t plaintext[4] = {
0XE0F10213,
0XACBDCEDF,
0X46576879,
0X02132435
};
uint32_t key[4] = {
0x9DFB01BF,
0x36BCF34E,
0x39F574D8,
0x4C683841,
};
/* Configure the AES-128 engine for ciphering with the key and the memory
* zone */
Sys_AES_Config (key, EM_BLE_ENC_PLAIN_OFFSET);
www.onsemi.com
205
RSL10 Firmware Reference
9.9 SYS_AES_CONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_aes.h
Template void Sys_AES_Config(uint32_t * key, uint32_t mem_zone)
Description Configure AES-128 engine for a ciphering method
Inputs key = Pointer to AES encryption 128-bit key
mem_zone = Memory offset from the top of the exchange memory; points to a 32-byte array
consisting of the 16-byte plain-text input, followed by the 16-byte cipher-text
output
Outputs None
Assumptions The baseband block should be enabled.
Example /* Configure the AES-128 engine for ciphering with the key and the memory
* zone */
Sys_AES_Config (key, EM_BLE_ENC_PLAIN_OFFSET);
/* Access to the cipher-text at EM_BLE_ENC_CIPHER_OFFSET address */
www.onsemi.com
206
ON Semiconductor
9.10 SYS_ASRC_CALCPHASECNT
Calculate the phase increment value according to the mode and the input frequencies
Type Macro
Include File #include <rsl10.h>
Source File rsl10_sys_asrc.h
Template Sys_ASRC_CalcPhaseCnt(mode, f_src, f_sink)
Description Calculate the phase increment value according to the mode and the input frequencies
Inputs mode = Configuration of the ASRC mode value; use ASRC_INT_MODE |
ASRC_DEC_MODE*
f_src = Source frequency or source sample number
f_sink = Sink frequency or sink sample number
Outputs return value = The phase increment value
Assumptions None
Example /* Calculate the phase increment value when f_src = 4 kHz and
* f_sink = 16 kHz are in mode 0. */
result = Sys_ASRC_CalcPhaseCnt(ASRC_INT_MODE, 4, 16);
www.onsemi.com
207
RSL10 Firmware Reference
9.11 SYS_ASRC_CHECKINPUTCONFIG
Check that the input frequencies or sample numbers are valid in the range depending on the selected mode
Type Macro
Include File #include <rsl10.h>
Source File rsl10_sys_asrc.h
Template Sys_ASRC_CheckInputConfig(mode, f_src, f_sink)
Description Check that the input frequencies or sample numbers are valid in the range depending on the selected mode
Inputs mode = Configuration of the mode value; use ASRC_INT_MODE |
ASRC_DEC_MODE*
f_src = Source frequency or source sample number
f_sink = Sink frequency or sink sample number
Outputs return value = 0 if frequency range check failed; 1 otherwise
Assumptions None
Example /* Check if f_sink = 16 kHz and f_src = 4 kHz are valid pair of
* frequencies in mode 0. */
result = Sys_ASRC_CheckInputConfig(ASRC_INT_MODE, 4, 16);
www.onsemi.com
208
ON Semiconductor
9.12 SYS_ASRC_CONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_asrc.h
Template void Sys_ASRC_Config(uint32_t phase_inc, uint32_t cfg)
Description Configure the ASRC block
Inputs phase_inc = The phase increment value
cfg = The WDF type and ASRC mode; use ASRC_[INT_MODE | DEC_MODE*], and
[LOW_DELAY | WIDE_BAND]
Outputs None
Assumptions None
Example /* Configure ASRC block for f_sink = 7 kHz and f_src = 16 kHz in
* mode = 3. Coefficient setting for WDF1 is for wide band
* response. */
Sys_ASRC_Config(0x2492792, ASRC_DEC_MODE3 | WIDE_BAND);
www.onsemi.com
209
RSL10 Firmware Reference
9.13 SYS_ASRC_CONFIGRUNTIME
Configure the phase increment value according to the WDF selection and the input frequencies
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_asrc.c
Template void Sys_ASRC_ConfigRunTime(uint32_t cfg, uint32_t f_src, uint32_t
f_sink)
Description Configure the phase increment value according to the WDF selection and the input frequencies. The mode is
calculated automatically.
Inputs cfg = The WDF type and the ASRC mode; use [LOW_DELAY | WIDE_BAND],
[ASRC_INT_MODE | ASRC_DEC_MODE*]
f_src = Source frequency or source sample number
f_sink = Sink frequency or sink sample number
diff_bit = Number of shifts on the numerator of the ASRC formula after the subtraction of
(f_src) and (x*f_sink). It must be calculated by the user to prevent overflow and
have the maximum precision
Outputs None
Assumptions The ASRC mode must be selected according to f_src and f_sink mode == ASRC_INT_MODE where (f_sink >
f_src) mode == ASRC_DEC_MODE1 where (f_sink < f_src * 1.20 && f_sink > f_src * 0.8) mode ==
ASRC_DEC_MODE2 where (f_sink > f_src * 0.4 && f_sink < f_src)) mode == ASRC_DEC_MODE2 where
f_sink < f_src * 0.4
Example /* Configure the ASRC block to convert 16 kHz sample rate to
* 16.12 kHz at run time. Zero bit shift is performed*/
Sys_ASRC_ConfigRunTime(ASRC_INT_MODE | WIDE_BAND, 16000, 16120, 0);
www.onsemi.com
210
ON Semiconductor
9.14 SYS_ASRC_ENABLE
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_asrc.h
Template void Sys_ASRC_Enable(uint32_t cfg)
Description Enable or disable the ASRC block
Inputs cfg = Enable or disable the ASRC block; use ASRC_[DISABLE | ENABLE]_BITBAND
Outputs None
Assumptions None
Example /* Enable ASRC block. */
Sys_ASRC_Enable(ASRC_ENABLE_BITBAND);
www.onsemi.com
211
RSL10 Firmware Reference
9.15 SYS_ASRC_INPUTDATA
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_asrc.h
Template void Sys_ASRC_InputData(uint16_t data)
Description Send a sample to the ASRC block
Inputs data = Value of the input sample
Outputs None
Assumptions None
Example /* Send 0xAA as sample in the ASRC block. */
Sys_ASRC_InputData (0xAA);
www.onsemi.com
212
ON Semiconductor
9.16 SYS_ASRC_INTENABLECONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_asrc.h
Template void Sys_ASRC_IntEnableConfig(uint32_t cfg)
Description Configure the interrupt enable register of the ASRC block
Inputs cfg = Interrupt register value; use INT_EBL_ASRC_IN, INT_EBL_ASRC_OUT,
INT_EBL_ASRC_IN_ERR, and INT_EBL_ASRC_UPDATE_ERR
Outputs None
Assumptions None
Example /* Enable asrc_in and asrc_out interrupts. */
Sys_ASRC_IntEnableConfig(INT_EBL_ASRC_IN |
INT_EBL_ASRC_OUT);
www.onsemi.com
213
RSL10 Firmware Reference
9.17 SYS_ASRC_OUTPUTCOUNT
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_asrc.h
Template uint32_t Sys_ASRC_OutputCount(void)
Description Read the ASRC output counter value
Inputs None
Outputs return value = The output counter value
Assumptions None
Example /* Read the number of output samples. */
result = Sys_ASRC_OutputCount();
www.onsemi.com
214
ON Semiconductor
9.18 SYS_ASRC_OUTPUTDATA
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_asrc.h
Template uint16_t Sys_ASRC_OutputData(void)
Description Read a sample from the ASRC block
Inputs None
Outputs return value = The output value of the block
Assumptions None
Example /* Read sample out of the ASRC block. */
result = Sys_ASRC_OutputData();
www.onsemi.com
215
RSL10 Firmware Reference
9.19 SYS_ASRC_PHASEINCCONFIG
Type Macro
Include File #include <rsl10.h>
Source File rsl10_sys_asrc.h
Template Sys_ASRC_PhaseIncConfig(mode, f_src, f_sink)
Description Calculate the phase increment value in m8p24
Inputs mode = Configuration value; use ASRC_INT_MODE | ASRC_DEC_MODE*
f_src = Source frequency or source samples
f_sink = Sink frequency or sink samples
Outputs return value = 0 if frequency range check failed; otherwise return the phase increment value
Assumptions None
Example /* Calculate the phase increment value when f_src = 4 kHz and
* f_sink = 16 kHz are in mode 0. */
result = Sys_ASRC_PhaseIncConfig(ASRC_INT_MODE, 4, 16);
www.onsemi.com
216
ON Semiconductor
9.20 SYS_ASRC_RESET
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_asrc.h
Template void Sys_ASRC_Reset(void)
Description Reset the ASRC block
Inputs None
Outputs None
Assumptions None
Example /* Reset the ASRC block. */
Sys_ASRC_Reset();
www.onsemi.com
217
RSL10 Firmware Reference
9.21 SYS_ASRC_RESETOUTPUTCOUNT
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_asrc.h
Template void Sys_ASRC_ResetOutputCount(void)
Description Reset the ASRC block output counter
Inputs None
Outputs None
Assumptions None
Example /* Reset the ASRC output counter. */
Sys_ASRC_ResetOutputCount();
www.onsemi.com
218
ON Semiconductor
9.22 SYS_ASRC_STATUS
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_asrc.h
Template uint32_t Sys_ASRC_Status(void)
Description Read status of the ASRC block
Inputs None
Outputs return value = The value of the ASRC_CTRL register
Assumptions None
Example /* Read status of the ASRC block. */
result = Sys_ASRC_Status();
www.onsemi.com
219
RSL10 Firmware Reference
9.23 SYS_ASRC_STATUSCONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_asrc.h
Template void Sys_ASRC_StatusConfig(uint32_t cfg)
Description Configure the status of the ASRC block
Inputs cfg = The value of the ASRC_CTRL register
Outputs None
Assumptions None
Example /* Reset the ASRC block. */
Sys_ASRC_StatusConfig(ASRC_RESET);
www.onsemi.com
220
ON Semiconductor
9.24 SYS_AUDIO_DMICDIOCONFIG
Configure two DIOs for the specified DMIC data input selection
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_audio.h
Template void Sys_Audio_DMICDIOConfig(uint32_t cfg, uint32_t clk, uint32_t data,
uint32_t clk_ext)
Description Configure two DIOs for the specified DMIC data input selection
Inputs cfg = DIO pin configuration for the DMIC input
clk = DIO to use as the DMIC clock out pad
data = DIO to use as the DMIC input pad
clk_ext = Clock source for external clock on DMIC clock pad; use
DIO_MODE_[AUDIOCLK | AUDIOSLOWCLK]
Outputs None
Assumptions None
Example /* Configure DIOs 1 and 4 as the DMIC interface. */
Sys_Audio_DMICDIOConfig(APP_DIO_CFG, 1, 4, DIO_MODE_AUDIOCLK);
www.onsemi.com
221
RSL10 Firmware Reference
9.25 SYS_AUDIO_ODDIOCONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_audio.h
Template void Sys_Audio_ODDIOConfig(uint32_t cfg, uint32_t od_p, uint32_t od_n)
Description Configure two DIOs for the specified OD data output selection
Inputs cfg = DIO pin configuration for the OD outputs
od_p = DIO to use as the OD positive pin
od_n = DIO to use as the OD negative pin
Outputs None
Assumptions None
Example /* Configure pin 0 as OD positive and 1 as OD negative. */
Sys_Audio_ODDIOConfig(DIO_NO_PULL, 0, 1);
www.onsemi.com
222
ON Semiconductor
9.26 SYS_AUDIO_ODDIOCONFIGMULT
Configure multiple sets of DIOs for the specified OD data output selection
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_audio.c
Template void Sys_Audio_ODDIOConfigMult(uint32_t cfg, uint32_t * od_p, uint32_t *
od_n, uint32_t num)
Description Configure multiple sets of DIOs for the specified OD data output selection
Inputs cfg = DIO pin configuration for the OD outputs
od_p = Pointer to the DIOs array to use as the OD positive pins
od_n = Pointer to the DIOs array to use as the OD negative pins
num = Number of pairs of DIO pins used for the OD
Outputs None
Assumptions The arrays od_p and od_n are the same length
Example /* Configure 3 pins as OD positive and 3 others as OD negative. */
#define NUM_OD_DIO 3
www.onsemi.com
223
RSL10 Firmware Reference
9.27 SYS_AUDIO_SET_CONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_audio.h
Template void Sys_Audio_Set_Config(uint32_t cfg)
Description Configure the audio block
Inputs cfg = The DMIC and OD configuration values; use OD_[AUDIOCLK |
AUDIOSLOWCLK], DMIC_[AUDIOCLK | AUDIOSLOWCLK],
DECIMATE_BY_*_BYTE, OD_UNDERRUN_PROTECT_[ENABLE |
DISABLE], OD_DMA_REQ_[ENABLE | DISABLE], OD_INT_GEN_[ENABLE |
DISABLE], OD_DATA_[LSB | MSB]_ALIGNED, OD_[ENABLE | DISABLE],
DMIC*_DMA_REQ_[ENABLE | DISABLE], DMIC*_INT_GEN_[ENABLE |
DISABLE], DMIC*_DATA_[LSB | MSB]_ALIGNED, and DMIC*_[ENABLE |
DISABLE]
Outputs None
Assumptions None
Example /* Enable OD with LSB aligned setting. */
Sys_Audio_Set_Config(OD_ENABLE | OD_DATA_LSB_ALIGNED);
www.onsemi.com
224
ON Semiconductor
9.28 SYS_AUDIO_SET_DMICCONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_audio.h
Template void Sys_Audio_Set_DMICConfig(uint32_t cfg, uint32_t frac_delay)
Description Configure the DMIC
Inputs cfg = The DMIC configuration; use DMIC*_DCRM_CUTOFF_[*HZ | DISABLE],
DMIC1_DELAY_[*P* | DISABLE], and DMIC*_[FALLING | RISING]_EDGE
frac_delay = DMIC1 fractional delay; use a 5- bit number
Outputs None
Assumptions None
Example /* Enable DMIC0 for a 5 Hz cutoff removal frequency and decimation
* rate of 64, sampled on the falling edge of the input clock */
Sys_Audio_Set_DMICConfig(DMIC0_DCRM_CUTOFF_5HZ |
DECIMATE_BY_64 |
DMIC0_FALLING_EDGE |
DMIC0_ENABLE,
0);
www.onsemi.com
225
RSL10 Firmware Reference
9.29 SYS_AUDIO_SET_ODCONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_audio.h
Template void Sys_Audio_Set_ODConfig(uint32_t cfg)
Description Configure the OD block and sigma-delta modulator for normal operation
Inputs cfg = The OD configuration; use DCRM_CUTOFF_[*HZ | DISABLE],
DITHER_[ENABLE | DISABLE], and OD_[RISING | FALLING]_EDGE
Outputs None
Assumptions None
Example /* Configure OD to enable dithering, DC removal with a 10 Hz cut off
* frequency and output data clock edge on rising. */
Sys_Audio_Set_ODConfig (DCRM_CUTOFF_10HZ |
DITHER_ENABLE |
OD_RISING_EDGE);
www.onsemi.com
226
ON Semiconductor
9.30 SYS_AUDIOSINK_CONFIG
Configure the audio sink block and set values for clock counter, clock phase counter and clock period counter
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_audiosink.h
Template void Sys_Audiosink_Config(uint32_t cfg, uint32_t phasecnt, uint32_t
periodcnt)
Description Configure the audio sink block and set values for clock counter, clock phase counter and clock period counter
Inputs cfg = The number of the audio sink Clock periods over which the period counter
measures; use AUDIO_SINK_PERIODS_*
phasecnt = The sink clock phase counter initial value
periodcnt = The sink clock period counter initial value
Outputs None
Assumptions None
Example /* Measure 1 audio sink clock period. The initial value for the phase
* and period counter is 0. */
Sys_Audiosink_Config(AUDIO_SINK_PERIODS_1, 0, 0);
www.onsemi.com
227
RSL10 Firmware Reference
9.31 SYS_AUDIOSINK_COUNTER
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_audiosink.h
Template uint32_t Sys_Audiosink_Counter(void)
Description Read the value of the audio sink Clock counter
Inputs None
Outputs return value = The current value of the audio sink Clock counter
Assumptions None
Example /* Read audio sink clock counter value. */
result = Sys_Audiosink_Counter();
www.onsemi.com
228
ON Semiconductor
9.32 SYS_AUDIOSINK_INPUTCLOCK
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_audiosink.h
Template void Sys_Audiosink_InputClock(uint32_t cfg, uint32_t sink)
Description Configure a source for the audio sink input
Inputs cfg = DIO pin configuration for the audio sink input
sink = Source to use as the audio sink input pad; use AUDIOSINK_CLK_SRC_DIO_*,
AUDIOSINK_CLK_SRC_CONST_[LOW | HIGH], or
AUDIOSINK_CLK_SRC_[STANDBYCLK | DMIC_OD]
Outputs None
Assumptions None
Example /* Configure DIO 0 as Audio Sink pad. */
Sys_Audiosink_InputClock(APP_DIO_CFG, AUDIOSINK_CLK_SRC_DIO_0);
www.onsemi.com
229
RSL10 Firmware Reference
9.33 SYS_AUDIOSINK_PERIODCOUNTER
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_audiosink.h
Template uint32_t Sys_Audiosink_PeriodCounter(void)
Description Read the value of the audio sink Clock period counter
Inputs None
Outputs return value = The current value of the audio sink Clock period counter
Assumptions None
Example /* Read the audio sink period counter value. */
result = Sys_Audiosink_PeriodCounter();
www.onsemi.com
230
ON Semiconductor
9.34 SYS_AUDIOSINK_PHASECOUNTER
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_audiosink.h
Template uint32_t Sys_Audiosink_PhaseCounter(void)
Description Read the value of the audio sink Clock phase counter
Inputs None
Outputs return value = The current value of the audio sink Clock phase counter
Assumptions None
Example /* Read the audio sink phase counter value. */
result = Sys_Audiosink_PhaseCounter();
www.onsemi.com
231
RSL10 Firmware Reference
9.35 SYS_AUDIOSINK_RESETCOUNTERS
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_audiosink.h
Template void Sys_Audiosink_ResetCounters(void)
Description Reset counter, phase counter and period counter mechanism.
Inputs None
Outputs None
Assumptions None
Example /* Reset all Audio Sink counters. */
Sys_Audiosink_ResetCounters();
www.onsemi.com
232
ON Semiconductor
9.36 SYS_AUDIOSINK_SET_CTRL
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_audiosink.h
Template void Sys_Audiosink_Set_Ctrl(uint32_t cfg)
Description Configure the audio sink Clock control
Inputs cfg = The control value for the audio sink; use PHASE_CNT_[STOP | START], and
CNT_RESET
Outputs None
Assumptions None
Example /* Reset PERIOD_CNT and start audio sink clock period counter,
* stop audio sink clock phase counter. */
Sys_Audiosink_Set_Ctrl(PHASE_CNT_STOP |
CNT_RESET);
www.onsemi.com
233
RSL10 Firmware Reference
9.37 SYS_BBIF_CONNECTRFFE
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_bbif.h
Template Sys_BBIF_ConnectRFFE(void)
Description Internally connect the baseband to the RF front-end.
Inputs None
Outputs None
Assumptions None
Example /* Connect baseband to RF front-end. */
Sys_BBIF_ConnectRFFE();
www.onsemi.com
234
ON Semiconductor
9.38 SYS_BBIF_DIOCONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_bbif.h
Template void Sys_BBIF_DIOConfig(uint32_t cfg, uint32_t gpi_rx_clk, uint32_t
gpi_rx_data, uint32_t tx_data_valid, uint32_t tx_data, uint32_t sync_p)
Description Configure DIO pads connected to radio pins of baseband controller
Inputs cfg = DIO pin configuration for the output pads
rx_clk = DIO to use as the BB_RX_CLK pad
rx_data = DIO to use as the BB_RX_DATA pad
tx_data_valid = DIO to use as the BB_TX_DATA_VALID pad
tx_data = DIO to use as the BB_TX_DATA pad
sync_p = DIO to use as the BB_SYNC_P pad
Outputs None
Assumptions None
Example /* Configure DIOs 1, 2, 3, 4, 5 as data for baseband. */
Sys_BBIF_DIOConfig(APP_DIO_CFG, 1, 2, 3, 4, 5);
www.onsemi.com
235
RSL10 Firmware Reference
9.39 SYS_BBIF_RFFE
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_bbif.h
Template void Sys_BBIF_RFFE(uint32_t gpio_num)
Description Configure a DIO as a source for RF front-end audio synchronization pulse
Inputs gpio_num = GPIO number used for SYNC_PULSE generation
Outputs None
Assumptions None
Example /* Configure RF front-end audio synchronization pulse with link
* label 0x00
*/
Sys_BBIF_RFFE(0x00);
www.onsemi.com
236
ON Semiconductor
9.40 SYS_BBIF_RFFEDRIVENEXTERNAL
Configure DIO pads connected to the RF frontend interface to be driven from an external device
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_bbif.h
Template Sys_BBIF_RFFEDrivenExternal(uint32_t cfg, uint32_t clk, uint32_t mosi,
uint32_t miso, uint32_t csn, uint32_t rx_clk, uint32_t rx_data, uint32_t
tx_data_val, uint32_t tx_data, uint32_t sync_p)
Description Configure DIO pads connected to the RF frontend interface to be driven from an external device
Inputs cfg = DIO pin configuration for the output pads
clk = DIO to use as the clock pad
mosi = DIO to use as the MOSI pad
miso = DIO to use as the MISO pad
csn = DIO to use as the chip select pad
rx_clk = DIO to use as the BB_RX_CLK pad
rx_data = DIO to use as the BB_RX_DATA pad
tx_data_valid = DIO to use as the BB_TX_DATA_VALID pad
tx_data = DIO to use as the BB_TX_DATA pad
sync_p = DIO to use as the BB_SYNC_P pad
Outputs None
Assumptions None
Example /* Connect RF and digital pins to external GPIOs. */
Sys_BBIF_RFFEDrivenExternal(DIO_WEAK_PULL_DOWN,
0, 1, 2, 3, 4, 5, 6, 7, 8);
www.onsemi.com
237
RSL10 Firmware Reference
9.41 SYS_BBIF_SPICONFIG
Configure DIOs as an SPI slave for the Bluetooth baseband controller; disable the RF SPI slave interface
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_bbif.h
Template void Sys_BBIF_SPIConfig(uint32_t cfg, uint32_t miso, uint32_t csn,
uint32_t mosi, uint32_t clk)
Description Configure DIOs as an SPI slave for the Bluetooth baseband controller; disable the RF SPI slave interface
Inputs cfg = DIO pin configuration for the output pads
miso = DIO to use as the MISO pad
csn = DIO to use as the CSN pad
mosi = DIO to use as the MOSI pad
clk = DIO to use as the CLK pad
Outputs None
Assumptions None
Example /* Configure DIOs 1, 2, 3, 4 as the baseband SPI interface in slave
* mode
*/
Sys_BBIF_SPIConfig(APP_DIO_CFG, 1, 2, 3, 4);
www.onsemi.com
238
ON Semiconductor
9.42 SYS_BBIF_SYNCCONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_bbif.h
Template void Sys_BBIF_SyncConfig(uint32_t cfg, uint32_t linklbl, uint32_t
linkformat)
Description Configure the link synchronization
Inputs cfg = Configuration of the link synchronization mechanism mode; use RX_[IDLE |
ACTIVE], SYNC_[DISABLE | ENABLE], [IDLE | ACTIVE], and
SYNC_SOURCE_[BLE_RX | BLE_RX_AUDIO* | RF_RX | BLE_TX]
linklbl = The BLE link label for synchronization; use a 5-bit number
linkformat = Configure the BLE link format for synchronization; use [SLAVE,
MASTER]_CONNECT
Outputs None
Assumptions None
Example /* Configure the baseband synchronization signal to trigger from the
* RX signal. */
Sys_BBIF_SyncConfig(SYNC_ENABLE | SYNC_SOURCE_BLE_TX, 0,
SLAVE_CONNECT);
www.onsemi.com
239
RSL10 Firmware Reference
9.43 SYS_BOOTROM_RESET
Reset the system by executing the reset vector in the Boot ROM
Type Function
Include File #include <rsl10.h>
Source File rsl10_romvect.h
Template void Sys_BootROM_Reset(void)
Description Reset the system by executing the reset vector in the Boot ROM
Inputs None
Outputs None
Assumptions None
Example /* Reset the system by executing the reset vector in the Boot ROM. */
Sys_BootROM_Reset();
www.onsemi.com
240
ON Semiconductor
9.44 SYS_BOOTROM_STARTAPP
Type Function
Include File #include <rsl10.h>
Source File rsl10_romvect.h
Template BootROMStatus Sys_BootROM_StartApp(uint32_t* vect_table)
Description Validate and start up an application using the Boot ROM.
Inputs vect_table = Pointer to the vector table at the start of an application that will be validated and
then run.
Outputs return value = Status code indicating application validation error if application cannot be
started. If not returning, the status code is written to the top of the started
application's stack to capture non-fatal validation issues.
Assumptions None
Example /* Checks if application is valid and starts it (if possible).
* Returns status code. */
isValid = Sys_BootROM_StartApp(vect_table);
www.onsemi.com
241
RSL10 Firmware Reference
9.45 SYS_BOOTROM_STARTAPP_RETURN
Read the start application return code from the application stack for the current application
Type Macro
Include File #include <rsl10.h>
Source File rsl10_sys_cm3.h
Template SYS_BOOTROM_STARTAPP_RETURN
Description Read the start application return code from the application stack for the current application
Inputs None
Outputs return value = The value stored on the top of the stack (uint32_t); compare against
BOOTROM_ERR_* or SYS_INIT_ERR_*
Assumptions None
Example /* Check the boot ROM start application error code return. */
result = SYS_BOOTROM_STARTAPP_RETURN;
www.onsemi.com
242
ON Semiconductor
9.46 SYS_BOOTROM_STRICTSTARTAPP
Type Function
Include File #include <rsl10.h>
Source File rsl10_romvect.c
Template BootROMStatus Sys_BootROM_StrictStartApp(uint32_t* vect_table)
Description Validate and start up an application using the Boot ROM. Only start the application if application validation
returns BOOTROM_ERR_NONE.
Inputs vect_table = Pointer to the vector table at the start of an application that will be validated and
then run.
Outputs return value = Status code indicating application validation error if application cannot be
started. If not returning, the status code is written to the top of the started
application's stack to capture non-fatal validation issues.
Assumptions None
Example /* Checks if application is valid and starts it (if possible).
* Returns status code if any errors at all occur. */
isValid = Sys_BootROM_StrictStartApp(vect_table);
www.onsemi.com
243
RSL10 Firmware Reference
9.47 SYS_BOOTROM_VALIDATEAPP
Type Function
Include File #include <rsl10.h>
Source File rsl10_romvect.h
Template BootROMStatus Sys_BootROM_ValidateApp(uint32_t* vect_table)
Description Validate an application using the Boot ROM application checks.
Inputs vect_table = Pointer to the vector table at the start of an application that will be validated.
Outputs return value = Status code indicating whether a validation error occurred or not; compare
against BOOTROM_ERR_*
Assumptions None
Example /* Checks if application is valid. Returns status code. */
isValid = Sys_BootROM_ValidateApp(vect_table);
www.onsemi.com
244
ON Semiconductor
9.48 SYS_CLOCKS_CLKDETENABLE
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_clocks.h
Template void Sys_Clocks_ClkDetEnable(void)
Description Enable/Disable the external clock detector
Inputs cfg = Configuration of the clock detector enable value; use CLK_DET_[DISABLE |
ENABLE]_BITBAND
Outputs None
Assumptions None
Example /* Enable the clock detector. */
Sys_Clocks_ClkDetEnable(CLK_DET_ENABLE_BITBAND);
www.onsemi.com
245
RSL10 Firmware Reference
9.49 SYS_CLOCKS_OSC
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_clocks.h
Template void Sys_Clocks_Osc(uint32_t cfg)
Description Configure the RC oscillator
Inputs cfg = Configuration for 3 MHz/12 MHz RC oscillator; use RC_START_OSC_[3 |
12]MHZ RC_START_OSC_[M48 | M46P5 | NOM | P46P5]
Outputs None
Assumptions None
Example /* Enable the RC oscillator at a nominal 3 MHz frequency. */
Sys_Clocks_Osc(RC_OSC_ENABLE |
RC_START_OSC_3MHZ);
www.onsemi.com
246
ON Semiconductor
9.50 SYS_CLOCKS_OSC32KCALIBRATEDCONFIG
Set the standby clock frequency to the given target based on a calibration trim value specified in NVR4
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_clocks.c
Template unsigned int Sys_Clocks_Osc32kCalibratedConfig(uint16_t target)
Description Set the standby clock frequency to the given target based on a calibration trim value specified in NVR4. The
32k oscillator is not enabled. This function will only load the trim register, the user is responsible for enabling
the oscillator if desired.
Inputs target = The target 32k oscillator frequency in Hz
Outputs return value = A code indicating whether an error has occurred.
Assumptions None
Example /* Load the standby oscillator trim register to target 32768 Hz */
result = Sys_Clocks_Osc32kCalibratedConfig(32768);
www.onsemi.com
247
RSL10 Firmware Reference
9.51 SYS_CLOCKS_OSC32KHZ
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_clocks.h
Template void Sys_Clocks_Osc32kHz(uint32_t cfg)
Description Configure the 32 kHz RC oscillator
Inputs cfg = Configuration for 32 kHz RC oscillator; use RC_OSC_[DISABLE | ENABLE]
RC_OSC_RANGE_[NOM | M25] RC_OSC_[M48 | M46P5 | NOM | P46P5]
Outputs None
Assumptions None
Example /* The 32kHz RC Oscillator frequency trimming set to the nominal. */
Sys_Clocks_Osc32kHz(RC_OSC_NOM);
www.onsemi.com
248
ON Semiconductor
9.52 SYS_CLOCKS_OSCRCCALIBRATEDCONFIG
Set the start oscillator frequency to the given target based on a calibration trim value specified in NVR4
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_clocks.c
Template unsigned int Sys_Clocks_OscRCCalibratedConfig(uint16_t target)
Description Set the start oscillator frequency to the given target based on a calibration trim value specified in NVR4. This
function only loads the trim register and multiplier bit if necessary.
Inputs target = The target start oscillator frequency in kHz
Outputs return value = A code indicating whether an error has occurred.
Assumptions None
Example /* Load the start oscillator trim register for a target of 3 MHz */
result = Sys_Clocks_OscRCCalibratedConfig(3000);
www.onsemi.com
249
RSL10 Firmware Reference
9.53 SYS_CLOCKS_SET_CLKDETCONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_clocks.h
Template void Sys_Clocks_Set_ClkDetConfig(uint32_t cfg)
Description Configure the external clock detector
Inputs cfg = The external clock detector configuration; use CLK_DET_[DISABLE |
ENABLE], CLK_DET_SLOWCLK_DIV*, CLK_DET_INT_[DISABLE |
ACTIVATED | DEACTIVATED | ACTIVITY_CHANGE], and
CLK_DET_SEL_[EXT | SW]CLK
Outputs None
Assumptions None
Example /* Enable the clock detector to monitor EXTCLK, setting the
* clock detector divider to 32. */
Sys_Clocks_Set_ClkDetConfig(CLK_DET_ENABLE |
CLK_DET_SLOWCLK_DIV32 |
CLK_DET_INT_ACTIVATED |
CLK_DET_SEL_EXTCLK);
www.onsemi.com
250
ON Semiconductor
9.54 SYS_CLOCKS_SYSTEMCLKCONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_clocks.h
Template void Sys_Clocks_SystemClkConfig(uint32_t cfg)
Description Configure System Clock
Inputs cfg = Configuration of the system clock source and prescale value; use
SYSCLK_CLKSRC_[RCCLK | STANDBYCLK | RFCLK | EXTCLK | JTCK],
EXTCLK_PRESCALE_*, and JTCK_PRESCALE_*
Outputs None
Assumptions None
Example /* Configure the system clock source to RF clock with default
* prescale values.
*/
Sys_Clocks_SystemClkConfig(SYSCLK_CLKSRC_RFCLK |
EXTCLK_PRESCALE_1 |
JTCK_PRESCALE_1);
www.onsemi.com
251
RSL10 Firmware Reference
9.55 SYS_CLOCKS_SYSTEMCLKPRESCALE0
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_clocks.h
Template void Sys_Clocks_SystemClkPrescale0(uint32_t cfg)
Description Configure prescale register number 0
Inputs cfg = Configuration of the prescale value for the slow, user and baseband peripheral
clocks; use SLOWCLK_PRESCALE_*, BBCLK_PRESCALE_*, and
USRCLK_PRESCALE_*
Outputs None
Assumptions None
Example /* Configure prescale of slow clock to 1, baseband clock to 2 and
* user clock to 3. */
Sys_Clocks_SystemClkPrescale0(SLOWCLK_PRESCALE_1 |
BBCLK_PRESCALE_2 |
USRCLK_PRESCALE_3);
www.onsemi.com
252
ON Semiconductor
9.56 SYS_CLOCKS_SYSTEMCLKPRESCALE1
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_clocks.h
Template void Sys_Clocks_SystemClkPrescale1(uint32_t cfg)
Description Configure prescale register number 1
Inputs cfg = Configuration of the prescale value for the PWM0, PWM1, UART and AUDIO
input peripheral clocks; use PWM0CLK_PRESCALE_*,
PWM1CLK_PRESCALE_*, UARTCLK_PRESCALE_*, and
AUDIOCLK_PRESCALE_*
Outputs None
Assumptions None
Example /* Configure prescale of PWM0 clock to 1, PWM1 clock to 2,
* UART clock to 31 and AUDIO clock to 63. */
Sys_Clocks_SystemClkPrescale1(PWM0CLK_PRESCALE_1 |
PWM1CLK_PRESCALE_2 |
UARTCLK_PRESCALE_31 |
AUDIOCLK_PRESCALE_63);
www.onsemi.com
253
RSL10 Firmware Reference
9.57 SYS_CLOCKS_SYSTEMCLKPRESCALE2
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_clocks.h
Template void Sys_Clocks_SystemClkPrescale2(uint32_t cfg)
Description Configure prescale register number 2
Inputs cfg = Configuration of the prescale value for the charge pump and DC-DC converter
clocks; use CPCLK_PRESCALE_*, and DCCLK_PRESCALE_*
Outputs None
Assumptions None
Example /* Configure the prescalers of the clocks used by the charge pump
* and DC-DC converters */
Sys_Clocks_SystemClkPrescale2(CPCLK_PRESCALE_1 |
DCCLK_PRESCALE_2);
www.onsemi.com
254
ON Semiconductor
9.58 SYS_CRC_CALC
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_crc.c
Template uint32_t Sys_CRC_Calc(uint32_t type, uint32_t base, uint32_t top,
uint32_t* crc_val)
Description Calculate the CRC over the specified range
Inputs type = CRC mode; use CRC_32 or CRC_CCITT
base = Base of the range to be verified
top = Last byte in the range to be verified
crc_val = Address to store the calculated value at
Outputs return value = 0 if invalid input; 1 otherwise
Assumptions None
Example /* Calculate the CRC for a sample buffer */
crc_val = 0x1234;
result = Sys_CRC_Calc(CRC_CCITT, (uint32_t)&sample,
(uint32_t)&sample[7], &crc_val);
/* Save the calculated CRC at the end of the block (Assumes CRC-CCITT
* algorithm and Little Endian mode) */
sample[8] = (uint8_t) (crc_val & 0xFF);
sample[9] = (uint8_t) ((crc_val >> 8) & 0xFF);
www.onsemi.com
255
RSL10 Firmware Reference
9.59 SYS_CRC_CHECK
Check the CRC over the specified range assuming the last bytes of the defined block contain the previously
calculated CRC
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_crc.c
Template uint32_t Sys_CRC_Check(uint32_t type, uint32_t base, uint32_t top)
Description Check the CRC over the specified range assuming the last bytes of the defined block contain the previously
calculated CRC
Inputs type = CRC mode; use CRC_32 or CRC_CCITT
base = Base of the range to be verified
top = Last byte in the range to be verified
Outputs return value = 0 if CRC check failed, 1 if CRC check passed, 2 if there's an error
Assumptions None
Example /* Verify the CRC for a sample array of ten 8-bit elements */
result = Sys_CRC_Check(CRC_CCITT, (uint32_t)&sample,
(uint32_t)&sample[9]);
www.onsemi.com
256
ON Semiconductor
9.60 SYS_CRC_GET_CONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_crc.h
Template uint32_t Sys_CRC_Get_Config(void)
Description Get the CRC generator configuration
Inputs None
Outputs return value = CRC generator configuration; compare with CRC_[CCITT | 32], CRC_[BIG |
LITTLE]_ENDIAN, CRC_BIT_ORDER_[STANDARD | NON_STANDARD],
CRC_FINAL_REVERSE_[STANDARD | NON_STANDARD], and
CRC_FINAL_XOR_[STANDARD | NON_STANDARD]
Assumptions None
Example /* Get current CRC generator configuration. */
curr_config = Sys_CRC_Get_Config();
www.onsemi.com
257
RSL10 Firmware Reference
9.61 SYS_CRC_SET_CONFIG
Configure the CRC generator type, endianness of the input data, and standard vs non-standard CRC behavior
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_crc.h
Template void Sys_CRC_Set_Config(uint32_t cfg)
Description Configure the CRC generator type, endianness of the input data, and standard vs non-standard CRC behavior
Inputs cfg = CRC generator configuration; use CRC_[CCITT | 32], CRC_[BIG |
LITTLE]_ENDIAN, CRC_BIT_ORDER_[STANDARD | NON_STANDARD],
CRC_FINAL_REVERSE_[STANDARD | NON_STANDARD], and
CRC_FINAL_XOR_[STANDARD | NON_STANDARD]
Outputs None
Assumptions None
Example /* Enable CRC-CCITT (16-bit) algorithm, Little Endian mode, standard
* bit order, standard CRC reversal and standard CRC XOR. */
Sys_CRC_Set_Config(CRC_CCITT |
CRC_LITTLE_ENDIAN |
CRC_BIT_ORDER_STANDARD |
CRC_FINAL_REVERSE_STANDARD |
CRC_FINAL_XOR_STANDARD);
www.onsemi.com
258
ON Semiconductor
9.62 SYS_DELAY_PROGRAMROM
Type Function
Include File #include <rsl10.h>
Source File rsl10_romvect.h
Template void Sys_Delay_ProgramROM(uint32_t cycles)
Description Delay by at least the specified number of clock cycles
Inputs cycles = Number of system clock cycles to delay
Outputs None
Assumptions The requested delay is at least 32 cycles (32 us at 1 MHz) and fits in a uint32_t (0xFFFFFFFF cycles is
approximately 214.75 s at 20 MHz).
A delay between cycles and (cycles + 3) provides a sufficient delay resolution.
The requested delay does not exceed the watchdog timeout.
If the delay resolution is required to be exact, disable interrupts.
Example /* Delay by 100 clock cycles. */
Sys_Delay_ProgramROM(100);
www.onsemi.com
259
RSL10 Firmware Reference
9.63 SYS_DIO_CONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_dio.h
Template void Sys_DIO_Config(uint32_t pad, uint32_t cfg)
Description Configure the specified digital I/O
Inputs pad = Digital I/O pad to configure; use a constant between 0 and 15
cfg = I/O configuration; use DIO_*X_DRIVE, DIO_LPF_[ENABLE | DISABLE],
DIO_[NO_PULL | STRONG_PULL_UP | WEAK_PULL_UP |
WEAK_PULL_DOWN], and DIO_MODE_*
Outputs None
Assumptions None
Example /* Configure DIO 4 as a GPIO input with a weak pull-up resistor. */
Sys_DIO_Config(4, DIO_WEAK_PULL_UP | DIO_MODE_GPIO_IN_0);
www.onsemi.com
260
ON Semiconductor
9.64 SYS_DIO_GET_MODE
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_dio.h
Template uint32_t Sys_DIO_Get_Mode(void)
Description Get the DIO mode (DIO or GPIO)
Inputs None
Outputs return value = Current DIO/GPIO mode
Assumptions None
Example /* Get current DIO mode for DIOs 0 to 15. */
dio_mode = Sys_DIO_Get_Mode();
www.onsemi.com
261
RSL10 Firmware Reference
9.65 SYS_DIO_INTCONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_dio.h
Template void Sys_DIO_IntConfig(uint32_t index, uint32_t cfg, uint32_t dbnc_clk,
uint32_t dbnc_cnt)
Description Configure a DIO interrupt source
Inputs index = DIO interrupt source to configure; use [0- 3]
cfg = DIO interrupt configuration; use DIO_DEBOUNCE_[DISABLE | ENABLE],
DIO_SRC_DIO_*, and DIO_EVENT_[NONE | HIGH_LEVEL | LOW_LEVEL |
RISING_EDGE | FALLING_EDGE | TRANSITION]
dbnc_clk = Interrupt button debounce filter clock; use
DIO_DEBOUNCE_SLOWCLK_DIV[32 | 1024]
dbnc_cnt = Interrupt button debounce filter count
Outputs None
Assumptions None
Example /* Configure 0 Interrupt source with pad 0 and high level event in
* active debounce with slow clock divider 32. */
Sys_DIO_IntConfig(0,
DIO_DEBOUNCE_ENABLE |
DIO_SRC_DIO_0 |
DIO_EVENT_HIGH_LEVEL,
DIO_DEBOUNCE_SLOWCLK_DIV32,
0);
www.onsemi.com
262
ON Semiconductor
9.66 SYS_DIO_NMICONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_dio.h
Template void Sys_DIO_NMIConfig(uint32_t cfg, uint32_t nmi)
Description Configure a DIO for the specified NMI input selection
Inputs cfg = DIO pin configuration for the NMI input pad
nmi = DIO to use as the NMI input pad
Outputs None
Assumptions None
Example /* Configure DIO 1 as the NMI interface. */
Sys_DIO_NMIConfig(APP_DIO_CFG, 1);
www.onsemi.com
263
RSL10 Firmware Reference
9.67 SYS_DIO_SET_DIRECTION
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_dio.h
Template void Sys_DIO_Set_Direction(uint32_t dir)
Description Set the input/output direction for any DIOs configured as GPIOs
Inputs dir = Input/output configuration for those DIOs configured as GPIOs; use
DIO*_INPUT, and DIO*_OUTPUT
Outputs None
Assumptions None
Example /* Set DIO0, DIO2 as inputs; set DIO1 as an output. */
Sys_DIO_Set_Direction(DIO0_INPUT | DIO1_OUTPUT | DIO2_INPUT);
www.onsemi.com
264
ON Semiconductor
9.68 SYS_DMA_CHANNELCONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_dma.c
Template void Sys_DMA_ChannelConfig(uint32_t num, uint32_t cfg, uint32_t
transferLength, uint32_t counterInt, uint32_t srcAddr, uint32_t
destAddr)
Description Configure the DMA channels for a data transfer
Inputs num = DMA channel number
cfg = Configuration of the DMA transfer behavior; use
DMA_DEST_ADDR_STEP_SIZE_*, DMA_SRC_ADDR_STEP_SIZE_*,
DMA_DEST_ADDR_[POS | NEG], DMA_SRC_ADDR_[POS | NEG],
DMA_[LITTLE | BIG]_ENDIAN, DMA_DISABLE_INT_[DISABLE | ENABLE],
DMA_ERROR_INT_[DISABLE | ENABLE], DMA_COMPLETE_INT_[DISABLE
| ENABLE], DMA_COUNTER_INT_[DISABLE | ENABLE],
DMA_START_INT_[DISABLE | ENABLE], DMA_DEST_WORD_SIZE_*,
DMA_SRC_WORD_SIZE_*, DMA_DEST_[I2C | SPI0 | SPI1 | PCM | UART |
ASRC], DMA_SRC_[I2C | SPI0 | SPI1 | PCM | UART | ASRC],
DMA_PRIORITY_*, DMA_TRANSFER_[P | M]_TO_[P | M]
DMA_DEST_ADDR_[STATIC | INC], DMA_SRC_ADDR_[STATIC | INC],
DMA_ADDR_[CIRC | LIN], DMA_[DISABLE | ENABLE]
transferLength = Configuration of the DMA transfer length
counterInt = Configuration of when the counter interrupt will occur during the transfer
srcAddr = Base source address for the DMA transfer
destAddr = Base destination address for the DMA transfer
Outputs None
www.onsemi.com
265
RSL10 Firmware Reference
Assumptions None
Example /* Configure DMA channel 0 for a transfer from the PCM interface to
* a 16-word buffer in memory. Clear any previous DMA status bit
* settings. */
Sys_DMA_ChannelConfig(0,
(DMA_DEST_ADDR_STEP_SIZE_1 |
DMA_DEST_ADDR_POS |
DMA_SRC_ADDR_STEP_SIZE_1 |
DMA_SRC_ADDR_POS |
DMA_LITTLE_ENDIAN |
DMA_DISABLE_INT_DISABLE |
DMA_ERROR_INT_ENABLE |
DMA_COMPLETE_INT_ENABLE |
DMA_COUNTER_INT_ENABLE |
DMA_START_INT_DISABLE |
DMA_DEST_WORD_SIZE_32 |
DMA_SRC_WORD_SIZE_32 |
DMA_SRC_PCM |
DMA_PRIORITY_0 |
DMA_TRANSFER_P_TO_M |
DMA_SRC_ADDR_STATIC |
DMA_DEST_ADDR_INC |
DMA_ADDR_CIRC |
DMA_DISABLE) ,
16,
0,
(uint32_t)&PCM->RX_DATA,
(uint32_t)buffer);
www.onsemi.com
266
ON Semiconductor
9.69 SYS_DMA_CHANNELDISABLE
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_dma.h
Template void Sys_DMA_ChannelDisable(uint32_t num)
Description Disable the DMA channel
Inputs num = The DMA channel number
Outputs None
Assumptions None
Example /* Disable DMA channel 0. */
Sys_DMA_ChannelDisable(0);
www.onsemi.com
267
RSL10 Firmware Reference
9.70 SYS_DMA_CHANNELENABLE
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_dma.h
Template void Sys_DMA_ChannelEnable(uint32_t num)
Description Enable the DMA channel
Inputs num = The DMA channel number
Outputs None
Assumptions None
Example /* Enable DMA channel 0. */
Sys_DMA_ChannelEnable(0);
www.onsemi.com
268
ON Semiconductor
9.71 SYS_DMA_CLEARALLCHANNELSTATUS
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_dma.h
Template void Sys_DMA_ClearAllChannelStatus(void)
Description Clear the current status for the DMA on all channels
Inputs None
Outputs None
Assumptions None
Example /* Clear the current status for DMA on all channels. */
Sys_DMA_ClearAllChannelStatus();
www.onsemi.com
269
RSL10 Firmware Reference
9.72 SYS_DMA_CLEARCHANNELSTATUS
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_dma.h
Template void Sys_DMA_ClearChannelStatus(uint32_t num)
Description Clear the current status for the specified DMA channel
Inputs num = The DMA channel number; use 0- 7
Outputs None
Assumptions None
Example /* Clear the current status for DMA channel 0. */
Sys_DMA_ClearChannelStatus(0);
www.onsemi.com
270
ON Semiconductor
9.73 SYS_DMA_GET_CHANNELSTATUS
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_dma.h
Template uint8_t Sys_DMA_Get_ChannelStatus(uint32_t num)
Description Get the current status of the DMA channel
Inputs num = The DMA channel number
Outputs return value = The current status of the specified DMA channel
Assumptions None
Example /* Get the current status of DMA channel 0. */
status = Sys_DMA_Get_ChannelStatus(0);
www.onsemi.com
271
RSL10 Firmware Reference
9.74 SYS_DMA_SET_CHANNELDESTADDRESS
Set the base destination address for the specified DMA channel
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_dma.h
Template void Sys_DMA_Set_ChannelDestAddress(uint32_t num, uint32_t destAddr)
Description Set the base destination address for the specified DMA channel
Inputs num = The DMA channel number
destAddr = Base destination address for the DMA transfer
Outputs None
Assumptions None
Example /* Set buffer as the base destination address for DMA channel 0. */
uint32_t buffer[1] = {0};
Sys_DMA_Set_ChannelDestAddress(0, (uint32_t) buffer);
www.onsemi.com
272
ON Semiconductor
9.75 SYS_DMA_SET_CHANNELSOURCEADDRESS
Set the base source address for the specified DMA channel
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_dma.h
Template void Sys_DMA_Set_ChannelSourceAddress(uint32_t num, uint32_t srcAddr)
Description Set the base source address for the specified DMA channel
Inputs num = The DMA channel number
srcAddr = Base source address for the DMA transfer
Outputs None
Assumptions None
Example /* Set PCM_RX_DATA as the base source address for DMA channel 0. */
Sys_DMA_Set_ChannelSourceAddress(0, (uint32_t)&PCM->RX_DATA);
www.onsemi.com
273
RSL10 Firmware Reference
9.76 SYS_FLASH_COMPARE
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_flash.c
Template uint32_t Sys_Flash_Compare(uint32_t cfg, uint32_t addr, uint32_t length,
uint32_t value, uint32_t value_ecc)
Description Compare data in the flash to a pre-specified value
Inputs cfg = Flash comparator configuration; use COMP_MODE_[CONSTANT |
CHBK]_BYTE, COMP_ADDR_[DOWN | UP]_BYTE, and
COMP_ADDR_STEP_*_BYTE
addr = Base address of the area to verify
length = Number of words to verify
value = Value that the words read from flash will be compared against
value_ecc = Value that the error-correction coding bits from the extended words read from
flash will be compared against
Outputs return value = 0 if comparison succeeded, 1 if the comparison failed.
Assumptions addr points to an address in flash memory
Example /* Check that the 10 words this application needs are still erased */
result = Sys_Flash_Compare((COMP_MODE_CONSTANT_BYTE |
COMP_ADDR_UP_BYTE |
COMP_ADDR_STEP_1_BYTE),
FLASH_MAIN_TOP - 0x100, 10,
0xFFFFFFFF, 0xF);
if (result == 0)
{
/* Use the flash here since it has been validated as erased. */
}
www.onsemi.com
274
ON Semiconductor
9.77 SYS_FLASH_COPY
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_flash.c
Template void Sys_Flash_Copy(uint32_t src_addr, uint32_t dest_addr, uint32_t
length, uint32_t cpy_dest)
Description Copy data from the flash memory to a RAM memory instance
Inputs src_addr = Source address in flash to copy data from
dest_addr = Destination address in RAM to copy data to
length = Number of words to copy
cpy_dest = Destination copier is CRC or memories; use COPY_TO_[CRC |
MEM]_BITBAND
Outputs None
Assumptions src_addr points to an address in flash memory
dest_addr points to an address in RAM memory
If dest_addr points to an area in DSP_PRAM memory, the copy will write all 40 bits of the PRAM memory
The flash copy does not need to be complete before returning
If CRC is selected as the destination, dest_addr is ignored and 32-bit copy mode is selected automatically.
Example /* Copy 10 words from data to the base of DSP_PRAM0. */
Sys_Flash_Copy(data, DSP_PRAM0_BASE, 10, COPY_TO_MEM_BITBAND);
www.onsemi.com
275
RSL10 Firmware Reference
9.78 SYS_FLASH_ECC_CONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_flash.h
Template void Sys_Flash_ECC_Config(uint32_t cfg)
Description Configure the flash error-correction control support
Inputs cfg = Configuration for the flash error-correction control block; use
FLASH_IDBUS_ECC_[ENABLE | DISABLE], FLASH_DMA_ECC_[ENABLE |
DISABLE], FLASH_CMD_ECC_[ENABLE | DISABLE],
FLASH_COPIER_ECC_[ENABLE | DISABLE], and
FLASH_ECC_COR_INT_THRESHOLD_* or a constant shifted to
FLASH_ECC_CTRL_ECC_COR_CNT_INT_THRESHOLD_Pos
Outputs None
Assumptions None
Example /* Enable the ECC blocks for all users of flash. */
Sys_Flash_ECC_Config(FLASH_IDBUS_ECC_ENABLE | FLASH_CMD_ECC_ENABLE |
FLASH_COPIER_ECC_ENABLE |
FLASH_ECC_COR_INT_THRESHOLD_1);
www.onsemi.com
276
ON Semiconductor
9.79 SYS_GPIO_SET_HIGH
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_gpio.h
Template void Sys_GPIO_Set_High(uint32_t gpio_pin)
Description Set the specified GPIO output value to high
Inputs gpio_pin = GPIO pin to set high
Outputs None
Assumptions None
Example /* Set GPIO 0 high. */
Sys_GPIO_Set_High(0);
www.onsemi.com
277
RSL10 Firmware Reference
9.80 SYS_GPIO_SET_LOW
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_gpio.h
Template void Sys_GPIO_Set_Low(uint32_t gpio_pin)
Description Set the specified GPIO output value to low
Inputs gpio_pin = GPIO pin to set low
Outputs None
Assumptions None
Example /* Set GPIO 0 low. */
Sys_GPIO_Set_Low(0);
www.onsemi.com
278
ON Semiconductor
9.81 SYS_GPIO_TOGGLE
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_gpio.h
Template void Sys_GPIO_Toggle(uint32_t gpio_pin)
Description Toggle the current value of the specified GPIO output
Inputs gpio_pin = GPIO pin to toggle
Outputs None
Assumptions None
Example /* Toggle GPIO 0. */
Sys_GPIO_Toggle(0);
www.onsemi.com
279
RSL10 Firmware Reference
9.82 SYS_I2C_ACK
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_i2c.h
Template void Sys_I2C_ACK(void)
Description Manually acknowledge the latest transfer
Inputs None
Outputs None
Assumptions None
Example /* Acknowledge the latest byte transfer. */
Sys_I2C_ACK();
www.onsemi.com
280
ON Semiconductor
9.83 SYS_I2C_CONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_i2c.h
Template void Sys_I2C_Config(uint32_t cfg)
Description Configure the I2C interface for operation
Inputs cfg = I2C interface configuration; use I2C_MASTER_SPEED_*, a slave address
constant shifted to I2C_CTRL0_SLAVE_ADDRESS_Pos,
I2C_CONTROLLER_[CM3 | DMA], I2C_STOP_INT_[ENABLE | DISABLE],
I2C_AUTO_ACK_[ENABLE | DISABLE], I2C_SAMPLE_CLK_[ENABLE |
DISABLE], and I2C_SLAVE_[ENABLE | DISABLE],
Outputs None
Assumptions None
Example /* Configure the I2C interface to communicate as a slave at address
* 0x40 in auto-acknowledgement mode. */
Sys_I2C_Config( (0x40 << I2C_CTRL0_SLAVE_ADDRESS_Pos) |
I2C_CONTROLLER_CM3 |
I2C_STOP_INT_DISABLE |
I2C_AUTO_ACK_ENABLE |
I2C_SAMPLE_CLK_ENABLE |
I2C_SLAVE_ENABLE );
www.onsemi.com
281
RSL10 Firmware Reference
9.84 SYS_I2C_DIOCONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_i2c.h
Template void Sys_I2C_DIOConfig(uint32_t cfg, uint32_t scl, uint32_t sda)
Description Configure two DIOs for the specified I2C interface
Inputs cfg = DIO pin configuration for the I2C pads
scl = DIO to use as the I2C SCL pad
sda = DIO to use as the I2C SDA pad
Outputs None
Assumptions None
Example /* Configure DIOs 1 and 4 as the I2C interface. */
Sys_I2C_DIOConfig(APP_DIO_CFG, 1, 4);
www.onsemi.com
282
ON Semiconductor
9.85 SYS_I2C_GET_STATUS
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_i2c.h
Template uint32_t Sys_I2C_Get_Status(void)
Description Get the current I2C interface status
Inputs None
Outputs status = Current I2C interface status; compare with I2C_[NO_ERROR | ERROR]_S,
I2C_[BUS | NO_BUS]_ERROR_S, I2C_START_[PENDING | NOT_PENDING],
I2C_MASTER_[ACTIVE | INACTIVE], I2C_[DMA | NO_DMA]_REQUEST,
I2C_[STOP | NO_STOP]_DETECTED, I2C_[DATA | NON_DATA]_EVENT,
I2C_[ERROR | NO_ERROR], I2C_[BUS_ERROR | NO_BUS_ERROR],
I2C_BUFFER_[FULL | EMPTY], I2C_CLK_[STRETCHED |
NOT_STRETCHED], I2C_BUS_[FREE | BUSY], I2C_DATA_IS_[ADDR |
DATA], I2C_IS_[READ | WRITE], I2C_ADDR_[GEN_CALL | OTHER] and
I2C_HAS_[NACK | ACK]
Assumptions None
Example /* Check if a repeated start condition occurred, indicating that the
* most recently received data will be treated as an address. */
if ((Sys_I2C_Get_Status() & (1 << I2C_STATUS_ADDR_DATA_Pos))
== I2C_DATA_IS_ADDR)
{
/* Initialize a new slave transfer over the I2C interface. */
}
www.onsemi.com
283
RSL10 Firmware Reference
9.86 SYS_I2C_LASTDATA
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_i2c.h
Template void Sys_I2C_LastData(void)
Description Indicate that this is the last byte in the transfer
Inputs None
Outputs None
Assumptions None
Example /* Send LAST_DATA control bit to stop a transaction automatically. */
Sys_I2C_LastData();
www.onsemi.com
284
ON Semiconductor
9.87 SYS_I2C_NACK
Manually not-acknowledge the latest transfer (releases the bus to continue with a transfer)
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_i2c.h
Template void Sys_I2C_NACK(void)
Description Manually not-acknowledge the latest transfer (releases the bus to continue with a transfer)
Inputs None
Outputs None
Assumptions None
Example /* Do not acknowledge the latest byte transfer. */
Sys_I2C_NACK();
www.onsemi.com
285
RSL10 Firmware Reference
9.88 SYS_I2C_NACKANDSTOP
Manually not-acknowledge the latest transfer and send a stop condition (Master mode only)
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_i2c.h
Template void Sys_I2C_NACKAndStop(void)
Description Manually not-acknowledge the latest transfer and send a stop condition (Master mode only)
Inputs None
Outputs None
Assumptions None
Example /* Not-acknowledge the latest byte transfer and issue a stop
* condition on the I2C interface. */
Sys_I2C_NACKAndStop();
www.onsemi.com
286
ON Semiconductor
9.89 SYS_I2C_RESET
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_i2c.h
Template void Sys_I2C_Reset(void)
Description Reset the I2C interface
Inputs None
Outputs None
Assumptions None
Example /* Reset the I2C Interface. */
Sys_I2C_Reset();
www.onsemi.com
287
RSL10 Firmware Reference
9.90 SYS_I2C_STARTREAD
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_i2c.h
Template void Sys_I2C_StartRead(uint32_t addr)
Description Initialize an I2C master read transfer on the I2C interface
Inputs addr = I2C slave address to initiate a transfer with
Outputs None
Assumptions None
Example /* Initialize a read from address 0x40 over the I2C interface. */
Sys_I2C_StartRead(0x40);
www.onsemi.com
288
ON Semiconductor
9.91 SYS_I2C_STARTWRITE
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_i2c.h
Template void Sys_I2C_StartWrite(uint32_t addr)
Description Initialize an I2C master write transfer on the I2C interface
Inputs addr = I2C slave address to initiate a transfer with
Outputs None
Assumptions None
Example /* Initialize a write to the general call address over the I2C
* interface. */
Sys_I2C_StartWrite(0x00);
www.onsemi.com
289
RSL10 Firmware Reference
9.92 SYS_INITIALIZE
Type Function
Include File #include <rsl10.h>
Source File rsl10_romvect.h
Template SysInitStatus Sys_Initialize(void)
Description Run the program ROM's extended initialization functions.
Inputs None
Outputs None
Assumptions None
Example /* Reinitialize the system using the initialization program stored
* to the information page of flash. */
Sys_Initialize();
www.onsemi.com
290
ON Semiconductor
9.93 SYS_INITIALIZE_BASE
Run the Program ROM based basic initialization function; re-initialize all critical memory, clock, and power
supply components
Type Function
Include File #include <rsl10.h>
Source File rsl10_romvect.h
Template void Sys_Initialize_Base(void)
Description Run the Program ROM based basic initialization function; re-initialize all critical memory, clock, and power
supply components
Inputs None
Outputs None
Assumptions None
Example /* Reinitialize the system using the ROM initializtion routine. */
Sys_Initialize_Base();
www.onsemi.com
291
RSL10 Firmware Reference
9.94 SYS_IP_LOCK
Configure the debug lock key and set the device SWJ-DP to lock mode
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_ip.h
Template void Sys_IP_Lock(uint32_t * key)
Description Configure the debug lock key and set the device SWJ-DP to lock mode
Inputs key = Pointer to the 128-bit key as a debug lock key
Outputs None
Assumptions None
Example uint32_t ip_key[4] = {0x12345678, 0x9ABCDEF0, 0xAA5500FF, 0xAABBCCDD};
www.onsemi.com
292
ON Semiconductor
9.95 SYS_IP_UNLOCK
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_ip.h
Template void Sys_IP_Unlock(void)
Description Set the device SWJ-DP to unlock mode
Inputs None
Outputs None
Assumptions None
Example /* Unlock full access to the SWJ-DP interface */
Sys_IP_Unlock();
www.onsemi.com
293
RSL10 Firmware Reference
9.96 SYS_LPDSP32_COMMAND
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_lpdsp32.h
Template void Sys_LPDSP32_Command(uint32_t cfg)
Description Configure commands for LPDSP32
Inputs cfg = Set LPDSP32 commands; use DSS_CMD_[0- 6]
Outputs None
Assumptions None
Example /* Send command 0 to the LPDSP32. */
Sys_LPDSP32_Command(DSS_CMD_0);
www.onsemi.com
294
ON Semiconductor
9.97 SYS_LPDSP32_DIOJTAG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_lpdsp32.h
Template Sys_LPDSP32_DIOJTAG(uint32_t cfg, uint32_t tdi, uint32_t tms, uint32_t
tck, uint32_t tdo)
Description Configure DIO pads connected to LPDSP32 JTAG. It causes the LPDSP32 to be resumed.
Inputs cfg = DIO pin configuration for LPDSP32 JTAG pads
tdi = DIO to use as the JTAG TDI pad
tms = DIO to use as the JTAG TMS pad
tck = DIO to use as the JTAG TCK pad
tdo = DIO to use as the JTAG TDO pad
Outputs None
Assumptions None
Example /* Configure DIOs 1, 2 and 3 as the LPDSP32 JTAG interface. */
Sys_LPDSP32_DIOJTAG(APP_DIO_CFG, 1, 2, 3, 4);
www.onsemi.com
295
RSL10 Firmware Reference
9.98 SYS_LPDSP32_GET_ACTIVITYCOUNTER
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_lpdsp32.h
Template uint32_t Sys_LPDSP32_Get_ActivityCounter(void)
Description Read LPDSP32 activity counter value
Inputs None
Outputs return value = LPDSP32 activity counter value
Assumptions None
Example /* Read the LPDSP32 activity counter value. */
result = Sys_LPDSP32_Get_ActivityCounter();
www.onsemi.com
296
ON Semiconductor
9.99 SYS_LPDSP32_INTCLEAR
Reset pending (DMA and ARM Cortex-M3) interrupts in the LPDSP32 interrupt controller
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_lpdsp32.h
Template void Sys_LPDSP32_IntClear(void)
Description Reset pending (DMA and ARM Cortex-M3) interrupts in the LPDSP32 interrupt controller
Inputs None
Outputs None
Assumptions None
Example /* Reset pending interrupts in the LPDSP32 interrupt controller. */
Sys_LPDSP32_IntClear();
www.onsemi.com
297
RSL10 Firmware Reference
9.100 SYS_LPDSP32_PAUSE
Pause LPDSP32
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_lpdsp32.h
Template void Sys_LPDSP32_Pause(void)
Description Pause LPDSP32
Inputs None
Outputs None
Assumptions None
Example /* Pause DSS. */
Sys_LPDSP32_Pause();
www.onsemi.com
298
ON Semiconductor
9.101 SYS_LPDSP32_RESET
Reset LPDSP32
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_lpdsp32.h
Template void Sys_LPDSP32_Reset(void)
Description Reset LPDSP32
Inputs None
Outputs None
Assumptions None
Example /* Reset DSS. */
Sys_LPDSP32_Reset();
www.onsemi.com
299
RSL10 Firmware Reference
9.102 SYS_LPDSP32_RUN
Run LPDSP32
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_lpdsp32.h
Template void Sys_LPDSP32_Run(void)
Description Run LPDSP32
Inputs None
Outputs None
Assumptions None
Example /* Run DSS. */
Sys_LPDSP32_Run();
www.onsemi.com
300
ON Semiconductor
9.103 SYS_LPDSP32_RUN_STATUS
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_lpdsp32.h
Template uint32_t Sys_LPDSP32_Run_Status(void)
Description LPDSP32 running status
Inputs None
Outputs return value = LPDSP32 status; compare with DSS_LPDSP32_STATE_[PAUSE | RUN]
Assumptions None
Example /* Get the LPDSP32 running status. */
status = Sys_LPDSP32_Run_Status();
www.onsemi.com
301
RSL10 Firmware Reference
9.104 SYS_LPDSP32_RUNTIMEADDR
Type Macro
Include File #include <rsl10.h>
Source File rsl10_sys_lpdsp32.h
Template Sys_LPDSP32_RuntimeAddr(Addr, prgdata)
Description Calculate the equivalent LPDSP32 address to an ARM Cortex-M3 processor address.
Inputs Addr = the address in LPDSP32
prgdata = selection between program memory or data memory in LPDSP32. Value 1
indicates program section and 0 shows data section
Outputs return value = equivalent address in ARM Cortex-M3 processor
Assumptions For DSP_PROMx the output will contain the 32 bit LSB locations
Example /* Calculate the equivalent LPDSP32 address 0x4000 in the
* program memory. */
result = Sys_LPDSP32_RuntimeAddr(0x4000, 1);
www.onsemi.com
302
ON Semiconductor
9.105 SYS_LPDSP32_SET_DEBUGCONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_lpdsp32.h
Template void Sys_LPDSP32_Set_DebugConfig(uint32_t cfg)
Description Configure the LPDSP32 Debug Port
Inputs cfg = debug port configuration; use
LPDSP32_DEBUG_IN_POWERDOWN_[DISABLED | ENABLE] |
LPDSP32_EXIT_POWERDOWN_WHEN_HALTED_[DISABLED | ENABLE]
Outputs None
Assumptions None
Example /* Configure the LPDSP32 to exit power-down when halted */
Sys_LPDSP32_Set_DebugConfig(
LPDSP32_EXIT_POWERDOWN_WHEN_HALTED_DISABLED);
www.onsemi.com
303
RSL10 Firmware Reference
9.106 SYS_NVIC_CLEARALLPENDINGINT
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_cm3.h
Template void Sys_NVIC_ClearAllPendingInt(void)
Description Clear the pending status for all external interrupts
Inputs None
Outputs None
Assumptions None
Example /* Clear the pending status for all of the external interrupts. */
Sys_NVIC_ClearAllPendingInt();
www.onsemi.com
304
ON Semiconductor
9.107 SYS_NVIC_DISABLEALLINT
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_cm3.h
Template void Sys_NVIC_DisableAllInt(void)
Description Disable all external interrupts
Inputs None
Outputs None
Assumptions None
Example /* Disable all external interrupts. */
Sys_NVIC_DisableAllInt();
www.onsemi.com
305
RSL10 Firmware Reference
9.108 SYS_PCM_CLEARSTATUS
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_pcm.h
Template void Sys_PCM_ClearStatus(void)
Description Clear the current PCM interface status
Inputs None
Outputs None
Assumptions None
Example /* Clear the error indicators for the PCM Interface. */
Sys_PCM_ClearStatus();
www.onsemi.com
306
ON Semiconductor
9.109 SYS_PCM_CONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_pcm.h
Template void Sys_PCM_Config(uint32_t cfg)
Description Configure the PCM interface
Inputs cfg = Interface operation configuration; use PCM_SAMPLE_[FALLING |
RISING]_EDGE, PCM_BIT_ORDER_[MSB | LSB]_FIRST,
PCM_TX_ALIGN_[MSB | LSB], PCM_WORD_SIZE_*,
PCM_FRAME_ALIGN_[LAST | FIRST], PCM_FRAME_WIDTH_[SHORT |
LONG], PCM_MULTIWORD_*, PCM_SUBFRAME_[ENABLE | DISABLE],
PCM_CONTROLLER_[CM3 | DMA], PCM_[DISABLE | ENABLE], and
PCM_SELECT_[MASTER | SLAVE]
Outputs None
Assumptions None
Example /* Configure the PCM interface as a master for use with the DMA. */
Sys_PCM_Config(PCM_SAMPLE_FALLING_EDGE |
PCM_BIT_ORDER_MSB_FIRST |
PCM_TX_ALIGN_MSB |
PCM_WORD_SIZE_32 |
PCM_FRAME_ALIGN_LAST |
PCM_FRAME_WIDTH_LONG |
PCM_MULTIWORD_2 |
PCM_SUBFRAME_ENABLE |
PCM_CONTROLLER_DMA |
PCM_ENABLE |
PCM_SELECT_MASTER);
www.onsemi.com
307
RSL10 Firmware Reference
9.110 SYS_PCM_CONFIGCLK
Configure four DIOs for the PCM interface and clock source selection
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_pcm.h
Template void Sys_PCM_ConfigClk(uint32_t slave, uint32_t cfg, uint32_t clk,
uint32_t frame, uint32_t seri, uint32_t sero, uint32_t clksrc)
Description Configure four DIOs for the PCM interface and clock source selection
Inputs slave = PCM master/slave configuration; use PCM_SELECT_[MASTER | SLAVE]
cfg = DIO pin configuration for the PCM pads
clk = DIO to use as the PCM clock pad
frame = DIO to use as the PCM frame pad
seri = DIO to use as the PCM serial input pad
sero = DIO to use as the PCM serial output pad
clksrc = Clock source for PCM; use DIO_MODE_[*CLK | INPUT]
Outputs None
Assumptions None
Example /* Configure DIOs 0, 1, 2, and 3 as a master PCM interface. */
Sys_PCM_ConfigClk(PCM_SELECT_MASTER, APP_DIO_CFG, 0, 1, 2, 3,
DIO_MODE_USRCLK);
www.onsemi.com
308
ON Semiconductor
9.111 SYS_PCM_DIOCONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_pcm.h
Template void Sys_PCM_DIOConfig(uint32_t slave, uint32_t cfg, uint32_t clk,
uint32_t frame, uint32_t seri, uint32_t sero)
Description Configure four DIOs for the PCM interface
Inputs slave = PCM master/slave configuration; use PCM_SELECT_[MASTER | SLAVE]
cfg = DIO pin configuration for the PCM pads
clk = DIO to use as the PCM clock pad
frame = DIO to use as the PCM frame pad
seri = DIO to use as the PCM serial input pad
sero = DIO to use as the PCM serial output pad
Outputs None
Assumptions None
Example /* Configure DIOs 0, 1, 2, and 3 as a master PCM interface. */
Sys_PCM_DIOConfig(PCM_SELECT_MASTER, APP_DIO_CFG, 0, 1, 2, 3);
www.onsemi.com
309
RSL10 Firmware Reference
9.112 SYS_PCM_DISABLE
Disable the PCM interface without changing other PCM configuration settings
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_pcm.h
Template void Sys_PCM_Disable(void)
Description Disable the PCM interface without changing other PCM configuration settings
Inputs None
Outputs None
Assumptions None
Example /* Disable the PCM Interface. */
Sys_PCM_Disable();
www.onsemi.com
310
ON Semiconductor
9.113 SYS_PCM_ENABLE
Enable the PCM interface without changing other PCM configuration settings
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_pcm.h
Template void Sys_PCM_Enable(void)
Description Enable the PCM interface without changing other PCM configuration settings
Inputs None
Outputs None
Assumptions None
Example /* Enable the PCM Interface. */
Sys_PCM_Enable();
www.onsemi.com
311
RSL10 Firmware Reference
9.114 SYS_PCM_GET_STATUS
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_pcm.h
Template uint32_t Sys_PCM_Get_Status(void)
Description Get the current PCM interface status
Inputs None
Outputs Return value = The current PCM interface status
Assumptions None
Example /* Check for errors on the PCM Interface. */
if (Sys_PCM_Get_Status() != 0)
{
/* An error has occurred. Run the application's error handler. */
AppErrorHandler();
}
www.onsemi.com
312
ON Semiconductor
9.115 SYS_POWER_BANDGAPCALIBRATEDCONFIG
Set the band-gap voltage trim to the given target based on the calibration trim value specified in NVR4
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_power.c
Template unsigned int Sys_Power_BandGapCalibratedConfig(uint8_t target)
Description Set the band-gap voltage trim to the given target based on the calibration trim value specified in NVR4.
Inputs target = The target band-gap voltage in 10*mV
Outputs return value = A code indicating whether an error has occurred.
Assumptions None
Example /* Load the band gap power supply trim for a target of 750 mV */
result = Sys_Power_BandGapCalibratedConfig(75);
www.onsemi.com
313
RSL10 Firmware Reference
9.116 SYS_POWER_BANDGAPCONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_power.h
Template void Sys_Power_BandGapConfig(uint32_t cfg_slope, uint32_t cfg_vtrim)
Description Configure the band gap supply voltage
Inputs cfg_vtrim = Reference voltage trimming; use BG_TRIM_0p*
cfg_slope = Temperature coefficient trimming; use a 6-bit number
Outputs None
Assumptions None
Example /* Configure temperature dependency 0 ppm/C and reference voltage
* trim on 0.750V. */
Sys_Power_BandGapConfig(0x6, BG_TRIM_0P750V);
www.onsemi.com
314
ON Semiconductor
9.117 SYS_POWER_BANDGAPSTATUS
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_power.h
Template uint32_t Sys_Power_BandGapStatus(void)
Description Read Bandgap status
Inputs None
Outputs return value = content of the BG register; compare with BG_NOT_READY | BG_READY, and
BG_TRIM_0p*V
Assumptions None
Example /* Read Bandgap status. */
result = Sys_Power_BandGapStatus();
www.onsemi.com
315
RSL10 Firmware Reference
9.118 SYS_POWER_DCDCCALIBRATEDCONFIG
Set the DC-DC voltage trim to the given target based on the calibration trim value specified in NVR4
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_power.c
Template unsigned int Sys_Power_DCDCCalibratedConfig(uint8_t target)
Description Set the DC-DC voltage trim to the given target based on the calibration trim value specified in NVR4. The
DC-DC power supply is not enabled.
Inputs target = The target DCDC voltage in 10*mV
Outputs return value = A code indicating whether an error has occurred.
Assumptions None
Example /* Load the VCC power supply trim for a target of 1.20 V */
result = Sys_Power_DCDCCalibratedConfig(120);
www.onsemi.com
316
ON Semiconductor
9.119 SYS_POWER_GET_RESETANALOG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_power.h
Template uint32_t Sys_Power_Get_ResetAnalog(void)
Description Read ACS reset source status
Inputs None
Outputs return value = read status of reset source; compare with CLK_DET_RESET_FLAG_SET,
VDDM_RESET_FLAG_SET, VDDC_RESET_FLAG_SET,
PAD_RESET_FLAG_SET, and POR_RESET_FLAG_SET
Assumptions None
Example /* Read the reset source status. */
result = Sys_Power_Get_ResetAnalog();
www.onsemi.com
317
RSL10 Firmware Reference
9.120 SYS_POWER_GET_RESETDIGITAL
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_power.h
Template uint32_t Sys_Power_Get_ResetDigital(void)
Description Read digital reset source status
Inputs None
Outputs return value = setting for reset source status; use ACS_RESET_[NOT_SET | SET],
CM3_SW_RESET_[NOT_SET | SET], WATCHDOG_RESET_[NOT_SET |
SET], and LOCKUP_NOT_[NOT_SET | SET]
Assumptions None
Example /* Read the value of digital reset source. */
result = Sys_Power_Get_ResetDigital();
www.onsemi.com
318
ON Semiconductor
9.121 SYS_POWER_RESETANALOGCLEARFLAGS
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_power.h
Template void Sys_Power_ResetAnalogClearFlags(void)
Description Clear all the analog reset flags
Inputs None
Outputs None
Assumptions None
Example /* Reset POR, PAD, VDDC, VDDM and CLK_DET flags. */
Sys_Power_ResetAnalogClearFlags();
www.onsemi.com
319
RSL10 Firmware Reference
9.122 SYS_POWER_RESETDIGITALCLEARFLAGS
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_power.h
Template void Sys_Power_ResetDigitalClearFlags(void)
Description Clear all the digital reset flags
Inputs None
Outputs None
Assumptions None
Example /* Reset LOCKUP, Watchdog time out, CM3 software and ACS flags. */
Sys_Power_ResetDigitalClearFlags();
www.onsemi.com
320
ON Semiconductor
9.123 SYS_POWER_VCCCONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_power.h
Template void Sys_Power_VCCConfig(uint32_t cfg)
Description Configure DC-DC/ LDO supply
Inputs cfg = DC-DC/ LDO supply value; use VCC_ICHTRIM_*MA, VCC_[MULTI |
SINGLE]_PULSE, VCC_CONSTANT_[CHARGE | IMAX], VCC_[BUCK |
VBAT], and VCC_TRIM_1p*V_BYTE
Outputs None
Assumptions None
Example /* Configure DC-DC/ LDO supply to 1 V nominal output voltage
* in 16 mA max charge current. Single pulse mode control with
* constant charge transfer is chosen. The buck converter
* is enabled. */
Sys_Power_VCCConfig(VCC_ICHTRIM_16MA |
VCC_SINGLE_PULSE |
VCC_CONSTANT_CHARGE |
VCC_BUCK |
VCC_TRIM_1P00V);
www.onsemi.com
321
RSL10 Firmware Reference
9.124 SYS_POWER_VDDACONFIG
Configure analog voltage maximum current and sleep mode clamp control
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_power.h
Template void Sys_Power_VDDAConfig(uint32_t cfg)
Description Configure analog voltage maximum current and sleep mode clamp control
Inputs cfg = Configuration for output power trimming; use VDDA_PTRIM_*MA
Outputs None
Assumptions None
Example /* Configure VDDA to 8 mA charge pump max current charge pump.
* VCC is shorted to VDDA in sleep mode. */
Sys_Power_VDDAConfig(VDDA_PTRIM_8MA);
www.onsemi.com
322
ON Semiconductor
9.125 SYS_POWER_VDDCCALIBRATEDCONFIG
Set the VDDC voltage trim to the given target based on the calibration trim value specified in NVR4
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_power.c
Template unsigned int Sys_Power_VDDCCalibratedConfig(uint8_t target)
Description Set the VDDC voltage trim to the given target based on the calibration trim value specified in NVR4.
Inputs target = The target VDDC voltage in 10*mV
Outputs return value = A code indicating whether an error has occurred.
Assumptions None
Example /* Load the VDDC power supply trim for a target of 1.15 V */
result = Sys_Power_VDDCCalibratedConfig(115);
www.onsemi.com
323
RSL10 Firmware Reference
9.126 SYS_POWER_VDDCCONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_power.h
Template void Sys_Power_VDDCConfig(uint32_t cfg)
Description Configure digital core voltage regulator
Inputs cfg = setting standby voltage trimming, low power mode control, sleep mode clamp
control and output voltage trimming configuration; use VDDC_TRIM_*V,
VDDC_SLEEP_[HIZ | GND], VDDC_[LOW| NOMINAL]_BIAS, and
VDDC_STANDBY_TRIM_*V
Outputs None
Assumptions None
Example /* Configure VDDC standby voltage 0.75 V and output voltage
* 1 V in nominal biasing. The clamp output is grounded
* in sleep mode. */
Sys_Power_VDDCConfig(VDDC_TRIM_1P00V |
VDDC_SLEEP_GND |
VDDC_NOMINAL_BIAS |
VDDC_STANDBY_TRIM_0P75V);
www.onsemi.com
324
ON Semiconductor
9.127 SYS_POWER_VDDCSTANDBYCALIBRATEDCONFIG
Set the VDDC standby voltage trim to the given target based on the calibration trim value specified in NVR4
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_power.c
Template unsigned int Sys_Power_VDDCStandbyCalibratedConfig( uint8_t target)
Description Set the VDDC standby voltage trim to the given target based on the calibration trim value specified in NVR4.
Inputs target = The target VDDC standby voltage in 10*mV
Outputs return value = A code indicating whether an error has occurred.
Assumptions None
Example /* Load the VDDC standby power supply trim for a target of 800 mV */
result = Sys_Power_VDDCStandbyCalibratedConfig(80);
www.onsemi.com
325
RSL10 Firmware Reference
9.128 SYS_POWER_VDDMCALIBRATEDCONFIG
Set the VDDM voltage trim to the given target based on the calibration trim value specified in NVR4
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_power.c
Template unsigned int Sys_Power_VDDMCalibratedConfig(uint8_t target)
Description Set the VDDM voltage trim to the given target based on the calibration trim value specified in NVR4.
Inputs target = The target VDDM voltage in 10*mV
Outputs return value = A code indicating whether an error has occurred.
Assumptions None
Example /* Load the VDDM power supply trim for a target of 1.15 V */
result = Sys_Power_VDDMCalibratedConfig(115);
www.onsemi.com
326
ON Semiconductor
9.129 SYS_POWER_VDDMCONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_power.h
Template void Sys_Power_VDDMConfig(uint32_t cfg)
Description Configure memories' voltage regulator setting
Inputs cfg = value of the memory voltage regulator; use register VDDM_TRIM_*V,
VDDM_SLEEP_[HIZ | GND], VDDM_[LOW| NOMINAL]_BIAS, and
VDDM_STANDBY_TRIM_*V
Outputs None
Assumptions None
Example /* Configure VDDM standby voltage at 0.75 V and output voltage
* at 1 V in nominal biasing. The clamp output is grounded in
* sleep mode. */
Sys_Power_VDDMConfig(VDDM_TRIM_1P00V |
VDDM_SLEEP_GND |
VDDM_NOMINAL_BIAS |
VDDM_STANDBY_TRIM_0P75V);
www.onsemi.com
327
RSL10 Firmware Reference
9.130 SYS_POWER_VDDMSTANDBYCALIBRATEDCONFIG
Set the VDDM standby voltage trim to the given target based on the calibration trim value specified in NVR4
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_power.c
Template unsigned int Sys_Power_VDDMStandbyCalibratedConfig( uint8_t target)
Description Set the VDDM standby voltage trim to the given target based on the calibration trim value specified in NVR4.
Inputs target = The target VDDM standby voltage in 10*mV
Outputs return value = A code indicating whether an error has occurred.
Assumptions None
Example /* Load the VDDM standby power supply trim for a target of 800 mV */
result = Sys_Power_VDDMStandbyCalibratedConfig(80);
www.onsemi.com
328
ON Semiconductor
9.131 SYS_POWER_VDDPACALIBRATEDCONFIG
Set the VDDPA voltage trim to the given target based on the calibration trim value specified in NVR4
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_power.c
Template unsigned int Sys_Power_VDDPACalibratedConfig(uint8_t target)
Description Set the VDDPA voltage trim to the given target based on the calibration trim value specified in NVR4. The
VDDPA power supply is not enabled.
Inputs target = The target VDDPA voltage in 10*mV
Outputs return value = A code indicating whether an error has occurred.
Assumptions None
Example /* Load the VDDPA power supply trim for a target of 1.30 V */
result = Sys_Power_VDDPACalibratedConfig(130);
www.onsemi.com
329
RSL10 Firmware Reference
9.132 SYS_POWER_VDDPACONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_power.h
Template void Sys_Power_VDDPAConfig(uint32_t cfg)
Description Configure power amplifier RF block regulator
Inputs cfg = Power amplifier supply control, enable current sensing circuit, enable control
and output voltage trimming configuration; use VDDPA_[DISABLE | ENABLE,
VDDPA_TRIM_*V, VDDPA_ISENSE_[DISABLE | ENABLE], and
VDDPA_SW_[HIZ | GND]
Outputs None
Assumptions None
Example /* Power amplifier output connected to VDDRF regulator,
* the VDDPA regulator is enabled, the current sensing circuit
* is disabled and VDDPA is configured for a nominal 1.05 V
* output voltage trim. */
Sys_Power_VDDPAConfig(VDDPA_ENABLE |
VDDPA_TRIM_1P05V |
VDDPA_ISENSE_ENABLE |
VDDPA_SW_HIZ);
www.onsemi.com
330
ON Semiconductor
9.133 SYS_POWER_VDDRFCALIBRATEDCONFIG
Set the VDDRF voltage trim to the given target based on the calibration trim value specified in NVR4
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_power.c
Template unsigned int Sys_Power_VDDRFCalibratedConfig(uint8_t target)
Description Set the VDDRF voltage trim to the given target based on the calibration trim value specified in NVR4. The
VDDRF power supply is not enabled.
Inputs target = The target VDDRF voltage in 10*mV
Outputs return value = A code indicating whether an error has occurred.
Assumptions None
Example /* Load the VDDRF power supply trim for a target of 1.10 V */
result = Sys_Power_VDDRFCalibratedConfig(110);
www.onsemi.com
331
RSL10 Firmware Reference
9.134 SYS_POWER_VDDRFCONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_power.h
Template void Sys_Power_VDDRFConfig(uint32_t cfg)
Description Configure RF block regulator
Inputs cfg = set the RF block regulator; use VDDRF_TRIM_*V, VDDRF_[DISABLE |
ENABLE], and VDDRF_DISABLE_[HIZ | GND]
Outputs None
Assumptions None
Example /* Configure VDDRF regulator nominal output voltage on 1.0 V.
* The clamp control output is in floating. */
Sys_Power_VDDRFConfig(VDDRF_TRIM_1P00V |
VDDRF_ENABLE |
VDDRF_DISABLE_HIZ);
www.onsemi.com
332
ON Semiconductor
9.135 SYS_POWERMODES_SLEEP
Configure the system, save register and memory banks of the BLE, then enter Sleep Mode
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_power_modes.c
Template void Sys_PowerModes_Sleep( struct sleep_mode_env_tag *sleep_mode_env)
Description Configure the system, save register and memory banks of the BLE, then enter Sleep Mode
Inputs sleep_mode_env = Parameters and configurations for the Sleep Mode
Outputs None
Assumptions It is safe to enter Sleep Mode (this should be checked before calling this function), DMA channel 0 is available
Example /* Assume the configuration of Sleep Mode in sleep_mode_init_env
* and sleep_mode_env parameters were initialized. Also,
* Sys_PowerModes_Sleep_Init(&sleep_mode_init_env) or
* Sys_PowerModes_Sleep_Init_2Mbps(&sleep_mode_init_env) was called. */
www.onsemi.com
333
RSL10 Firmware Reference
9.136 SYS_POWERMODES_SLEEP_INIT
Initialize some system blocks for Sleep Mode, save RF register and memory banks excluding 2 Mbps bank,
configure retention regulators of supply voltages
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_power_modes.c
Template void Sys_PowerModes_Sleep_Init( struct sleep_mode_init_env_tag
*sleep_mode_env)
Description Initialize some system blocks for Sleep Mode, save RF register and memory banks excluding 2 Mbps bank,
configure retention regulators of supply voltages
Inputs sleep_mode_env = Parameters and configurations for the Sleep Mode
Outputs None
Assumptions RF bank 1 (2 Mbps) does not need to be saved
Example /* Assume the configuration of Sleep Mode in sleep_mode_init_env
* parameter was initialized. */
www.onsemi.com
334
ON Semiconductor
9.137 SYS_POWERMODES_SLEEP_INIT_2MBPS
Initialize some system blocks for Sleep Mode, save RF register and memory banks including 2 Mbps bank,
configure retention regulators of supply voltages
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_power_modes.c
Template void Sys_PowerModes_Sleep_Init_2Mbps( struct sleep_mode_init_env_tag
*sleep_mode_env)
Description Initialize some system blocks for Sleep Mode, save RF register and memory banks including 2 Mbps bank,
configure retention regulators of supply voltages
Inputs sleep_mode_env = Parameters and configurations for the Sleep Mode
Outputs None
Assumptions None
Example /* Assume the configuration of Sleep Mode in sleep_mode_init_env
* parameter was initialized. */
www.onsemi.com
335
RSL10 Firmware Reference
9.138 SYS_POWERMODES_SLEEP_WAKEUPFROMFLASH
Configure the system and enter Sleep Mode (wake up from flash)
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_power_modes.c
Template void Sys_PowerModes_Sleep_WakeupFromFlash( struct
sleep_mode_flash_env_tag *sleep_mode_env)
Description Configure the system and enter Sleep Mode (wake up from flash)
Inputs sleep_mode_env = Parameters and configurations for the Sleep Mode
Outputs None
Assumptions None
Example /* Assume the configuration of Sleep Mode in sleep_mode_flash_env
* parameter was initialized and
* Sleep_Mode_Configure(&sleep_mode_flash_env) was called. */
/* Configure the system and enter Sleep Mode (wake up from flash) */
Sys_PowerModes_Sleep_WakeupFromFlash(&sleep_mode_flash_env);
www.onsemi.com
336
ON Semiconductor
9.139 SYS_POWERMODES_STANDBY
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_power_modes.c
Template void Sys_PowerModes_Standby( struct standby_mode_env_tag
*standby_mode_env)
Description Configure the system and enter Standby Mode
Inputs standby_mode_env = Parameters and configurations for the Standby Mode
Outputs None
Assumptions Any retention regulator needed has been enabled
Desired wake-up source has been set up before calling this function
At least one interrupt needs to be enabled before going to Standby Mode and asserted after wake-up event to
wake up the ARM Cortex-M3 processor from WFI
Example /* Assume the configuration of Standby Mode in standby_mode_env
* parameter was initialized and
* Sys_PowerModes_Standby_Init(&standby_mode_env) was called. */
www.onsemi.com
337
RSL10 Firmware Reference
9.140 SYS_POWERMODES_STANDBY_WAKEUP
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_power_modes.c
Template void Sys_PowerModes_Standby_Wakeup( struct standby_mode_env_tag
*standby_mode_env)
Description Execute steps required to wake up the system from Standby Mode
Inputs Pre-defined = and configurations for the Standby Mode
Outputs None
Assumptions None
Example
/* Execute steps required to wake up the system from Standby Mode */
Sys_PowerModes_Standby_Wakeup(&standby_mode_env);
www.onsemi.com
338
ON Semiconductor
9.141 SYS_POWERMODES_WAKEUP
Execute steps required to wake up the system from Sleep Mode RF register bank 1 (2 Mbps) is not restored
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_power_modes.c
Template void Sys_PowerModes_Wakeup(void)
Description Execute steps required to wake up the system from Sleep Mode RF register bank 1 (2 Mbps) is not restored
Inputs None
Outputs None
Assumptions DMA channels 0 and 1 are available
Start RC oscillator is calibrated to 3 MHz
RF bank 1 (2 Mbps) does not need to be restored
Example /* Execute steps required to wake up the system from Sleep Mode.
* RF register bank 1 (2 Mbps) is not restored. */
Sys_PowerModes_Wakeup(&sleep_mode_env);
www.onsemi.com
339
RSL10 Firmware Reference
9.142 SYS_POWERMODES_WAKEUP_2MBPS
Execute steps required to wake up the system from Sleep Mode RF register bank 1 (2 Mbps) is also restored
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_power_modes.c
Template void Sys_PowerModes_Wakeup_2Mbps(void)
Description Execute steps required to wake up the system from Sleep Mode RF register bank 1 (2 Mbps) is also restored
Inputs None
Outputs None
Assumptions DMA channels 0 and 1 are available
Start RC oscillator is calibrated to 3 MHz
Example /* Execute steps required to wake up the system from Sleep Mode.
* RF register bank 1 (2 Mbps) is also restored. */
Sys_PowerModes_Wakeup_2Mbps(&sleep_mode_env);
www.onsemi.com
340
ON Semiconductor
9.143 SYS_PROGRAMROM_UNLOCKDEBUG
Type Function
Include File #include <rsl10.h>
Source File rsl10_romvect.h
Template void Sys_ProgramROM_UnlockDebug(void)
Description Run the unlock routine from the ProgramROM. WARNING: This will unlock the device by erasing the flash and
SRAM memories!
Inputs None
Outputs None
Assumptions None
Example /* Unlock the SWJ-DP after wiping the flash and RAM contents
* to protect the application IP (does not return). */
Sys_ProgramROM_UnlockDebug();
www.onsemi.com
341
RSL10 Firmware Reference
9.144 SYS_PWM_CONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_pwm.h
Template void Sys_PWM_Config(uint32_t num, uint32_t period, uint32_t duty)
Description Configure a pulse-width modulator
Inputs num = The PWM interface to configure; use 0 or 1
period = The period length for the PWM in cycles
duty = The high part of the period for the PWM in cycles
Outputs None
Assumptions PWM period is (period + 1) cycles long
PWM duty is high for (duty + 1) cycles
Example /* Set PWM0 period to (periodVal + 1). PWM0 duty cycle is high for
* (dutyVal + 1) cycles. */
Sys_PWM_Config(0, periodVal, dutyVal);
www.onsemi.com
342
ON Semiconductor
9.145 SYS_PWM_CONFIGALL
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_pwm.h
Template void Sys_PWM_ConfigAll(uint32_t period, uint32_t duty)
Description Configure both pulse-width modulators with the same configuration
Inputs period = The period length for the PWMs in cycles
duty = The high part of the period for the PWMs in cycles
Outputs None
Assumptions PWM period is (period + 1) cycles long
PWM duty is high for (duty + 1) cycles
Example /* Sets PWM0 and PWM1 periods to (periodVal + 1). PWM0 and PWM1 duty
* cycles are high for (dutyVal + 1) cycles. */
Sys_PWM_ConfigAll(periodVal, dutyVal);
www.onsemi.com
343
RSL10 Firmware Reference
9.146 SYS_PWM_CONTROL
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_pwm.h
Template void Sys_PWM_Control(uint32_t cfg)
Description Set the control configuration for the two PWM interfaces
Inputs cfg = The PWM bitband enable/disable setting; use PWM*_[DISABLE | ENABLE],
PWM_OFFSET_[DISABLE | ENABLE], and a constant shifted to
PWM_CTRL_PWM_OFFSET_Pos
Outputs None
Assumptions None
Example /* Enable both PWM interfaces with an offset of 10 cycles between
* PWM0 and PWM1. */
Sys_PWM_Control(PWM0_ENABLE | PWM1_ENABLE |
PWM_OFFSET_ENABLE | (10 << PWM_CTRL_PWM_OFFSET_Pos));
www.onsemi.com
344
ON Semiconductor
9.147 SYS_PWM_DIOCONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_pwm.h
Template void Sys_PWM_DIOConfig(uint32_t numinv, uint32_t cfg, uint32_t pwm)
Description Configure DIO for the specified PWM
Inputs numinv = PWM number; use DIO_MODE_[PWM0 | PWM0_INV | PWM1 | PWM1_INV]
cfg = DIO pin configuration for the PWM output
pwm = DIO to use as the PWM output pad
Outputs None
Assumptions None
Example /* Configure DIO 1 as the PWM0 interface and non-inverted. */
Sys_PWM_DIOConfig(DIO_MODE_PWM0, APP_DIO_CFG, 1);
www.onsemi.com
345
RSL10 Firmware Reference
9.148 SYS_PWM_ENABLE
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_pwm.h
Template void Sys_PWM_Enable(uint32_t num, uint32_t cfg)
Description Enable or disable a PWM
Inputs num = The PWM interface to enable or diable; use 0 or 1
cfg = The PWM bitband enable/disable setting; use PWM*_[DISABLE |
ENABLE]_BITBAND
Outputs None
Assumptions None
Example /* Enable PWM0 interface. */
Sys_PWM_Enable(0, PWM0_ENABLE_BITBAND);
www.onsemi.com
346
ON Semiconductor
9.149 SYS_READNVR4
Type Function
Include File #include <rsl10.h>
Source File rsl10_romvect.h
Template unsigned int Sys_ReadNVR4(unsigned int calib_info_ptr,
Description Read data from NVR4 using a function implemented in ROM.
Inputs info_ptr = The base register for the specified calibration information.
numReads = The number of words to be read.
data = A pointer to the variable that will hold the read data.
Outputs return value = A code indicating whether an error has occurred.
data = The data read from NVR4 will be contained here.
Assumptions None
Example /* Read the default VDDRF configuration from NVR4 into data */
Sys_ReadNVR4(MANU_INFO_VDDRF, 1, (unsigned int *)&data);
www.onsemi.com
347
RSL10 Firmware Reference
9.150 SYS_RFFE_INPUTDIOCONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_rffe.h
Template void Sys_RFFE_InputDIOConfig(uint32_t num, uint32_t cfg, uint32_t gpi)
Description Configure a DIO pad as an RF front-end general-purpose input
Inputs num = GPIO interface pad to configure; use 0 to 9
cfg = DIO pin configuration for the output pads
gpi = DIO to use as the GPI pad; use RF_GPIO[0:9]_SRC_DIO_[0:15], and
RF_GPIO[0:9]_SRC_CONST_[LOW | HIGH]
Outputs None
Assumptions None
Example /* Configure DIO 4 as an input pin of the chip and connect it to RF
* GPIO3 in other-end. */
Sys_RFFE_InputDIOConfig(3, DIO_WEAK_PULL_UP, RF_GPIO3_SRC_DIO_4);
www.onsemi.com
348
ON Semiconductor
9.151 SYS_RFFE_OUTPUTDIOCONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_rffe.h
Template void Sys_RFFE_OutputDIOConfig(uint32_t num, uint32_t cfg, uint32_t gpio)
Description Configure DIO pads connected to RF front-end GPIO
Inputs num = GPIO interface pad to configure; use 0 to 9
cfg = DIO pin configuration for the output pads
gpo = DIO to use as the GPO pad
Outputs None
Assumptions None
Example /* Configure DIO 2 as an output pin of the chip and connect it to RF
* GPIO5 in other-end. */
Sys_RFFE_OutputDIOConfig(5, APP_DIO_CFG, 2);
www.onsemi.com
349
RSL10 Firmware Reference
9.152 SYS_RFFE_SPIDIOCONFIG
Configure the SPI slave for the RF front-end to use DIOs as the SPI master source
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_rffe.h
Template void Sys_RFFE_SPIDIOConfig(uint32_t cfg, uint32_t mosi, uint32_t csn,
uint32_t clk, uint32_t miso)
Description Configure the SPI slave for the RF front-end to use DIOs as the SPI master source
Inputs cfg = DIO pin configuration for the output pads
mosi = DIO to use as the MOSI pad
csn = DIO to use as the CSN pad
clk = DIO to use as the CLK pad
miso = DIO to use as the MISO pad
Outputs None
Assumptions None
Example /* Configure DIOs 1, 2, 3, 4 as the SPI interface to the
* RF front-end. */
Sys_RFFE_SPIDIOConfig(APP_DIO_CFG, 1, 2, 3, 4);
www.onsemi.com
350
ON Semiconductor
9.153 SYS_RTC_CONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_rtc.h
Template void Sys_RTC_Config(uint32_t start_value, uint32_t rtc_ctrl_cfg)
Description Configure RTC block
Inputs start_value = Start value for the RTC timer counter; use a 32 bit value
rtc_ctrl_cfg = RTC control register; use RTC_RESET, RTC_FORCE_CLOCK,
RTC_ALARM_*, RTC_[DISABLE | ENABLE], and RTC_CLK_SRC_[XTAL32K |
RC_OSC]
Outputs None
Assumptions None
Example /* RTC timer count period of 30.518 us, RTC is reset and enabled,
* RTC alarm invoke every 1 s and the RTC is RC Oscillator. */
Sys_RTC_Config(0, RTC_RESET |
RTC_ALARM_1S |
RTC_ENABLE |
RTC_CLK_SRC_RC_OSC);
www.onsemi.com
351
RSL10 Firmware Reference
9.154 SYS_RTC_START
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_rtc.h
Template void Sys_RTC_Start(uint32_t cfg)
Description Enable or disable the RTC
Inputs cfg = Value for enabling or disabling RTC; use RTC_[DISABLE | ENABLE]_BITBAND
Outputs None
Assumptions None
Example /* Enable the RTC timer. */
Sys_RTC_Start(RTC_ENABLE_BITBAND);
www.onsemi.com
352
ON Semiconductor
9.155 SYS_RTC_VALUE
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_rtc.h
Template void Sys_RTC_Value(uint32_t cfg)
Description Read the current value of the RTC timer
Inputs None
Outputs return value = RTC timer counter current value
Assumptions None
Example /* Read the value of the RTC timer. */
result = Sys_RTC_Value();
www.onsemi.com
353
RSL10 Firmware Reference
9.156 SYS_SPI_CONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_spi.h
Template void Sys_SPI_Config(uint32_t num, uint32_t cfg)
Description Configure the specified SPI interface's operation and controller information
Inputs num = SPI interface to configure; use 0 or 1
cfg = Interface operation configuration; use SPI*_OVERRUN_INT_[DISABLE |
ENABLE], SPI*_UNDERRUN_INT_[DISABLE | ENABLE],
SPI*_CONTROLLER_[CM3 | DMA], SPI*_SELECT_[MASTER | SLAVE],
SPI*_CLK_POLARITY_[NORMAL | INVERSE],
SPI*_MODE_SELECT_[MANUAL | AUTO], SPI*_[DISABLE | ENABLE] and
SPI*_PRESCALE_*
Outputs None
Assumptions None
Example /* Configure SPI0 for master-mode writes of 16-bit data (controlled
* by the ARM Cortex-M3 processor), running the SPI0 at 1/4 of the
* system clock frequency. */
Sys_SPI_Config(0, SPI0_OVERRUN_INT_DISABLE |
SPI0_UNDERRUN_INT_DISABLE |
SPI0_CONTROLLER_CM3 |
SPI0_SELECT_MASTER |
SPI0_CLK_POLARITY_NORMAL |
SPI0_MODE_SELECT_AUTO |
SPI0_ENABLE |
SPI0_PRESCALE_4);
Sys_SPI_TransferConfig(0, SPI0_IDLE |
SPI0_WRITE_DATA |
SPI0_CS_1 |
SPI0_WORD_SIZE_16);
www.onsemi.com
354
ON Semiconductor
9.157 SYS_SPI_DIOCONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_spi.h
Template void Sys_SPI_DIOConfig(uint32_t num, uint32_t slave, uint32_t cfg,
uint32_t clk, uint32_t cs, uint32_t seri, uint32_t sero)
Description Configure four DIOs for the specified SPI interface
Inputs num = SPI interface to configure; use 0 or 1
slave = SPI master/slave configuration; use SPI*_SELECT_[MASTER | SLAVE]
cfg = DIO pin configuration for the SPI pads
clk = DIO to use as the SPI clock pad
cs = DIO to use as the SPI chip select pad
seri = DIO to use as the SPI serial input pad
sero = DIO to use as the SPI serial output pad
Outputs None
Assumptions None
Example /* Configure DIOs 5, 6, 7, and 8 as SPI interface 1 in slave mode */
Sys_SPI_DIOConfig(1, SPI1_SELECT_SLAVE, APP_DIO_CFG, 5, 6, 7, 8);
www.onsemi.com
355
RSL10 Firmware Reference
9.158 SYS_SPI_MASTERINIT
Initialize an SPI operation on a specified SPI interface when running this interface in master mode
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_spi.h
Template void Sys_SPI_MasterInit(uint32_t num)
Description Initialize an SPI operation on a specified SPI interface when running this interface in master mode
Inputs num = SPI interface to configure; use 0 or 1
Outputs None
Assumptions The SPI interface is currently idle
The SPI interface is configured for master mode operation
If writing over the SPI interface, the data to be written has been queued
Example /* Read the latest word from SPI0 before starting the next
* transfer. */
tempData = SPI0->RX_DATA;
Sys_SPI_MasterInit(0);
www.onsemi.com
356
ON Semiconductor
9.159 SYS_SPI_READ
Configure the interface to read the specified number of bits over the specified SPI interface
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_spi.h
Template void Sys_SPI_Read(uint32_t num, uint8_t bits)
Description Configure the interface to read the specified number of bits over the specified SPI interface
Inputs num = SPI interface to read from; use 0 or 1
bits = Word size used by the SPI interface; use SPI*_WORD_SIZE_*
Outputs None
Assumptions The SPI interface is currently idle
The SPI interface is configured for master mode operation
Example /* Read the latest word from SPI0 before reading the next SPI0
* byte. */
tempData = SPI0->RX_DATA;
Sys_SPI_Read(0, 8);
www.onsemi.com
357
RSL10 Firmware Reference
9.160 SYS_SPI_READWRITE
Configure the interface to read and write the specified number of bits over the specified SPI interface
(full-duplex)
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_spi.h
Template void Sys_SPI_ReadWrite(uint32_t num, uint8_t bits)
Description Configure the interface to read and write the specified number of bits over the specified SPI interface
(full-duplex)
Inputs num = SPI interface to read from; use 0 or 1
bits = Number of bits to transmit and receive (between 1 and 32)
Outputs None
Assumptions The SPI interface is currently idle
The SPI interface is configured for master mode operation
The data to be written has been queued
Example /* Echo back to slave device the most recently received SPI0 word,
* while reading the next word. */
SPI0->TX_DATA = SPI0->RX_DATA;
Sys_SPI_ReadWrite(0, 32);
www.onsemi.com
358
ON Semiconductor
9.161 SYS_SPI_TRANSFERCONFIG
Configure the SPI transfer information for the specified SPI interface
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_spi.h
Template void Sys_SPI_TransferConfig(uint32_t num, uint32_t cfg)
Description Configure the SPI transfer information for the specified SPI interface
Inputs num = SPI interface to configure; use 0 or 1
cfg = Interface transfer configuration; use SPI*_[IDLE | START], SPI*_[WRITE |
READ | RW]_DATA, SPI*_CS_*, and SPI*_WORD_SIZE_* or a constant
shifted to SPI*_CTRL1_SPI0_WORD_SIZE_Pos
Outputs None
Assumptions None
Example /* Configure SPI0 for master-mode writes of 32-bit data
* (controlled by the ARM Cortex-M3 processor), running the SPI0
* at 1/2 of the system clock frequency. */
Sys_SPI_Config(0, SPI0_OVERRUN_INT_DISABLE |
SPI0_UNDERRUN_INT_DISABLE |
SPI0_CONTROLLER_CM3 |
SPI0_SELECT_MASTER |
SPI0_CLK_POLARITY_NORMAL |
SPI0_MODE_SELECT_AUTO |
SPI0_ENABLE |
SPI0_PRESCALE_2);
Sys_SPI_TransferConfig(0, SPI0_IDLE |
SPI0_WRITE_DATA |
SPI0_CS_1 |
SPI0_WORD_SIZE_32);
www.onsemi.com
359
RSL10 Firmware Reference
9.162 SYS_SPI_WRITE
Configure the interface to write the specified number of bits over the specified SPI interface
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_spi.h
Template void Sys_SPI_Write(uint32_t num, uint8_t bits)
Description Configure the interface to write the specified number of bits over the specified SPI interface
Inputs num = SPI interface to read from; use 0 or 1
bits = Number of bits to transmit (between 1 and 32)
Outputs None
Assumptions The SPI interface is currently idle
The SPI interface is configured for master mode operation
The data to be written has been queued
Example /* Queue up and transmit the next SPI0 byte. */
SPI0->TX_DATA = tempData;
Sys_SPI_Write(0, 8);
www.onsemi.com
360
ON Semiconductor
9.163 SYS_TIMER_BBCONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_timers.h
Template void Sys_Timer_BBConfig(uint32_t cfg)
Description Configure the baseband timer
Inputs cfg = Value for configuration of the baseband timer clock; use: BB_TIMER_[RESET |
NRESET], BB_CLK_PRESCALE_*
Outputs None
Assumptions None
Example /* Reset and configure the baseband timer with prescale 1. */
Sys_Timer_BBConfig(BB_TIMER_RESET | BB_CLK_PRESCALE_1);
www.onsemi.com
361
RSL10 Firmware Reference
9.164 SYS_TIMER_GET_STATUS
Return the current running or stopped status of the specified general-purpose system timer
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_timers.h
Template uint32_t Sys_Timer_Get_Status(uint32_t num)
Description Return the current running or stopped status of the specified general-purpose system timer
Inputs num = Timer to read status from; use 0, 1, 2, or 3
Outputs return value = The current timer status; value loaded from
TIMER_CTRL_[*].TIMER_STATUS_ALIAS
Assumptions None
Example /* Get current running or stopped status of timer 0. */
status = Sys_Timer_Get_Status(0);
www.onsemi.com
362
ON Semiconductor
9.165 SYS_TIMER_SET_CONTROL
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_timers.h
Template void Sys_Timer_Set_Control(uint32_t num, uint32_t cfg)
Description Set up a general-purpose system timer
Inputs num = Timer to configure; use 0, 1, 2, or 3
cfg = Control configuration for the specified timer; use TIMER_MULTI_COUNT_*,
TIMER_[SHOT_MODE | FREE_RUN], TIMER_PRESCALE_* and a timeout
count setting
Outputs None
Assumptions None
Example /* Configure general-purpose timer 0 as a free-running timer,
* triggering every second for a slow clock of 1.28 MHz. */
Sys_Timer_Set_Control(0, TIMER_FREE_RUN | TIMER_PRESCALE_32 | 40000);
www.onsemi.com
363
RSL10 Firmware Reference
9.166 SYS_TIMERS_START
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_timers.c
Template void Sys_Timers_Start(uint32_t cfg)
Description Start the specified general-purpose system timers
Inputs cfg = Timers to start; use the SELECT_TIMER* settings or SELECT_[ALL |
NO]_TIMERS to indicate which timers to start
Outputs None
Assumptions None
Example /* Start timer 0 and timer 2. */
Sys_Timers_Start(SELECT_TIMER0 | SELECT_TIMER2);
www.onsemi.com
364
ON Semiconductor
9.167 SYS_TIMERS_STOP
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_timers.c
Template void Sys_Timers_Stop(uint32_t cfg)
Description Stop the specified general-purpose system timers
Inputs cfg = Timers to stop; use the SELECT_TIMER* settings or SELECT_[ALL |
NO]_TIMERS to indicate which timers to stop
Outputs None
Assumptions None
Example /* Stop timer 0 and timer 2. */
Sys_Timers_Stop(SELECT_TIMER0 | SELECT_TIMER2);
www.onsemi.com
365
RSL10 Firmware Reference
9.168 SYS_UART_DIOCONFIG
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_uart.h
Template void Sys_UART_DIOConfig(uint32_t cfg, uint32_t tx, uint32_t rx)
Description Configure two DIOs for the specified UART interface
Inputs cfg = DIO pin configuration for the UART pads
tx = DIO to use as the UART transmit pad
rx = DIO to use as the UART receive pad
Outputs None
Assumptions None
Example /* Configure DIOs 9 and 10 as UART interface 1. */
Sys_UART_DIOConfig(APP_DIO_CFG, 9, 10);
www.onsemi.com
366
ON Semiconductor
9.169 SYS_UART_DISABLE
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_uart.h
Template void Sys_UART_Disable(void)
Description Disable the UART
Inputs None
Outputs None
Assumptions None
Example /* Disable the UART0 interface. */
Sys_UART_Disable();
www.onsemi.com
367
RSL10 Firmware Reference
9.170 SYS_WAIT_FOR_EVENT
Hold the ARM Cortex-M3 core waiting for an event, interrupt request, abort or debug entry request (ARM
Thumb-2 WFE instruction)
Type Macro
Include File #include <rsl10.h>
Source File rsl10_sys_cm3.h
Template SYS_WAIT_FOR_EVENT
Description Hold the ARM Cortex-M3 core waiting for an event, interrupt request, abort or debug entry request (ARM
Thumb-2 WFE instruction)
Inputs None
Outputs None
Assumptions None
Example /* Wait for an event, interrupt request, abort or debug entry
* request. */
SYS_WAIT_FOR_EVENT;
www.onsemi.com
368
ON Semiconductor
9.171 SYS_WAIT_FOR_INTERRUPT
Hold the ARM Cortex-M3 core waiting for an interrupt request, abort or debug entry request (ARM Thumb-2
WFI instruction)
Type Macro
Include File #include <rsl10.h>
Source File rsl10_sys_cm3.h
Template SYS_WAIT_FOR_INTERRUPT
Description Hold the ARM Cortex-M3 core waiting for an interrupt request, abort or debug entry request (ARM Thumb-2
WFI instruction)
Inputs None
Outputs None
Assumptions None
Example /* Wait for an interrupt request, abort or debug entry request. */
SYS_WAIT_FOR_INTERRUPT;
www.onsemi.com
369
RSL10 Firmware Reference
9.172 SYS_WATCHDOG_REFRESH
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_watchdog.h
Template void Sys_Watchdog_Refresh(void)
Description Refresh the watchdog timer count
Inputs None
Outputs None
Assumptions None
Example /* Refresh the watchdog timer count. */
Sys_Watchdog_Refresh();
www.onsemi.com
370
ON Semiconductor
9.173 SYS_WATCHDOG_SET_TIMEOUT
Type Function
Include File #include <rsl10.h>
Source File rsl10_sys_watchdog.h
Template void Sys_Watchdog_Set_Timeout(uint32_t timeout)
Description Set the watchdog timeout period
Inputs timeout = Timeout value for watchdog; use WATCHDOG_TIMEOUT_*
Outputs None
Assumptions None
Example /* Set up watchdog timeout value to 2.048ms for a 1MHz watchdog
* input clock. */
Sys_Watchdog_Set_Timeout(WATCHDOG_TIMEOUT_2M048);
www.onsemi.com
371
CHAPTER 10
10. Math Library Reference
This reference chapter presents a detailed description of all the functions in the ARM Cortex-M3 core math
library, including calling parameters, returned values, and assumptions.
10.1 MATH_ADD_FRAC32
Type Function
Include File #include <rsl10_math.h>
Source File rsl10_math_frac32.c
Template int32_t Math_Add_frac32(int32_t x, int32_t y)
Description Add two 32-bit signed fractional numbers, then saturate. The result is one of the following:
• (x + y), if MIN_FRAC32 <= (x + y) <= MAX_FRAC32
• MAX_FRAC32, if (x + y) > MAX_FRAC32
• MIN_FRAC32, if (x + y) < MIN_FRAC32
Inputs x = Fractional number represented as a 32 bit integer
y = Fractional number represented as a 32 bit integer
Outputs z = (x + y) with saturation
Assumptions None
Example /* Addition with saturation: add two 32-bit signed fractional
* numbers, then saturate to 0x7FFFFFFF if positive overflow
* occurs, or 0x80000000 if negative overflow occurs. */
z = Math_Add_frac32(x, y);
www.onsemi.com
372
ON Semiconductor
10.2 MATH_ATTACKRELEASE
Type Function
Include File #include <rsl10_math.h>
Source File rsl10_math_float.c
Template float Math_AttackRelease(float a, float b, float x, float y1)
Description Calculate a first-order attack-release filter. The outputs of the attack-release filter are calculated as:
• y[n] = beta * x[n] + (1 - beta) * y[n-1]
Where:
• beta = a if x[n] >= y[n-1]
• beta = b if x[n] < y[n-1]
• a is the coefficient for attack, 0 < a < 1
• b is the coefficient for release, 0 < b < 1
Inputs a = Filter coefficient
b = Filter coefficient
x = Current input
y1 = Previous output
Outputs y = New output
Assumptions None
Example /* Dual-time constant attack release averaging filter: generate new
* output data based on the filter coefficients a and b, new input
* data data_in, and previous output data data_out. */
data_out = Math_AttackRelease(a, b, data_in, data_out);
www.onsemi.com
373
RSL10 Firmware Reference
10.3 MATH_ATTACKRELEASE_FRAC32
Type Function
Include File #include <rsl10_math.h>
Source File rsl10_math_frac32.c
Template int32_t Math_AttackRelease_frac32(int32_t a, int32_t b, int32_t x,
int32_t y1)
Description Calculate a fixed-point first-order attack-release filter. The outputs of the attack-release filter are calculated as:
• y[n] = beta * x[n] + (1 - beta) * y[n-1]
Where:
• beta = a if x[n] >= y[n-1]
• beta = b if x[n] < y[n-1]
• a is the coefficient for attack, 0 < a < 1
• b is the coefficient for release, 0 < b < 1
Inputs a = Filter coefficient
b = Filter coefficient
x = Current input
y1 = Previous output
Outputs y = New output
Assumptions None
Example /* Dual-time constant attack release averaging filter: generate new
* output data based on the filter coefficients a and b, new input
* data data_in, and previous output data data_out. All input and
* output types are 32-bit signed fractional. */
data_out = Math_AttackRelease_frac32(a, b, data_in, data_out);
www.onsemi.com
374
ON Semiconductor
10.4 MATH_EXPAVG
Type Function
Include File #include <rsl10_math.h>
Source File rsl10_math_float.c
Template float Math_ExpAvg(float alpha, float x, float y1)
Description Calculate a first-order exponential average. The outputs of the exponential average are calculated as:
• y[n] = alpha * x[n] + (1 - alpha) * y[n-1]
Where:
• 0 < alpha < 1
Inputs alpha = Filter coefficient
x = Current input
y1 = Previous output
Outputs y = New output
Assumptions None
Example /* Exponential moving average filter: generate new output data based
* on the filter coefficient alpha, new input data data_in, and
* previous output data data_out. */
data_out = Math_ExpAvg(alpha, data_in, data_out);
www.onsemi.com
375
RSL10 Firmware Reference
10.5 MATH_EXPAVG_FRAC32
Type Function
Include File #include <rsl10_math.h>
Source File rsl10_math_frac32.c
Template int32_t Math_ExpAvg_frac32(int32_t alpha, int32_t x, int32_t y1)
Description Calculate a fixed-point first-order exponential average. The outputs of the exponential average are calculated
as:
• y[n] = alpha * x[n] + (1 - alpha) * y[n-1]
Where:
• 0 < alpha < 1
Inputs alpha = Filter coefficient
x = Current input
y1 = Previous output
Outputs y = New output
Assumptions None
Example /* Exponential moving average filter: generate new output data based
* on the filter coefficient alpha, new input data data_in, and
* previous output data data_out. All input and output types are
* 32-bit signed fractional. */
data_out = Math_ExpAvg_frac32(alpha, data_in, data_out);
www.onsemi.com
376
ON Semiconductor
10.6 MATH_LINEARINTERP
Type Function
Include File #include <rsl10_math.h>
Source File rsl10_math_float.c
Template float Math_LinearInterp(float x0, float x1, float y0, float y1, float x)
Description Calculate linear interpolation on the interval [x0, x1). The interpolation is calculated as:
• y = y0 + ((y1 - y0) / (x1 - x0)) * (x - x0)
Inputs x0 = First boundary point x-axis value
x1 = Second boundary point x-axis value
y0 = First boundary point y-axis value
y1 = Second boundary point y-axis value
x = Interpolation point
Outputs y = Interpolated value
Assumptions x0 != x1
Example /* Linear interpolation on the interval [x0, x1) with boundary points
* (x0, y0) and (x1, y1). */
y = Math_LinearInterp(x0, x1, y0, y1, x);
www.onsemi.com
377
RSL10 Firmware Reference
10.7 MATH_LINEARINTERP_FRAC32
Type Function
Include File #include <rsl10_math.h>
Source File rsl10_math_frac32.c
Template int32_t Math_LinearInterp_frac32(int32_t y0, int32_t y1, int32_t x)
Description Calculate fixed-point linear interpolation on the interval [0, 1). The interpolation is calculated as:
• y = y0 + x * (y1 - y0)
Inputs y0 = Left boundary point
y1 = Right boundary point
x = Interpolation point
Outputs y = Interpolated value
Assumptions 0 <= x < 1
Example /* Linear interpolation on the interval [0, 1) with boundary points
* y0 and y1. */
y = Math_LinearInterp_frac32(y0, y1, x);
www.onsemi.com
378
ON Semiconductor
10.8 MATH_MULT_FRAC32
Type Function
Include File #include <rsl10_math.h>
Source File rsl10_math_frac32.c
Template int32_t Math_Mult_frac32(int32_t x, int32_t y)
Description Multiply two 32-bit signed fractional numbers, then saturate. The result is either:
• x * y, if x > MIN_FRAC32 or y > MIN_FRAC32
• MAX_FRAC32, if x = MIN_FRAC32 and y = MIN_FRAC32
Inputs x = Fractional number represented as a 32 bit integer
y = Fractional number represented as a 32 bit integer
Outputs z = (x * y) with saturation
Assumptions None
Example /* Multiplication with saturation: multiply two 32-bit signed
* fractional numbers, then saturate to 0x7FFFFFFF if overflow
* occurs. */
z = Math_Mult_frac32(x, y);
www.onsemi.com
379
RSL10 Firmware Reference
10.9 MATH_SINGLEVAR_REG
Find the least-squares solution for a single variable linear regression model
Type Function
Include File #include <rsl10_math.h>
Source File rsl10_math_float.c
Template void Math_SingleVar_Reg(float* x, float* y, unsigned int N, float* a)
Description Find the least-squares solution for a single variable linear regression model. A linear regression model with a
single predictor variable can be represented as:
• y[i] = a0 + a1 * x[i] + e[i], i = 0, 1, 2, ..., N-1
Inputs x = Pointer to the input variable vector x[]
y = Pointer to the dependent variable vector y[]
N = Length of vector x[] and y[]
Outputs a = Pointer to the coefficient vector {a0, a1}
Assumptions x[] and y[] are of the same length
x[] is not a constant vector (constant vector here means x[0] = x[1] = ... = x[N-1])
a is a pointer to a coefficient vector of length 2
Example /* For an input variable vector x[] and a dependent variable vector
* y[], find the least-squares solution to the linear regression
* model. */
Math_SingleVar_Reg(x, y, DATA_LENGTH, coeff_vector);
www.onsemi.com
380
ON Semiconductor
10.10 MATH_SUB_FRAC32
Subtract one 32-bit signed fractional number from another, then saturate
Type Function
Include File #include <rsl10_math.h>
Source File rsl10_math_frac32.c
Template int32_t Math_Sub_frac32(int32_t x, int32_t y)
Description Subtract one 32-bit signed fractional number from another, then saturate. The result is one of the following:
• (x - y), if MIN_FRAC32 <= (x - y) <= MAX_FRAC32
• MAX_FRAC32, if (x - y) > MAX_FRAC32
• MIN_FRAC32, if (x - y) < MIN_FRAC32
Inputs x = Fractional number represented as a 32 bit integer
y = Fractional number represented as a 32 bit integer
Outputs z = (x - y) with saturation
Assumptions None
Example /* Subtract with saturation: subtract one 32-bit signed fractional
* number from another, then saturate to 0x7FFFFFFF if positive
* overflow occurs, or 0x80000000 if negative overflow occurs. */
z = Math_Sub_frac32(x, y);
www.onsemi.com
381
CHAPTER 11
11. Flash Library Reference
This reference chapter presents a detailed description of all the functions in the flash write support library,
including calling parameters, returned values, and assumptions. Warning: All functions provided by the flash library
should be executed from RAM or ROM, as executing them from flash can result in hidden, flash-access-related
failures.
11.1 FLASH_ERASEALL
Type Function
Include File #include <rsl10_flash.h>
Source File rsl10_flash.c
Template unsigned int Flash_EraseAll(void)
Description Erase all of the sectors in the main block of the flash
Inputs None
Outputs return value = Status code indicating whether the requested flash operation succeeded
Assumptions The calling application has unlocked all of the main flash instance, and any NVR or redundancy sectors that
should be erased
If the flash is in sequential programming mode, it is safe to exit this mode
Example /* Configure the flash to allow writing to the whole flash */
FLASH->MAIN_WRITE_UNLOCK = FLASH_MAIN_KEY;
FLASH->MAIN_CTRL = (MAIN_LOW_W_ENABLE | MAIN_MIDDLE_W_ENABLE |
MAIN_HIGH_W_ENABLE);
www.onsemi.com
382
ON Semiconductor
11.2 FLASH_ERASESECTOR
Type Function
Include File #include <rsl10_flash.h>
Source File rsl10_flash.c
Template unsigned int Flash_EraseSector(unsigned int addr)
Description Erase the specified flash sector. This sector could be in the main flash, one of the NVR sectors, or one of the
redundancy sectors. Verify the sector was erased, progressively trying the different sector erase pulses until
one successfully erases the sector.
Inputs addr = Address of data in the sector to be erased
Outputs return value = Status code indicating whether the requested flash operation succeeded
Assumptions The calling application has unlocked the flash for erase
If the flash is in sequential programming mode, it is safe to exit this mode
None of the RECALL, VREAD0_MODE and VREAD1_MODE bits are set in FLASH_IF_CTRL
Example /* Configure the flash to allow writing to the lower flash area */
FLASH->MAIN_WRITE_UNLOCK = FLASH_MAIN_KEY;
FLASH->MAIN_CTRL = MAIN_LOW_W_ENABLE;
www.onsemi.com
383
RSL10 Firmware Reference
11.3 FLASH_WRITEBUFFER
Write a buffer of memory of the specified length, starting at the specified address, to flash
Type Function
Include File #include <rsl10_flash.h>
Source File rsl10_flash.c
Template unsigned int Flash_WriteBuffer(unsigned int start_addr, unsigned int
length, unsigned int* data)
Description Write a buffer of memory of the specified length, starting at the specified address, to flash
Inputs start_addr = Start address for the write to flash
length = Number of words to write to flash
data = Pointer to the data to write to flash
Outputs return value = Status code indicating whether the requested flash operation succeeded
Assumptions The calling application has unlocked the flash for write
The areas of flash to be written have been previously erased (if necessary) and are not currently write
protected
"data" points to a buffer of at least "length" words
The address in flash is even word aligned
The number of words to write is an even number
If the flash is already in sequential programming mode, it is safe to exit this mode to perform the buffered write.
None of the RECALL, VREAD0_MODE and VREAD1_MODE bits are set in FLASH_IF_CTRL
Example /* Configure the flash to allow writing to the lower flash area */
FLASH->MAIN_WRITE_UNLOCK = FLASH_MAIN_KEY;
FLASH->MAIN_CTRL = MAIN_LOW_W_ENABLE;
/* Write the first words of the main flash with data from a
* previously loaded buffer (assumes this sector has been
* previously erased) */
Flash_WriteBuffer(FLASH_MAIN_BASE, bufferLength, buffer);
www.onsemi.com
384
ON Semiconductor
11.4 FLASH_WRITECOMMAND
Safely issue a flash command; blocks waiting for the flash to be idle before running the command and again
before returning
Type Function
Include File #include <rsl10_flash.h>
Source File rsl10_flash.c
Template void Flash_WriteCommand(uint32_t command)
Description Safely issue a flash command; blocks waiting for the flash to be idle before running the command and again
before returning.
Inputs command = Command to be written to FLASH_CMD_CTRL; use CMD_*
Outputs return value = Status code indicating whether the flash interface can be written; returns
FLASH_ERR_INACCESSIBLE if the flash is isolated or not powered, otherwise
returns no error.
Assumptions None
Example /* Force a wakeup the flash */
Flash_WriteCommand(CMD_WAKE_UP);
www.onsemi.com
385
RSL10 Firmware Reference
11.5 FLASH_WRITEINTERFACECONTROL
Safely write the interface control register; blocks waiting for the flash to be idle before writing the interface
control register, and again before returning
Type Function
Include File #include <rsl10_flash.h>
Source File rsl10_flash.c
Template void Flash_WriteInterfaceControl(uint32_t ctrl)
Description Safely write the interface control register; blocks waiting for the flash to be idle before writing the interface
control register, and again before returning.
Inputs ctrl = Data to write to the FLASH_IF_CTRL register
Outputs return value = Status code indicating whether the flash interface can be written; returns
FLASH_ERR_INACCESSIBLE if the flash is isolated or not powered and
LP_MODE, RECALL, VREAD0_MODE or VREAD1_MODE are being changed,
otherwise returns no error.
Assumptions If the flash is in sequential programming mode, it is safe to exit this mode
No more than two of the LP_MODE, RECALL, VREAD0_MODE and VREAD1_MODE bits are being updated
in FLASH_IF_CTRL
Example /* Disable the flash recall settings */
Flash_WriteInterfaceControl(FLASH_RECALL_DISABLE);
www.onsemi.com
386
ON Semiconductor
11.6 FLASH_WRITEWORDPAIR
Type Function
Include File #include <rsl10_flash.h>
Source File rsl10_flash.c
Template unsigned int Flash_WriteWordPair(unsigned int addr, unsigned int data0,
unsigned int data1)
Description Write a word pair of flash at the specified address
Inputs addr = Address to write in the flash
data0 = First data word to write to the specified address in flash
data1 = Second data word to write to the specified (address + 4) in flash
Outputs return value = Status code indicating whether the requested flash operation succeeded
Assumptions The calling application has unlocked the flash for write
The area of flash to be written has been previously erased (if necessary) and is not currently write protected
If the flash is in sequential programming mode, it is safe to exit this mode
None of the RECALL, VREAD0_MODE and VREAD1_MODE bits are set in FLASH_IF_CTRL
Example /* Configure the flash to allow writing to the lower flash area */
FLASH->MAIN_WRITE_UNLOCK = FLASH_MAIN_KEY;
FLASH->MAIN_CTRL = MAIN_LOW_W_ENABLE;
/* Write the first word of the main flash with a test value (assumes
* this sector has been previously erased) */
Flash_WriteWordPair(FLASH_MAIN_BASE, 0x12345678, 0x9ABCDEF0);
www.onsemi.com
387
CHAPTER 12
12. Calibration Library Reference
This reference chapter presents a detailed description of all the functions in the calibration support library,
including calling parameters, returned values, and assumptions.
12.1 CALIBRATE_CLOCK_32K_RCOSC
Type Function
Include File #include <rsl10_calibrate.h>
Source File rsl10_calibrate_clock.c
Template unsigned int Calibrate_Clock_32K_RCOSC(uint32_t target)
Description Used to calibrate the 32K RC oscillator to a specified frequency.
Inputs target = Number of cycles required to achieve the Desired clock frequency in Hz
Outputs return value = Status code indicating whether the RCOSC calibration succeeded
Assumptions Calibrate_Clock_Initialize() has been called.
Example /* Calibrate the 32K RC oscillator to 30000 Hz */
result = Calibrate_Clock_32K_RCOSC(30000);
www.onsemi.com
388
ON Semiconductor
12.2 CALIBRATE_CLOCK_INITIALIZE
Initialize the system to support the clock calibration, consisting of the 48 MHz XTAL oscillator and RC oscillator
Type Function
Include File #include <rsl10_calibrate.h>
Source File rsl10_calibrate_clock.c
Template void Calibrate_Clock_Initialize(void)
Description Initialize the system to support the clock calibration, consisting of the 48 MHz XTAL oscillator and RC
oscillator.
Inputs None
Outputs None
Assumptions None
Example /* Initialize the system for clock calibration. */
Calibrate_Clock_Initialize();
www.onsemi.com
389
RSL10 Firmware Reference
12.3 CALIBRATE_CLOCK_START_OSC
Type Function
Include File #include <rsl10_calibrate.h>
Source File rsl10_calibrate_clock.c
Template unsigned int Calibrate_Clock_Start_OSC(uint32_t target)
Description Used to calibrate the startup oscillator to a specified frequency.
Inputs target = Desired clock frequency in kHz
Outputs return value = Status code indicating whether the clock succeeded
Assumptions Calibrate_Clock_Initialize() has been called.
Example /* Calibrate the startup oscillator to 3 MHz */
result = Calibrate_Clock_Start_OSC(3000);
www.onsemi.com
390
ON Semiconductor
12.4 CALIBRATE_POWER_DCDC
Type Function
Include File #include <rsl10_calibrate.h>
Source File rsl10_calibrate_power.c
Template unsigned int Calibrate_Power_DCDC(unsigned int adc_num, uint32_t
*adc_ptr, uint32_t target)
Description Calibrate the DC-DC converter (DCDC).
Inputs adc_num = ADC channel number [0-7]
adc_ptr = Pointer to the ADC data register
target = Target voltage readback [10*mV]
Outputs return value = Status code indicating whether the calibration succeeded
Assumptions VBG has been calibrated.
Calibrate_Power_Initialize() has been called.
Example /* Calibrate the DC-DC converter to 125 10*mV. */
result = Calibrate_Power_DCDC(0, (uint32_t *)&ADC->DATA_TRIM_CH[0],
125);
www.onsemi.com
391
RSL10 Firmware Reference
12.5 CALIBRATE_POWER_INITIALIZE
The initialization function does the following tasks: 1) Changes settings in all power supply control registers to
their default values
Type Function
Include File #include <rsl10_calibrate.h>
Source File rsl10_calibrate_power.c
Template void Calibrate_Power_Initialize(void)
Description The initialization function does the following tasks: 1) Changes settings in all power supply control registers to
their default values. 2) Sets the system clock source to RFCLK/3 (16 MHz). 3) Configures the ADC to enable
measurement at 100 Hz
Inputs None
Outputs None
Assumptions VBAT must be less than or equal to 1.3 V
Example /* Initialize the system for power supply calibration and configure
* ADC to be measured. */
Calibrate_Power_Initialize();
www.onsemi.com
392
ON Semiconductor
12.6 CALIBRATE_POWER_VBG
Calibrate the bandgap voltage (VBG) against a specified VBAT supply voltage
Type Function
Include File #include <rsl10_calibrate.h>
Source File rsl10_calibrate_power.c
Template unsigned int Calibrate_Power_VBG(unsigned int adc_num, uint32_t
*adc_ptr, uint32_t target)
Description Calibrate the bandgap voltage (VBG) against a specified VBAT supply voltage. VBG is the reference voltage
for the ADC, so it can be calibrated based on the ADC output for a known voltage, which is VBAT.
Inputs adc_num = ADC channel number [0-7]
adc_ptr = Pointer to the ADC data register
target = Target voltage readback [10*mV]
Outputs return value = Status code indicating whether the calibration succeeded
Assumptions The target band-gap is calibrated by reading the current VBAT supply using the ADC. The assumed VBAT
supply voltage is 1.25 V.
Calibrate_Power_Initialize() has been called.
Example /* Calibrate the bandgap voltage (VBG) to 75 10*mV.*/
result = Calibrate_Power_VBG(0, (uint32_t *)&ADC->DATA_TRIM_CH[0],
75);
www.onsemi.com
393
RSL10 Firmware Reference
12.7 CALIBRATE_POWER_VDDC
Type Function
Include File #include <rsl10_calibrate.h>
Source File rsl10_calibrate_power.c
Template unsigned int Calibrate_Power_VDDC(unsigned int adc_num, uint32_t
*adc_ptr, uint32_t target)
Description Calibrate the digital core voltage power supply (VDDC).
Inputs adc_num = ADC channel number [0-7]
adc_ptr = Pointer to the ADC data register
target = Target voltage readback [10*mV]
Outputs return value = Status code indicating whether the calibration succeeded
Assumptions VBG has been calibrated.
Calibrate_Power_Initialize() has been called.
Example /* Calibrate the VDDC supply to 118 10*mV. */
result = Calibrate_Power_VDDC(0, (uint32_t *)&ADC->DATA_TRIM_CH[0],
118);
www.onsemi.com
394
ON Semiconductor
12.8 CALIBRATE_POWER_VDDM
Type Function
Include File #include <rsl10_calibrate.h>
Source File rsl10_calibrate_power.c
Template unsigned int Calibrate_Power_VDDM(unsigned int adc_num, uint32_t
*adc_ptr, uint32_t target)
Description Calibrate the digital memory voltage (VDDM)
Inputs adc_num = ADC channel number [0-7]
adc_ptr = Pointer to the ADC data register
target = Target voltage readback [10*mV]
Outputs return value = Status code indicating whether the calibration succeeded
Assumptions VBG has been calibrated.
Calibrate_Power_Initialize() has been called.
Example /* Calibrate the VDDM supply to 118 10*mV. */
result = Calibrate_Power_VDDM(0, (uint32_t *)&ADC->DATA_TRIM_CH[0],
118);
www.onsemi.com
395
RSL10 Firmware Reference
12.9 CALIBRATE_POWER_VDDPA
Type Function
Include File #include <rsl10_calibrate.h>
Source File rsl10_calibrate_power.c
Template unsigned int Calibrate_Power_VDDPA(unsigned int adc_num, uint32_t
*adc_ptr, uint32_t target)
Description Calibrate the radio power amplifier power supply (VDDPA).
Inputs adc_num = ADC channel number [0-7]
adc_ptr = Pointer to the ADC data register
target = Target voltage readback [10*mV]
Outputs return value = Status code indicating whether the calibration succeeded
Assumptions VBG has been calibrated.
Calibrate_Power_Initialize() has been called.
Example /* Calibrate the VDDPA supply to 160 10*mV. */
result = Calibrate_Power_VDDPA(0, (uint32_t *)&ADC->DATA_TRIM_CH[0],
160);
www.onsemi.com
396
ON Semiconductor
12.10 CALIBRATE_POWER_VDDRF
Type Function
Include File #include <rsl10_calibrate.h>
Source File rsl10_calibrate_power.c
Template unsigned int Calibrate_Power_VDDRF(unsigned int adc_num, uint32_t
*adc_ptr, uint32_t target)
Description Calibrate the radio front-end power supply (VDDRF).
Inputs adc_num = ADC channel number [0-7]
adc_ptr = Pointer to the ADC data register
target = Target voltage readback [10*mV]
Outputs return value = Status code indicating whether the calibration succeeded
Assumptions VBG has been calibrated.
Calibrate_Power_Initialize() has been called.
VCC is sufficiently high to trim VDDRF to the desired value. This is because VCC supplies VDDRF.
Example /* Calibrate the VDDRF supply to 125 10*mV. */
result = Calibrate_Power_VDDRF(0, (uint32_t *)&ADC->DATA_TRIM_CH[0],
125);
www.onsemi.com
397
APPENDIX A
A. Glossary
The following abbreviations and terms are used in this manual:
LC link controller
LL link layer
www.onsemi.com
398
ON Semiconductor
LM link manager
PDU packet data unit; sub-packet containing a 2-byte L2CAP header and a payload
POR power-on-reset
SWD serial wire debug, two-wire interface used for communication with ARM cores
www.onsemi.com
399
RSL10 Firmware Reference
www.onsemi.com
400
ON Semiconductor
ON Semiconductor and are registered trademarks of Semiconductor Components Industries, LLC (SCILLC). ARM and Cortex are trademarks or registered
trademarks of ARM Ltd. Bluetooth is a registered trademark of Bluetooth SIG, Inc. SCILLC owns the rights to a number of patents, trademarks, copyrights, trade secrets, and
other intellectual property. A listing of SCILLC’s product/patent coverage may be accessed at www.onsemi.com/site/pdf/Patent-Marking.pdf. SCILLC reserves the right to
make changes without further notice to any products herein. SCILLC makes no warranty, representation or guarantee regarding the suitability of its products for any particular
purpose, nor does SCILLC assume any liability arising out of the application or use of any product or circuit, and specifically disclaims any and all liability, including without
limitation special, consequential or incidental damages. “Typical” parameters which may be provided in SCILLC data sheets and/or specifications can and do vary in different
applications and actual performance may vary over time. All operating parameters, including “Typicals” must be validated for each customer application by customer’s
technical experts. SCILLC does not convey any license under its patent rights nor the rights of others. SCILLC products are not designed, intended, or authorized for use as
components in systems intended for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which the failure of
the SCILLC product could create a situation where personal injury or death may occur. Should Buyer purchase or use SCILLC products for any such unintended or
unauthorized application, Buyer shall indemnify and hold SCILLC and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims, costs,
damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or
unauthorized use, even if such claim alleges that SCILLC was negligent regarding the design or manufacture of the part. SCILLC is an Equal Opportunity/Affirmative Action
Employer. This literature is subject to all applicable copyright laws and is not for resale in any manner.
M-20818-007