English
Language : 

AN91184 Datasheet, PDF (22/36 Pages) Ramtron International Corporation – Designing BLE Applications
PSoC® 4 BLE – Designing BLE Applications
Note: Source files for the application firmware are in the example project that is included with this application note.
You can either include the source files in your own project or you can use the completed example project as-is. There
are nine source files for the example project which are listed in Table 5.
Table 5. Example Project Source Files
Name
main.c
CommonFunctions.c/.h
Temperature.c/.h
WatchdogTimer.c/.h
BLE_HTSS.c/.h
Description
This is the main firmware file. It has only one function:
 main() – This function controls the flow of the complete application. Primary tasks performed as a part of this
function are initializing the system, application control that includes processing BLE events, application flow
control, and low-power implementation.
It implements the common functions that are used for application control. It has the following functions:
 InitializeSystem() – Initializes all the blocks of the system.
 PrepareForDeepSleep – Prepares the system for low-power operation by putting the hardware blocks in the
Deep-Sleep mode.
 WakupFromDeepSleep() – Restores the hardware blocks for normal operation.
It implements the temperature measurement by reading the measured data from the ADC and calculating the
temperature using the Thermistor Calculator Component. It also provides an option to the user to simulate the
temperature instead of measuring it from the temperature sensor. It has the following functions:
 MeasureSensorVoltage() – This function measures the sensor voltage. This function is not available when the
sensor simulation option is selected. For more details, refer to the Sensor Simulation section.
 ProcessTemperature() – This function measures or simulates the temperature value.
It implements the watchdog timer functionality and keeps track of the system time. It has the following functions:
 WatchdogTimer_Start() – Starts the watchdog timer (WDT0) with a 1-s period and an interrupt on match.
 WatchdogTimer_Isr() – The ISR for the WDT; it is used to track the measurement interval. This function is a
callback from the watchdog timer.
 WatchdogTimer_Stop() – Stops the watchdog timer (WDT0).
It handles the BLE-specific functionality of the project. It handles the events generated from the BLE stack,
explained in detail in the Event Handler section. It has the following functions:
 GenericEventHandler() – Handles the generic events generated by the BLE stack.
 HtssEventHandler() – Handles the events generated for the Health Thermometer Service.
 ProcessBLE() – Sends the temperature data as Indication to the GATT Client.
 EnableBLE() – Starts the BLE Component and registers the event handler functions.
The following sections explain the operation of the Health Thermometer application. Note that the complete firmware
is not included in this document. Instead, the key concepts are explained in detail. Refer to the included example
project for the complete firmware.
The Health Thermometer application state machine consists of four states:
 System Initialization
 Event Handler
 Generic Event Handler
 Health Thermometer Event Handler
 System Normal Operation
 System Low-Power Operation
These states are discussed in detail in the following sections.
www.cypress.com
Document No. 001-91184 Rev. *B
22