1    /*
     2     * Copyright (c) 2016, Texas Instruments Incorporated
     3     * All rights reserved.
     4     *
     5     * Redistribution and use in source and binary forms, with or without
     6     * modification, are permitted provided that the following conditions
     7     * are met:
     8     *
     9     * *  Redistributions of source code must retain the above copyright
    10     *    notice, this list of conditions and the following disclaimer.
    11     *
    12     * *  Redistributions in binary form must reproduce the above copyright
    13     *    notice, this list of conditions and the following disclaimer in the
    14     *    documentation and/or other materials provided with the distribution.
    15     *
    16     * *  Neither the name of Texas Instruments Incorporated nor the names of
    17     *    its contributors may be used to endorse or promote products derived
    18     *    from this software without specific prior written permission.
    19     *
    20     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    21     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    22     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    23     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    24     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    25     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    26     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
    27     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
    28     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    29     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    30     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    31     */
    32    
    33    import ti.catalog.msp430.peripherals.clock.CS as CS;
    34    
    35    /*!
    36     *  ======== GPIO for MSP430FR5737_33_27_23 ========
    37     *  MSP430 General Purpose Input Output Ports
    38     */
    39    metaonly module GPIO_MSP430FR5737_33_27_23 inherits IGPIO {
    40        /*!
    41         *  ======== create ========
    42         *  Create an instance of this peripheral. Use a customized
    43         *  init function so that we can get access to the CS
    44         *  instances.
    45         */
    46        create(CS.Instance clock);
    47    
    48    instance:
    49        /*! @_nodoc */
    50        config CS.Instance clock;
    51    
    52       /*! Define an array to describe all device pins. The 1st dimension
    53        *  denotes the port, the second the pin on that port. On an
    54        *  MSP430FR57xx device, there are 5 + 2 = 10 pins total.
    55        */
    56    
    57        /* TODO: This here should really be a module-wide feature, rather than an instance feature,
    58         * however due to limitations in XDCtools 3.21.0.0 the data is located here */
    59        config DevicePin_t devicePins[5][8];
    60    
    61        /*! Implementation of Device Pin Functional Configuration */
    62        override config DevicePinFunctionSetting_t devicePinSetting[5][8];
    63    
    64        /*! Determine if each Register needs to be forced set or not */
    65        readonly config ForceSetDefaultRegister_t forceSetDefaultRegister[] =
    66        [
    67            { register : "P1OUT"  , regForceSet : true  },
    68            { register : "P1SEL0" , regForceSet : false },
    69            { register : "P1SEL1" , regForceSet : false },
    70            { register : "P1DIR"  , regForceSet : true  },
    71            { register : "P1REN"  , regForceSet : false },
    72            { register : "P1IES"  , regForceSet : true  },
    73            { register : "P1IFG"  , regForceSet : true  },
    74            { register : "P1IE"   , regForceSet : false },
    75            { register : "P2OUT"  , regForceSet : true  },
    76            { register : "P2SEL0" , regForceSet : false },
    77            { register : "P2SEL1" , regForceSet : false },
    78            { register : "P2DIR"  , regForceSet : true  },
    79            { register : "P2REN"  , regForceSet : false },
    80            { register : "P2IES"  , regForceSet : true  },
    81            { register : "P2IFG"  , regForceSet : true  },
    82            { register : "P2IE"   , regForceSet : false },
    83            { register : "P3OUT"  , regForceSet : true  },
    84            { register : "P3SEL0" , regForceSet : false },
    85            { register : "P3SEL1" , regForceSet : false },
    86            { register : "P3DIR"  , regForceSet : true  },
    87            { register : "P3REN"  , regForceSet : false },
    88            { register : "P3IES"  , regForceSet : true  },
    89            { register : "P3IFG"  , regForceSet : true  },
    90            { register : "P3IE"   , regForceSet : false },
    91            { register : "P4OUT"  , regForceSet : true  },
    92            { register : "P4SEL0" , regForceSet : false },
    93            { register : "P4SEL1" , regForceSet : false },
    94            { register : "P4DIR"  , regForceSet : true  },
    95            { register : "P4REN"  , regForceSet : false },
    96            { register : "P4IES"  , regForceSet : true  },
    97            { register : "P4IFG"  , regForceSet : true  },
    98            { register : "P4IE"   , regForceSet : false },
    99            { register : "PJOUT"  , regForceSet : true  },
   100            { register : "PJSEL0" , regForceSet : false },
   101            { register : "PJSEL1" , regForceSet : false },
   102            { register : "PJDIR"  , regForceSet : true  },
   103            { register : "PJREN"  , regForceSet : false }
   104        ];
   105    
   106        /*
   107         *  GPIO Digital I/O Registers
   108         *
   109         *  One GIPO instance defines the configuration of an entire,
   110         *  8-bit wide digital I/O port.
   111         */
   112    
   113        /*! Port 1 Output Register */
   114        config GpioBits8PxOut_t P1OUT = {
   115            Bit0        : BIT0_OFF,
   116            Bit1        : BIT1_OFF,
   117            Bit2        : BIT2_OFF,
   118            Bit3        : BIT3_OFF,
   119            Bit4        : BIT4_OFF,
   120            Bit5        : BIT5_OFF,
   121            Bit6        : BIT6_OFF,
   122            Bit7        : BIT7_OFF
   123        };
   124    
   125        /*! Port 1 Port Select Register 0 */
   126        config GpioBits8PxSel_t P1SEL0 = {
   127            Bit0        : BIT0_OFF,
   128            Bit1        : BIT1_OFF,
   129            Bit2        : BIT2_OFF,
   130            Bit3        : BIT3_OFF,
   131            Bit4        : BIT4_OFF,
   132            Bit5        : BIT5_OFF,
   133            Bit6        : BIT6_OFF,
   134            Bit7        : BIT7_OFF
   135        };
   136    
   137        /*! Port 1 Port Select Register 1 */
   138        config GpioBits8PxSel_t P1SEL1 = {
   139            Bit0        : BIT0_OFF,
   140            Bit1        : BIT1_OFF,
   141            Bit2        : BIT2_OFF,
   142            Bit3        : BIT3_OFF,
   143            Bit4        : BIT4_OFF,
   144            Bit5        : BIT5_OFF,
   145            Bit6        : BIT6_OFF,
   146            Bit7        : BIT7_OFF
   147        };
   148    
   149        /*! Port 1 Direction Register */
   150        config GpioBits8PxDir_t P1DIR = {
   151            Bit0        : BIT0_OFF,
   152            Bit1        : BIT1_OFF,
   153            Bit2        : BIT2_OFF,
   154            Bit3        : BIT3_OFF,
   155            Bit4        : BIT4_OFF,
   156            Bit5        : BIT5_OFF,
   157            Bit6        : BIT6_OFF,
   158            Bit7        : BIT7_OFF
   159        };
   160    
   161        /*! Port 1 Resistor Enable Register */
   162        config GpioBits8PxRen_t P1REN = {
   163            Bit0        : BIT0_OFF,
   164            Bit1        : BIT1_OFF,
   165            Bit2        : BIT2_OFF,
   166            Bit3        : BIT3_OFF,
   167            Bit4        : BIT4_OFF,
   168            Bit5        : BIT5_OFF,
   169            Bit6        : BIT6_OFF,
   170            Bit7        : BIT7_OFF
   171        };
   172    
   173        /*! Port 2 Output Register */
   174        config GpioBits8PxOut_t P2OUT = {
   175            Bit0        : BIT0_OFF,
   176            Bit1        : BIT1_OFF,
   177            Bit2        : BIT2_OFF,
   178            Bit3        : BIT3_OFF,
   179            Bit4        : BIT4_OFF,
   180            Bit5        : BIT5_OFF,
   181            Bit6        : BIT6_OFF,
   182            Bit7        : BIT7_OFF
   183        };
   184    
   185        /*! Port 2 Port Select Register 0 */
   186        config GpioBits8PxSel_t P2SEL0 = {
   187            Bit0        : BIT0_OFF,
   188            Bit1        : BIT1_OFF,
   189            Bit2        : BIT2_OFF,
   190            Bit3        : BIT3_OFF,
   191            Bit4        : BIT4_OFF,
   192            Bit5        : BIT5_OFF,
   193            Bit6        : BIT6_OFF,
   194            Bit7        : BIT7_OFF
   195        };
   196    
   197        /*! Port 2 Port Select Register 1 */
   198        config GpioBits8PxSel_t P2SEL1 = {
   199            Bit0        : BIT0_OFF,
   200            Bit1        : BIT1_OFF,
   201            Bit2        : BIT2_OFF,
   202            Bit3        : BIT3_OFF,
   203            Bit4        : BIT4_OFF,
   204            Bit5        : BIT5_OFF,
   205            Bit6        : BIT6_OFF,
   206            Bit7        : BIT7_OFF
   207        };
   208    
   209        /*! Port 2 Direction Register */
   210        config GpioBits8PxDir_t P2DIR = {
   211            Bit0        : BIT0_OFF,
   212            Bit1        : BIT1_OFF,
   213            Bit2        : BIT2_OFF,
   214            Bit3        : BIT3_OFF,
   215            Bit4        : BIT4_OFF,
   216            Bit5        : BIT5_OFF,
   217            Bit6        : BIT6_OFF,
   218            Bit7        : BIT7_OFF
   219        };
   220    
   221        /*! Port 2 Resistor Enable Register */
   222        config GpioBits8PxRen_t P2REN = {
   223            Bit0        : BIT0_OFF,
   224            Bit1        : BIT1_OFF,
   225            Bit2        : BIT2_OFF,
   226            Bit3        : BIT3_OFF,
   227            Bit4        : BIT4_OFF,
   228            Bit5        : BIT5_OFF,
   229            Bit6        : BIT6_OFF,
   230            Bit7        : BIT7_OFF
   231        };
   232    
   233        /*! Port 3 Output Register */
   234        config GpioBits8PxOut_t P3OUT = {
   235            Bit0        : BIT0_OFF,
   236            Bit1        : BIT1_OFF,
   237            Bit2        : BIT2_OFF,
   238            Bit3        : BIT3_OFF,
   239            Bit4        : BIT4_OFF,
   240            Bit5        : BIT5_OFF,
   241            Bit6        : BIT6_OFF,
   242            Bit7        : BIT7_OFF
   243        };
   244    
   245        /*! Port 3 Port Select Register 0 */
   246        config GpioBits8PxSel_t P3SEL0 = {
   247            Bit0        : BIT0_OFF,
   248            Bit1        : BIT1_OFF,
   249            Bit2        : BIT2_OFF,
   250            Bit3        : BIT3_OFF,
   251            Bit4        : BIT4_OFF,
   252            Bit5        : BIT5_OFF,
   253            Bit6        : BIT6_OFF,
   254            Bit7        : BIT7_OFF
   255        };
   256    
   257        /*! Port 3 Port Select Register 1 */
   258        config GpioBits8PxSel_t P3SEL1 = {
   259            Bit0        : BIT0_OFF,
   260            Bit1        : BIT1_OFF,
   261            Bit2        : BIT2_OFF,
   262            Bit3        : BIT3_OFF,
   263            Bit4        : BIT4_OFF,
   264            Bit5        : BIT5_OFF,
   265            Bit6        : BIT6_OFF,
   266            Bit7        : BIT7_OFF
   267        };
   268    
   269        /*! Port 3 Direction Register */
   270        config GpioBits8PxDir_t P3DIR = {
   271            Bit0        : BIT0_OFF,
   272            Bit1        : BIT1_OFF,
   273            Bit2        : BIT2_OFF,
   274            Bit3        : BIT3_OFF,
   275            Bit4        : BIT4_OFF,
   276            Bit5        : BIT5_OFF,
   277            Bit6        : BIT6_OFF,
   278            Bit7        : BIT7_OFF
   279        };
   280    
   281        /*! Port 3 Resistor Enable Register */
   282        config GpioBits8PxRen_t P3REN = {
   283            Bit0        : BIT0_OFF,
   284            Bit1        : BIT1_OFF,
   285            Bit2        : BIT2_OFF,
   286            Bit3        : BIT3_OFF,
   287            Bit4        : BIT4_OFF,
   288            Bit5        : BIT5_OFF,
   289            Bit6        : BIT6_OFF,
   290            Bit7        : BIT7_OFF
   291        };
   292    
   293        /*! Port 4 Output Register */
   294        config GpioBits8PxOut_t P4OUT = {
   295            Bit0        : BIT0_OFF,
   296            Bit1        : BIT1_OFF,
   297            Bit2        : BIT2_OFF,
   298            Bit3        : BIT3_OFF,
   299            Bit4        : BIT4_OFF,
   300            Bit5        : BIT5_OFF,
   301            Bit6        : BIT6_OFF,
   302            Bit7        : BIT7_OFF
   303        };
   304    
   305        /*! Port 4 Port Select Register 0 */
   306        config GpioBits8PxSel_t P4SEL0 = {
   307            Bit0        : BIT0_OFF,
   308            Bit1        : BIT1_OFF,
   309            Bit2        : BIT2_OFF,
   310            Bit3        : BIT3_OFF,
   311            Bit4        : BIT4_OFF,
   312            Bit5        : BIT5_OFF,
   313            Bit6        : BIT6_OFF,
   314            Bit7        : BIT7_OFF
   315        };
   316    
   317        /*! Port 4 Port Select Register 1 */
   318        config GpioBits8PxSel_t P4SEL1 = {
   319            Bit0        : BIT0_OFF,
   320            Bit1        : BIT1_OFF,
   321            Bit2        : BIT2_OFF,
   322            Bit3        : BIT3_OFF,
   323            Bit4        : BIT4_OFF,
   324            Bit5        : BIT5_OFF,
   325            Bit6        : BIT6_OFF,
   326            Bit7        : BIT7_OFF
   327        };
   328    
   329        /*! Port 4 Direction Register */
   330        config GpioBits8PxDir_t P4DIR = {
   331            Bit0        : BIT0_OFF,
   332            Bit1        : BIT1_OFF,
   333            Bit2        : BIT2_OFF,
   334            Bit3        : BIT3_OFF,
   335            Bit4        : BIT4_OFF,
   336            Bit5        : BIT5_OFF,
   337            Bit6        : BIT6_OFF,
   338            Bit7        : BIT7_OFF
   339        };
   340    
   341        /*! Port 4 Resistor Enable Register */
   342        config GpioBits8PxRen_t P4REN = {
   343            Bit0        : BIT0_OFF,
   344            Bit1        : BIT1_OFF,
   345            Bit2        : BIT2_OFF,
   346            Bit3        : BIT3_OFF,
   347            Bit4        : BIT4_OFF,
   348            Bit5        : BIT5_OFF,
   349            Bit6        : BIT6_OFF,
   350            Bit7        : BIT7_OFF
   351        };
   352    
   353        /*! Port J Output Register */
   354        config GpioBits8PxOut_t PJOUT = {
   355            Bit0        : BIT0_OFF,
   356            Bit1        : BIT1_OFF,
   357            Bit2        : BIT2_OFF,
   358            Bit3        : BIT3_OFF,
   359            Bit4        : BIT4_OFF,
   360            Bit5        : BIT5_OFF,
   361            Bit6        : BIT6_OFF,
   362            Bit7        : BIT7_OFF
   363        };
   364    
   365        /*! Port J Port Select Register 0 */
   366        config GpioBits8PxSel_t PJSEL0 = {
   367            Bit0        : BIT0_OFF,
   368            Bit1        : BIT1_OFF,
   369            Bit2        : BIT2_OFF,
   370            Bit3        : BIT3_OFF,
   371            Bit4        : BIT4_OFF,
   372            Bit5        : BIT5_OFF,
   373            Bit6        : BIT6_OFF,
   374            Bit7        : BIT7_OFF
   375        };
   376    
   377        /*! Port J Port Select Register 1 */
   378        config GpioBits8PxSel_t PJSEL1 = {
   379            Bit0        : BIT0_OFF,
   380            Bit1        : BIT1_OFF,
   381            Bit2        : BIT2_OFF,
   382            Bit3        : BIT3_OFF,
   383            Bit4        : BIT4_OFF,
   384            Bit5        : BIT5_OFF,
   385            Bit6        : BIT6_OFF,
   386            Bit7        : BIT7_OFF
   387        };
   388    
   389        /*! Port J Direction Register */
   390        config GpioBits8PxDir_t PJDIR = {
   391            Bit0        : BIT0_OFF,
   392            Bit1        : BIT1_OFF,
   393            Bit2        : BIT2_OFF,
   394            Bit3        : BIT3_OFF,
   395            Bit4        : BIT4_OFF,
   396            Bit5        : BIT5_OFF,
   397            Bit6        : BIT6_OFF,
   398            Bit7        : BIT7_OFF
   399        };
   400    
   401        /*! Port J Resistor Enable Register */
   402        config GpioBits8PxRen_t PJREN = {
   403            Bit0        : BIT0_OFF,
   404            Bit1        : BIT1_OFF,
   405            Bit2        : BIT2_OFF,
   406            Bit3        : BIT3_OFF,
   407            Bit4        : BIT4_OFF,
   408            Bit5        : BIT5_OFF,
   409            Bit6        : BIT6_OFF,
   410            Bit7        : BIT7_OFF
   411        };
   412    }