English
Language : 

AN92584 Datasheet, PDF (11/42 Pages) Ramtron International Corporation – Designing for Low Power and Estimating Battery Life for BLE Applications
Designing for Low Power and Estimating Battery Life for BLE Applications
*
* Parameters:
* none
*
****************************************************************************/
inline void RunApplication()
{
/***********************************************************************
* Place your application code here
************************************************************************/
/* if you are done with everything and ready to go to sleep,
then set it up to go to sleep. Update the code inside if() specific
to your application*/
if(0)
{
applicationPower = SLEEP;
}
/* if you are done with everything and ready to go to deepsleep,
then set it up to go to deepsleep. Update the code inside if() specific
to your application*/
if (1)
{
applicationPower = DEEPSLEEP;
}
}
BLE Stack Event Handler
The BLE stack event handler function handles the events generated by the BLE stack. Employ the following low-
power techniques in the event-handling section soon after the BLE stack is initialized (an EVT_STACK_ON event is
received):
 [C8] Set the device sleep-clock accuracy (SCA) based on the tuned ppm of the WCO. The SCA is defined by the
Bluetooth specifications in seven subranges in the total range of 0 ppm to 500 ppm.
The code snippet for these is shown below:
void AppCallBack(uint32 event, void* eventParam)
{
CYBLE_BLESS_CLK_CFG_PARAMS_T clockConfig;
switch(event)
{
/* Handle stack events */
case CYBLE_EVT_STACK_ON:
/* C8. Get the configured clock parameters for BLE subsystem */
CyBle_GetBleClockCfgParam(&clockConfig);
/* C8. Set the device sleep-clock accuracy (SCA) based on the tuned ppm
of the WCO */
clockConfig.bleLlSca = CYBLE_LL_SCA_000_TO_020_PPM;
/* C8. Set the clock parameter of BLESS with updated values */
CyBle_SetBleClockCfgParam(&clockConfig);
/* Put the device into discoverable mode so that a Central device can
www.cypress.com
Document No. 001-92584 Rev. *A
11