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-82G
   11 //   OS: 4.06D, 4.06G
   12 //
   13 // File:    IQRF.h
   14 // Version: v1.00                                   Revision: 25/02/2022
   15 //
   16 // Revision history:
   17 //   v1.00: 25/02/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 TR82G
   53     #message Compilation for TR-82G modules (PIC16LF18877) and IQRF OS 4.06G.
   54     #define TR8xG
   55 #else
   56     #error Unsupported TR module type.
   57 #endif
   58 
   59 // TR-7xD
   60 #if defined TR7xD
   61     #if _16LF1938 != 1
   62         #pragma chip      PIC16LF1938
   63     #endif
   64     
   65     #define MCU_ID    4
   66     #define TR_FAMILY 1 // TR-7xD
   67 
   68     #define _ACKDT    ACKDT
   69     #define _ACKEN    ACKEN
   70     #define _ACKSTAT  ACKSTAT
   71     #define _BAUDCON  BAUDCON
   72     #define _BF       BF
   73     #define _CKE      CKE
   74     #define _DACCON0  DACCON0
   75     #define _DACCON1  DACCON1
   76     #define _EEADRH   EEADRH
   77     #define _EEADRL   EEADRL
   78     #define _EECON1   EECON1
   79     #define _EECON2   EECON2
   80     #define _EEDATH   EEDATH
   81     #define _EEDATL   EEDATL
   82     #define _GO       GO
   83     #define _PEN      PEN
   84     #define _PR6      PR6
   85     #define _RCEN     RCEN
   86     #define _RCREG    RCREG
   87     #define _RCSTA    RCSTA
   88     #define _RW_      RW_
   89     #define _SEN      SEN
   90     #define _SMP      SMP
   91     #define _SPBRGH   SPBRGH
   92     #define _SPBRGL   SPBRGL
   93     #define _SSPADD   SSPADD
   94     #define _SSPBUF   SSPBUF
   95     #define _SSPCON1  SSPCON1
   96     #define _SSPCON2  SSPCON2
   97     #define _SSPIF    SSPIF
   98     #define _SSPEN    SSPEN
   99     #define _SSPSTAT  SSPSTAT
  100     #define _SWDTEN   SWDTEN
  101     #define _T1SYNC_  T1SYNC_
  102     #define _TMR1ON   TMR1ON
  103     #define _TMR6     TMR6
  104     #define _TMR6ON   TMR6ON
  105     #define _TXREG    TXREG
  106     #define _TXSTA    TXSTA
  107     #define _WDTCON   WDTCON
  108 
  109 // TR-7xG, TR-8xG
  110 #elif defined TR7xG || defined TR8xG
  111     #if _16LF18877 != 1
  112         #pragma chip      PIC16LF18877
  113     #endif
  114     
  115     #define MCU_ID    5
  116     
  117     #if defined TR7xG
  118         #define TR_FAMILY 2 // TR-7xG
  119     #else
  120         #define TR_FAMILY 3 // TR-8xG
  121     #endif
  122 
  123     #define _ACKDT    SSP1CON2.5
  124     #define _ACKEN    SSP1CON2.4
  125     #define _ACKSTAT  SSP1CON2.6
  126     #define _BAUDCON  BAUD1CON
  127     #define _BF       SSP1STAT.0
  128     #define _CKE      SSP1STAT.6
  129     #define _DACCON0  DAC1CON0
  130     #define _DACCON1  DAC1CON1
  131     #define _EEADRH   NVMADRH
  132     #define _EEADRL   NVMADRL
  133     #define _EECON1   NVMCON1
  134     #define _EECON2   NVMCON2
  135     #define _EEDATH   NVMDATH
  136     #define _EEDATL   NVMDATL
  137     #define _GO       ADGO
  138     #define _PEN      SSP1CON2.2
  139     #define _PR6      T6PR
  140     #define _RCEN     SSP1CON2.3
  141     #define _RCREG    RC1REG
  142     #define _RCSTA    RC1STA
  143     #define _RW_      SSP1STAT.2
  144     #define _SEN      SSP1CON2.0
  145     #define _SMP      SSP1STAT.7
  146     #define _SPBRGH   SP1BRGH
  147     #define _SPBRGL   SP1BRGL
  148     #define _SSPADD   SSP1ADD
  149     #define _SSPBUF   SSP1BUF
  150     #define _SSPCON1  SSP1CON1
  151     #define _SSPCON2  SSP1CON2
  152     #define _SSPIF    SSP1IF
  153     #define _SSPEN    SSP1CON1.5
  154     #define _SSPSTAT  SSP1STAT
  155     #define _SWDTEN   WDTCON0.0
  156     #define _T1SYNC_  T1CON.2
  157     #define _TMR1ON   T1CON.0
  158     #define _TMR6     T6TMR
  159     #define _TMR6ON   T6CON.7
  160     #define _TXREG    TX1REG
  161     #define _TXSTA    TX1STA
  162     #define _WDTCON   WDTCON0
  163 #else
  164     #error Unsupported TR module family.
  165 #endif
  166 
  167 #pragma origin 0x100
  168 #pragma update_RP 0
  169 
  170 void APPLICATION();
  171 
  172 void main()                                 // Skipped during Upload
  173 {
  174     APPLICATION();
  175 }
  176 
  177 #include "IQRF-memory.h"                    // Memory definitions
  178 #include "IQRF-functions.h"                 // Functions definitions
  179 #include "IQRF-macros.h"
  180 
  181 // *********************************************************************
  182