1 // *********************************************************************
    2 //   DPA IO Setup example                                              *
    3 // *********************************************************************
    4 // Copyright (c) MICRORISC s.r.o.
    5 //
    6 // File:    $RCSfile: DpaIoSetup.c,v $
    7 // Version: $Revision: 1.13 $
    8 // Date:    $Date: 2021/04/26 15:13:51 $
    9 //
   10 // Revision history:
   11 //   2017/03/13  Release for DPA 3.00
   12 //   2015/08/05  Release for DPA 2.20
   13 //   2014/04/30  Release for DPA 2.10
   14 //
   15 // *********************************************************************
   16 
   17 // Online DPA documentation https://doc.iqrf.org/DpaTechGuide/
   18 
   19 // Before uploading this example make sure:
   20 // 1. IO Setup is enabled at HWP Configuration
   21 // 2. Embedded IO peripheral is enabled at HWP Configuration
   22 // 3. External EEPROM upload is selected at IQRF IDE. Please note external EEPROM cannot be uploaded using RFPGM.
   23 
   24 // ! Important: 
   25 // Updating Custom DPA Handler code using OTA LoadCode command does not allow writing external EEPROM content. 
   26 // Therefore the update of the IO Setup is not possible. It is recommended to avoid IO Setup when OTA is used.
   27 
   28 // Default IQRF include (modify the path according to your setup)
   29 #include "IQRF.h"
   30 
   31 // Do not check for the Custom DPA Handler existence (we only wrote to the external EEPROM)
   32 #define NO_CUSTOM_DPA_HANDLER
   33 
   34 // Default DPA header (modify the path according to your setup)
   35 #include "DPA.h"
   36 // Default Custom DPA Handler header (modify the path according to your setup)
   37 #include "DPAcustomHandler.h"
   38 
   39 //############################################################################################
   40 
   41 // Example: set green LED output pin and set LED on for 1s and then off for 1s
   42 #pragma cdata[ __EEESTART + IOSETUP_EEEPROM_ADDR ] = \
   43 /* 1. Green LED IO is output */ \
   44 8,  PNUM_IO, CMD_IO_DIRECTION, 0xff, 0xff, /* PORTB.7 = LEDG = Output */ PNUM_IO_TRISB, 0x80, 0x00, \
   45 /* 2. Green LED on for 1s, Green LED off for 1s */ \
   46 17, PNUM_IO, CMD_IO_SET, 0xff, 0xff, \
   47   /* PORTB.7 = 1 => LEDG on */ PNUM_IO_PORTB, 0x80, 0x80, \
   48   /* delay 1s */ PNUM_IO_DELAY, 0xe8, 0x03, \
   49   /* PORTB.7 = 0 => LEDG off */ PNUM_IO_PORTB, 0x80, 0x00, \
   50   /* delay 1s */ PNUM_IO_DELAY, 0xe8, 0x03, \
   51 /* 3. End IO Setup  */ \
   52 0
   53 
   54 //############################################################################################