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