1 // ***************************************************************************
    2 //   Custom DPA Handler code example - Disables sleep during default bonding *
    3 // ***************************************************************************
    4 // Copyright (c) MICRORISC s.r.o.
    5 //
    6 // File:    $RCSfile: CustomDpaHandler-BondingNoSleep.c,v $
    7 // Version: $Revision: 1.19 $
    8 // Date:    $Date: 2023/03/07 08:03:13 $
    9 //
   10 // Revision history:
   11 //   2023/03/07  Release for DPA 4.30
   12 //   2022/10/05  Release for DPA 4.18
   13 //   2022/02/24  Release for DPA 4.17
   14 //   2018/10/25  Release for DPA 3.03
   15 //
   16 // *********************************************************************
   17 
   18 // Online DPA documentation https://doc.iqrf.org/DpaTechGuide/
   19 
   20 // Default IQRF include (modify the path according to your setup)
   21 #include "IQRF.h"
   22 
   23 // Default DPA header (modify the path according to your setup)
   24 #include "DPA.h"
   25 // Default Custom DPA Handler header (modify the path according to your setup)
   26 #include "DPAcustomHandler.h"
   27 
   28 // Must be the 1st defined function in the source code in order to be placed at the correct FLASH location!
   29 //############################################################################################
   30 bit CustomDpaHandler()
   31 //############################################################################################
   32 {
   33   // Handler presence mark
   34   clrwdt();
   35 
   36   // Detect DPA event to handle
   37   switch ( GetDpaEvent() )
   38   {
   39     // -------------------------------------------------
   40     case DpaEvent_Interrupt:
   41       return Carry;
   42 
   43       // -------------------------------------------------
   44 #ifdef DpaEvent_BondingButton
   45     case DpaEvent_BondingButton:
   46       // Called to allow a bonding button customization
   47 #else
   48 #ifdef DpaEvent_MenuActivated
   49       // -------------------------------------------------
   50     case DpaEvent_MenuActivated:
   51       // Called to allow a menu customization
   52       if ( userReg1 == DMENU_ReadyToBond )
   53 #else
   54 #error DpaEvent_BondingButton or DpaEvent_MenuActivated must be defined
   55 #endif
   56 #endif
   57       BondingSleepCountdown = 0;
   58       break;
   59 
   60     case DpaEvent_DpaRequest:
   61       // Called to interpret DPA request for peripherals
   62       // -------------------------------------------------
   63       // Peripheral enumeration
   64       if ( IsDpaEnumPeripheralsRequest() )
   65       {
   66         // We implement no user peripheral
   67         _DpaMessage.EnumPeripheralsAnswer.HWPID |= 0xabcF;
   68         _DpaMessage.EnumPeripheralsAnswer.HWPIDver |= 0x9876;
   69         return TRUE;
   70       }
   71   }
   72 
   73   return FALSE;
   74 }
   75 
   76 //############################################################################################
   77 // Default Custom DPA Handler header; 2nd include implementing a Code bumper to detect too long code of the Custom DPA Handler (modify the path according to your setup)
   78 #include "DPAcustomHandler.h"
   79 //############################################################################################