PreviousNext
FRC-Minimalistic
Help > Custom DPA Handler > Examples > FRC-Minimalistic

This is a truly minimalistic code example. It shows literally at only two lines of C code how to implement a custom FRC command. Its code is FRC_USER_BIT_FROM = 0x40. It returns 2nd bit equals 1 if the IQRF button is pressed, otherwise, it returns 0.

 

Following code extract shows the key part of the handler:

 

if (GetDpaEvent() == DpaEvent_FrcValue && _PCMD == FRC_USER_BIT_FROM && buttonPressed)

  responseFRCvalue.1 = 1;

 

The code checks:

         for event DpaEvent_FrcValue,

         for custom FRC command code FRC_USER_BIT_FROM and

         for the button being pressed.

 

If all conditions are met then it sets the 2nd bit returned by FRC to 1. That’s all.

 

→ Self-study tip: Modify the code in the way the FRC command returns the bit indicating whether the green LED is switched on or off.