1 // *********************************************************************
    2 //                     IQRF OS basic include file                      *
    3 // *********************************************************************
    4 //
    5 // Online IQRF OS Reference Guide: http://www.iqrf.org/IQRF-OS-Reference-guide/
    6 //
    7 // Copyright (c) MICRORISC s.r.o.
    8 //
    9 // Intended for:
   10 //   HW: TR-72D, TR-76D, TR-77D, TR-78D, TR-75D, TR-72G, TR-76G, TR-75G, TR-82G
   11 //   OS: 4.06D, 4.06G
   12 //
   13 // File:    IQRF.h
   14 // Version: v1.00                                   Revision: 03/06/2022
   15 //
   16 // Revision history:
   17 //   v1.00: 03/06/2022  First release for OS 4.06D and 4.06G.
   18 //
   19 // *********************************************************************
   20 
   21 #if IQRFOS != 406
   22     #error Invalid IQRF OS version, v4.06D or v4.06G is expected. Make sure matching header files and project IQRF OS version setting are used.
   23 #endif
   24 
   25 #if __CC5X__ < 3701
   26     #warning Insufficient CC5X compiler version, V3.7A or higher is recommended.
   27 #endif
   28 
   29 #define OS_VERSION 0x46
   30 
   31 #if defined TR72D
   32     #message Compilation for TR-72D modules (PIC16LF1938) and IQRF OS 4.06D.
   33     #define TR7xD
   34 #elif defined TR76D
   35     #message Compilation for TR-76D modules (PIC16LF1938) and IQRF OS 4.06D.
   36     #define TR7xD
   37 #elif defined TR77D
   38     #message Compilation for TR-77D modules (PIC16LF1938) and IQRF OS 4.06D.
   39     #define TR7xD
   40 #elif defined TR78D
   41     #message Compilation for TR-78D modules (PIC16LF1938) and IQRF OS 4.06D.
   42     #define TR7xD
   43 #elif defined TR75D
   44     #message Compilation for TR-75D modules (PIC16LF1938) and IQRF OS 4.06D.
   45     #define TR7xD
   46 #elif defined TR72G
   47     #message Compilation for TR-72G modules (PIC16LF18877) and IQRF OS 4.06G.
   48     #define TR7xG
   49 #elif defined TR76G
   50     #message Compilation for TR-76G modules (PIC16LF18877) and IQRF OS 4.06G.
   51     #define TR7xG
   52 #elif defined TR75G
   53     #message Compilation for TR-75G modules (PIC16LF18877) and IQRF OS 4.06G.
   54     #define TR7xG
   55 #elif defined TR82G
   56     #message Compilation for TR-82G modules (PIC16LF18877) and IQRF OS 4.06G.
   57     #define TR8xG
   58 #else
   59     #error Unsupported TR module type.
   60 #endif
   61 
   62 // TR-7xD
   63 #if defined TR7xD
   64     #if _16LF1938 != 1
   65         #pragma chip      PIC16LF1938
   66     #endif
   67     
   68     #define MCU_ID    4
   69     #define TR_FAMILY 1 // TR-7xD
   70 
   71     #define _ACKDT    ACKDT
   72     #define _ACKEN    ACKEN
   73     #define _ACKSTAT  ACKSTAT
   74     #define _BAUDCON  BAUDCON
   75     #define _BF       BF
   76     #define _CKE      CKE
   77     #define _DACCON0  DACCON0
   78     #define _DACCON1  DACCON1
   79     #define _EEADRH   EEADRH
   80     #define _EEADRL   EEADRL
   81     #define _EECON1   EECON1
   82     #define _EECON2   EECON2
   83     #define _EEDATH   EEDATH
   84     #define _EEDATL   EEDATL
   85     #define _GO       GO
   86     #define _PEN      PEN
   87     #define _PR6      PR6
   88     #define _RCEN     RCEN
   89     #define _RCREG    RCREG
   90     #define _RCSTA    RCSTA
   91     #define _RW_      RW_
   92     #define _SEN      SEN
   93     #define _SMP      SMP
   94     #define _SPBRGH   SPBRGH
   95     #define _SPBRGL   SPBRGL
   96     #define _SSPADD   SSPADD
   97     #define _SSPBUF   SSPBUF
   98     #define _SSPCON1  SSPCON1
   99     #define _SSPCON2  SSPCON2
  100     #define _SSPIF    SSPIF
  101     #define _SSPEN    SSPEN
  102     #define _SSPSTAT  SSPSTAT
  103     #define _SWDTEN   SWDTEN
  104     #define _T1SYNC_  T1SYNC_
  105     #define _TMR1ON   TMR1ON
  106     #define _TMR6     TMR6
  107     #define _TMR6ON   TMR6ON
  108     #define _TXREG    TXREG
  109     #define _TXSTA    TXSTA
  110     #define _WDTCON   WDTCON
  111 
  112 // TR-7xG, TR-8xG
  113 #elif defined TR7xG || defined TR8xG
  114     #if _16LF18877 != 1
  115         #pragma chip      PIC16LF18877
  116     #endif
  117     
  118     #define MCU_ID    5
  119     
  120     #if defined TR7xG
  121         #define TR_FAMILY 2 // TR-7xG
  122     #else
  123         #define TR_FAMILY 3 // TR-8xG
  124     #endif
  125 
  126     #define _ACKDT    SSP1CON2.5
  127     #define _ACKEN    SSP1CON2.4
  128     #define _ACKSTAT  SSP1CON2.6
  129     #define _BAUDCON  BAUD1CON
  130     #define _BF       SSP1STAT.0
  131     #define _CKE      SSP1STAT.6
  132     #define _DACCON0  DAC1CON0
  133     #define _DACCON1  DAC1CON1
  134     #define _EEADRH   NVMADRH
  135     #define _EEADRL   NVMADRL
  136     #define _EECON1   NVMCON1
  137     #define _EECON2   NVMCON2
  138     #define _EEDATH   NVMDATH
  139     #define _EEDATL   NVMDATL
  140     #define _GO       ADGO
  141     #define _PEN      SSP1CON2.2
  142     #define _PR6      T6PR
  143     #define _RCEN     SSP1CON2.3
  144     #define _RCREG    RC1REG
  145     #define _RCSTA    RC1STA
  146     #define _RW_      SSP1STAT.2
  147     #define _SEN      SSP1CON2.0
  148     #define _SMP      SSP1STAT.7
  149     #define _SPBRGH   SP1BRGH
  150     #define _SPBRGL   SP1BRGL
  151     #define _SSPADD   SSP1ADD
  152     #define _SSPBUF   SSP1BUF
  153     #define _SSPCON1  SSP1CON1
  154     #define _SSPCON2  SSP1CON2
  155     #define _SSPIF    SSP1IF
  156     #define _SSPEN    SSP1CON1.5
  157     #define _SSPSTAT  SSP1STAT
  158     #define _SWDTEN   WDTCON0.0
  159     #define _T1SYNC_  T1CON.2
  160     #define _TMR1ON   T1CON.0
  161     #define _TMR6     T6TMR
  162     #define _TMR6ON   T6CON.7
  163     #define _TXREG    TX1REG
  164     #define _TXSTA    TX1STA
  165     #define _WDTCON   WDTCON0
  166 #else
  167     #error Unsupported TR module family.
  168 #endif
  169 
  170 #pragma origin 0x100
  171 #pragma update_RP 0
  172 
  173 void APPLICATION();
  174 
  175 void main()                                 // Skipped during Upload
  176 {
  177     APPLICATION();
  178 }
  179 
  180 #include "IQRF-memory.h"                    // Memory definitions
  181 #include "IQRF-functions.h"                 // Functions definitions
  182 #include "IQRF-macros.h"
  183 
  184 // *********************************************************************
  185