KW36 - HeartRate_PowerDownMode_Switch??

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

KW36 - HeartRate_PowerDownMode_Switch??

1,629 Views
ayden
Contributor II

Hi,

I'm testing an example of heart rate. (frdmkw36_wireless_examples_bluetooth_hrs_freertos)

 The Switch is different when power down mode is set and not set.

1. The SW3 operate as gKBD_EventPressPB1_c when the power-down mode is set to "1".

2. The SW2 operate as gKBD_EventPressPB1_c when the power-down mode is set to "0".

--------------------------------------------------------------------------------------------------------------------------

/* Enable/Disable PowerDown functionality in PwrLib */
#define cPWR_UsePowerDownMode 0 // (1)

void BleApp_HandleKeys(key_event_t events)
{
#if (cPWR_UsePowerDownMode)
switch (events)
{
   case gKBD_EventPressPB1_c: //SW3 ??
   case gKBD_EventPressPB2_c:
   {
      if (mPeerDeviceId == gInvalidDeviceId_c)
      {
         BleApp_Start();
      }
      break;
   }
   case gKBD_EventLongPB1_c:
   case gKBD_EventLongPB2_c:
   {
      if (mPeerDeviceId != gInvalidDeviceId_c)
      {
         Gap_Disconnect(mPeerDeviceId);
      }
      break;
   }
   default:
   break;
}
#else
switch (events)
{
   case
gKBD_EventPressPB1_c: //SW2 ??
   {

--------------------------------------------------------------------------------------------------------------------------

Plz, Let me know if this is normal.

Labels (2)
0 Kudos
Reply
3 Replies

1,543 Views
Sebastian_Del_Rio
NXP Employee
NXP Employee

Hi Ayden, I hope you're doing well!

 

The keyboard assignments are not changed when enabling the cPWR_UsePowerDownMode macro definition.

 

On the switch case statement in the keyboard handler, when using low power mode, either switch can be pressed to start advertising.

This is because there's not a "break;" statement after the "gKBD_EventPressPB1_c", which means that the code will keep executing until it reaches the "break;" in the gKBD_EventPressPB2_c event. 

When Power Down mode is enabled in this application, both PB are assigned to the same action, but when Power Down is disabled, SW2 starts advertising, and SW3 toggles 16bit Heart Rate. 

 

Please let me know if you need any more information.

 

Take care, best regards,

Sebastian

0 Kudos
Reply

1,543 Views
ayden
Contributor II

Hi, Sebastian.

I checked again about what you mentioned.

When I set up cPWR_UsePowerDownMode, only SW3 works.

* Push SW3 ==> gKBD_EventPressPB1_c

And if cPWR_UsePowerDownMode is not set, SW2 and SW3 operate.

* Push SW2 ==> gKBD_EventPressPB1_c

* Push SW3 ==> gKBD_EventPressPB2_c

--------------------------------------------------------------------------------

void BleApp_HandleKeys(key_event_t events)
{
#if (cPWR_UsePowerDownMode)
switch (events)
{
   case gKBD_EventPressPB1_c: //SW3 ??
   
//case gKBD_EventPressPB2_c:
   {
   if (mPeerDeviceId == gInvalidDeviceId_c)
   {
      BleApp_Start();
   }
   break;
}
}
#else
switch (events)
{
   case gKBD_EventPressPB1_c: //SW2 ??
   {
      if (mPeerDeviceId == gInvalidDeviceId_c)
      {
         BleApp_Start();
      }
      break;
}

--------------------------------------------------------------------------------

I think, the keyboard assignments are changed when enabling the cPWR_UsePowerDownMode macro definition.

would you plz check it again?

0 Kudos
Reply

1,543 Views
Sebastian_Del_Rio
NXP Employee
NXP Employee

Hi Ayden,

 

When the Heart Rate Sensor detects the press of a button as a wakeup source, the Key Handling callback  is called from the App_Idle function in the /common/ApplMain.c source file of the project.

 

When the BleApp_HandleKeys function gets called from this point, it's always with the gKBD_EventPressPB1_c event as its argument, meaning that, independently of which button is pressed, the handled event will always be gKBD_EventPressPB1_c:

/* Skip over the key scan timer to improve low power consumption. */
 BleApp_HandleKeys(gKBD_EventPressPB1_c);

 

Please let me know if you need any more information.

 

Take care, best regards,

Sebastian

0 Kudos
Reply