PreviousNext
Handler Example
Help > Custom DPA Handler > Handler Example

The typical skeleton of the Custom DPA Handler looks like this (see CustomDpaHandler-Template-Node.c source code example for a complete template for Node):

 

// Default IQRF include

#include "IQRF.h"

 

// Uncomment to implement Custom DPA Handler for Coordinator

//#define COORDINATOR_CUSTOM_HANDLER

 

// Default DPA header

#include "DPA.h"

// Default Custom DPA Handler header

#include "DPAcustomHandler.h"

 

// Real Custom DPA Handler function

bit CustomDpaHandler ()

{

 // Handler presence mark

 clrwdt();

 

 // Detect DPA event to handle

 switch ( GetDpaEvent() )

 {

  case DpaEvent_Interrupt:

   // …

   return Carry;

 

  // Other events …

  case DpaEvent_Idle:

   // …

   return Carry;

 

  case DpaEvent_DpaRequest:

   if ( IsDpaEnumPeripheralsRequest() )

     // Enumerate Peripherals

     {

       // …

       return TRUE;

     }

   else if ( IsDpaPeripheralInfoRequest() )

     // Get Peripheral Info

     {

       // …

       return TRUE;

     }

   else

     // Peripheral Request

     {

       // …

       return TRUE;

     }

 }

 

 return FALSE;

}

 

// Default Custom DPA Handler header

// (2nd include to implement Code bumper to detect too long code of the handler)

#include "DPAcustomHandler.h"