EasyManuals Logo
Home>Texas Instruments>Microcontrollers>CC2541

Texas Instruments CC2541 Application Guide

Texas Instruments CC2541
36 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #12 background imageLoading...
Page #12 background image
TI CC2540 Bluetooth low energy Sample Applications Guide v1.4.1 SWRU297 Version 1.4.1
Page 12 of 36
Copyright © 2011-2015 Texas Instruments, Inc
The application is implemented in the file heartrate.c.
4.2.1 Initialization
The initialization of the application occurs in two phases: first, the HeartRate_Init function is
called by the OSAL. This function configures parameters in the peripheral profile, GAP, and GAP
bond manager. It also sets up the heart rate service and the battery service along with standard
GATT and GAP services in the attribute server. Then it sets an OSAL START_DEVICE_EVT
event. This triggers the second phase of the initialization, which can be found within the
HeartRate_ProcessEvent function. During this phase, the GAPRole_StartDevice function is
called to set up the GAP functions of the application. Then GAPBondMgr_Register is called to
register with the bond manager.
4.2.2 Event Processing
The application has two main event processing functions, HeartRate_ProcessEvent and
HeartRate_ProcessOSALMsg.
Function HeartRate_ProcessEvent handles events as follows:
SYS_EVENT_MSG: Service the OSAL queue and process OSAL messages.
START_DEVICE_EVT: Start the device, as described in the previous section.
HEART_PERIODIC_EVT: Send periodic heart rate measurements.
BATT_PERIODIC_EVT: Check the battery level and send notification if it changed.
Function HeartRate_ProcessOSALMsg handles OSAL messages as follows:
KEY_CHANGE messages: Call function HeartRate_HandleKeys to handle key presses.
4.2.3 Callbacks
The application callback functions are as follows:
HeartRateGapStateCB: This is the GAP event callback. It processes GAP events for
startup and link connect/disconnect.
HeartRateCB: This is the heart rate service callback. It handles enabling or disabling
periodic heart rate measurements when notifications of the heart rate measurement are
enabled or disabled.
HeartRateBattCB: This is the battery service callback. It handles enabling or disabling
periodic battery measurements when notifications of the battery level-state are enabled or
disabled.
4.2.4 Sending Notifications
The application sends notifications of the heart rate measurement and the battery level-state
when configured to do so by the peer device.
When the peer device configures the heart rate measurement for notification the application will
receive a heart rate service callback. The application starts a timer to begin periodic simulated
heart rate measurements. When the timer expires the application calls heartRateMeasNotify to
build and send a measurement using the heat rate service API.
When the peer device configures the battery level-state for notification the application will receive
a battery service callback. The application starts a timer to periodically measure the battery level.
When the timer expires the application calls battery service API function Batt_MeasLevel to
measure the battery level using the CC2450 ADC. Notification of the battery level-state is handled
inside the battery service; if the battery level has dropped since the previous measurement a
notification is sent.
5 Cycling Speed and Cadence (CSC) Sensor
This sample project implements the Cycling Speed and Cadence (CSC) profile in a BLE
peripheral device to provide a sample application of sensor that would be placed on a bicycle,
using simulated measurement data. The application implements the Sensor” role of the Cycling

Table of Contents

Other manuals for Texas Instruments CC2541

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments CC2541 and is the answer not in the manual?

Texas Instruments CC2541 Specifications

General IconGeneral
BrandTexas Instruments
ModelCC2541
CategoryMicrocontrollers
LanguageEnglish

Related product manuals