1    /* --COPYRIGHT--,EPL
     2     *  Copyright (c) 2008 Texas Instruments and others.
     3     *  All rights reserved. This program and the accompanying materials
     4     *  are made available under the terms of the Eclipse Public License v1.0
     5     *  which accompanies this distribution, and is available at
     6     *  http://www.eclipse.org/legal/epl-v10.html
     7     *
     8     *  Contributors:
     9     *      Texas Instruments - initial implementation
    10     *
    11     * --/COPYRIGHT--*/
    12    import ti.catalog.msp430.peripherals.clock.CS as CS;
    13    
    14    /*!
    15     *  ======== GPIO for MSP430FR5739_35_31_29_25_21 ========
    16     *  MSP430 General Purpose Input Output Ports
    17     */
    18    metaonly module GPIO_MSP430FR5739_35_31_29_25_21 inherits IGPIO {
    19        /*!
    20         *  ======== create ========
    21         *  Create an instance of this peripheral. Use a customized
    22         *  init function so that we can get access to the CS
    23         *  instances.
    24         */
    25        create(CS.Instance clock);
    26    
    27    instance:
    28        /*! @_nodoc */
    29        config CS.Instance clock;
    30    
    31       /*! Define an array to describe all device pins. The 1st dimension
    32        *  denotes the port, the second the pin on that port. On an
    33        *  MSP430FR57xx device, there are 5 + 2 = 10 pins total.
    34        */
    35    
    36        /* TODO: This here should really be a module-wide feature, rather than an instance feature,
    37         * however due to limitations in XDCtools 3.21.0.0 the data is located here */
    38        config DevicePin_t devicePins[5][8];
    39    
    40        /*! Implementation of Device Pin Functional Configuration */
    41        override config DevicePinFunctionSetting_t devicePinSetting[5][8];
    42    
    43        /*! Determine if each Register needs to be forced set or not */
    44        readonly config ForceSetDefaultRegister_t forceSetDefaultRegister[] =
    45        [
    46            { register : "P1OUT"  , regForceSet : true  },
    47            { register : "P1SEL0" , regForceSet : false },
    48            { register : "P1SEL1" , regForceSet : false },
    49            { register : "P1DIR"  , regForceSet : false },
    50            { register : "P1REN"  , regForceSet : false },
    51            { register : "P1IES"  , regForceSet : true  },
    52            { register : "P1IFG"  , regForceSet : true  },
    53            { register : "P1IE"   , regForceSet : false },
    54            { register : "P2OUT"  , regForceSet : true  },
    55            { register : "P2SEL0" , regForceSet : false },
    56            { register : "P2SEL1" , regForceSet : false },
    57            { register : "P2DIR"  , regForceSet : false },
    58            { register : "P2REN"  , regForceSet : false },
    59            { register : "P2IES"  , regForceSet : true  },
    60            { register : "P2IFG"  , regForceSet : true  },
    61            { register : "P2IE"   , regForceSet : false },
    62            { register : "P3OUT"  , regForceSet : true  },
    63            { register : "P3SEL0" , regForceSet : false },
    64            { register : "P3SEL1" , regForceSet : false },
    65            { register : "P3DIR"  , regForceSet : false },
    66            { register : "P3REN"  , regForceSet : false },
    67            { register : "P3IES"  , regForceSet : true  },
    68            { register : "P3IFG"  , regForceSet : true  },
    69            { register : "P3IE"   , regForceSet : false },
    70            { register : "P4OUT"  , regForceSet : true  },
    71            { register : "P4SEL0" , regForceSet : false },
    72            { register : "P4SEL1" , regForceSet : false },
    73            { register : "P4DIR"  , regForceSet : false },
    74            { register : "P4REN"  , regForceSet : false },
    75            { register : "P4IES"  , regForceSet : true  },
    76            { register : "P4IFG"  , regForceSet : true  },
    77            { register : "P4IE"   , regForceSet : false },
    78            { register : "PJOUT"  , regForceSet : true  },
    79            { register : "PJSEL0" , regForceSet : false },
    80            { register : "PJSEL1" , regForceSet : false },
    81            { register : "PJDIR"  , regForceSet : false },
    82            { register : "PJREN"  , regForceSet : false }
    83        ];
    84    
    85        /*
    86         *  GPIO Digital I/O Registers
    87         *
    88         *  One GIPO instance defines the configuration of an entire,
    89         *  8-bit wide digital I/O port.
    90         */
    91    
    92        /*! Port 1 Output Register */
    93        config GpioBits8PxOut_t P1OUT = {
    94            Bit0        : BIT0_OFF,
    95            Bit1        : BIT1_OFF,
    96            Bit2        : BIT2_OFF,
    97            Bit3        : BIT3_OFF,
    98            Bit4        : BIT4_OFF,
    99            Bit5        : BIT5_OFF,
   100            Bit6        : BIT6_OFF,
   101            Bit7        : BIT7_OFF
   102        };
   103    
   104        /*! Port 1 Port Select Register 0 */
   105        config GpioBits8PxSel_t P1SEL0 = {
   106            Bit0        : BIT0_OFF,
   107            Bit1        : BIT1_OFF,
   108            Bit2        : BIT2_OFF,
   109            Bit3        : BIT3_OFF,
   110            Bit4        : BIT4_OFF,
   111            Bit5        : BIT5_OFF,
   112            Bit6        : BIT6_OFF,
   113            Bit7        : BIT7_OFF
   114        };
   115    
   116        /*! Port 1 Port Select Register 1 */
   117        config GpioBits8PxSel_t P1SEL1 = {
   118            Bit0        : BIT0_OFF,
   119            Bit1        : BIT1_OFF,
   120            Bit2        : BIT2_OFF,
   121            Bit3        : BIT3_OFF,
   122            Bit4        : BIT4_OFF,
   123            Bit5        : BIT5_OFF,
   124            Bit6        : BIT6_OFF,
   125            Bit7        : BIT7_OFF
   126        };
   127    
   128        /*! Port 1 Direction Register */
   129        config GpioBits8PxDir_t P1DIR = {
   130            Bit0        : BIT0_OFF,
   131            Bit1        : BIT1_OFF,
   132            Bit2        : BIT2_OFF,
   133            Bit3        : BIT3_OFF,
   134            Bit4        : BIT4_OFF,
   135            Bit5        : BIT5_OFF,
   136            Bit6        : BIT6_OFF,
   137            Bit7        : BIT7_OFF
   138        };
   139    
   140        /*! Port 1 Resistor Enable Register */
   141        config GpioBits8PxRen_t P1REN = {
   142            Bit0        : BIT0_OFF,
   143            Bit1        : BIT1_OFF,
   144            Bit2        : BIT2_OFF,
   145            Bit3        : BIT3_OFF,
   146            Bit4        : BIT4_OFF,
   147            Bit5        : BIT5_OFF,
   148            Bit6        : BIT6_OFF,
   149            Bit7        : BIT7_OFF
   150        };
   151    
   152        /*! Port 2 Output Register */
   153        config GpioBits8PxOut_t P2OUT = {
   154            Bit0        : BIT0_OFF,
   155            Bit1        : BIT1_OFF,
   156            Bit2        : BIT2_OFF,
   157            Bit3        : BIT3_OFF,
   158            Bit4        : BIT4_OFF,
   159            Bit5        : BIT5_OFF,
   160            Bit6        : BIT6_OFF,
   161            Bit7        : BIT7_OFF
   162        };
   163    
   164        /*! Port 2 Port Select Register 0 */
   165        config GpioBits8PxSel_t P2SEL0 = {
   166            Bit0        : BIT0_OFF,
   167            Bit1        : BIT1_OFF,
   168            Bit2        : BIT2_OFF,
   169            Bit3        : BIT3_OFF,
   170            Bit4        : BIT4_OFF,
   171            Bit5        : BIT5_OFF,
   172            Bit6        : BIT6_OFF,
   173            Bit7        : BIT7_OFF
   174        };
   175    
   176        /*! Port 2 Port Select Register 1 */
   177        config GpioBits8PxSel_t P2SEL1 = {
   178            Bit0        : BIT0_OFF,
   179            Bit1        : BIT1_OFF,
   180            Bit2        : BIT2_OFF,
   181            Bit3        : BIT3_OFF,
   182            Bit4        : BIT4_OFF,
   183            Bit5        : BIT5_OFF,
   184            Bit6        : BIT6_OFF,
   185            Bit7        : BIT7_OFF
   186        };
   187    
   188        /*! Port 2 Direction Register */
   189        config GpioBits8PxDir_t P2DIR = {
   190            Bit0        : BIT0_OFF,
   191            Bit1        : BIT1_OFF,
   192            Bit2        : BIT2_OFF,
   193            Bit3        : BIT3_OFF,
   194            Bit4        : BIT4_OFF,
   195            Bit5        : BIT5_OFF,
   196            Bit6        : BIT6_OFF,
   197            Bit7        : BIT7_OFF
   198        };
   199    
   200        /*! Port 2 Resistor Enable Register */
   201        config GpioBits8PxRen_t P2REN = {
   202            Bit0        : BIT0_OFF,
   203            Bit1        : BIT1_OFF,
   204            Bit2        : BIT2_OFF,
   205            Bit3        : BIT3_OFF,
   206            Bit4        : BIT4_OFF,
   207            Bit5        : BIT5_OFF,
   208            Bit6        : BIT6_OFF,
   209            Bit7        : BIT7_OFF
   210        };
   211    
   212        /*! Port 3 Output Register */
   213        config GpioBits8PxOut_t P3OUT = {
   214            Bit0        : BIT0_OFF,
   215            Bit1        : BIT1_OFF,
   216            Bit2        : BIT2_OFF,
   217            Bit3        : BIT3_OFF,
   218            Bit4        : BIT4_OFF,
   219            Bit5        : BIT5_OFF,
   220            Bit6        : BIT6_OFF,
   221            Bit7        : BIT7_OFF
   222        };
   223    
   224        /*! Port 3 Port Select Register 0 */
   225        config GpioBits8PxSel_t P3SEL0 = {
   226            Bit0        : BIT0_OFF,
   227            Bit1        : BIT1_OFF,
   228            Bit2        : BIT2_OFF,
   229            Bit3        : BIT3_OFF,
   230            Bit4        : BIT4_OFF,
   231            Bit5        : BIT5_OFF,
   232            Bit6        : BIT6_OFF,
   233            Bit7        : BIT7_OFF
   234        };
   235    
   236        /*! Port 3 Port Select Register 1 */
   237        config GpioBits8PxSel_t P3SEL1 = {
   238            Bit0        : BIT0_OFF,
   239            Bit1        : BIT1_OFF,
   240            Bit2        : BIT2_OFF,
   241            Bit3        : BIT3_OFF,
   242            Bit4        : BIT4_OFF,
   243            Bit5        : BIT5_OFF,
   244            Bit6        : BIT6_OFF,
   245            Bit7        : BIT7_OFF
   246        };
   247    
   248        /*! Port 3 Direction Register */
   249        config GpioBits8PxDir_t P3DIR = {
   250            Bit0        : BIT0_OFF,
   251            Bit1        : BIT1_OFF,
   252            Bit2        : BIT2_OFF,
   253            Bit3        : BIT3_OFF,
   254            Bit4        : BIT4_OFF,
   255            Bit5        : BIT5_OFF,
   256            Bit6        : BIT6_OFF,
   257            Bit7        : BIT7_OFF
   258        };
   259    
   260        /*! Port 3 Resistor Enable Register */
   261        config GpioBits8PxRen_t P3REN = {
   262            Bit0        : BIT0_OFF,
   263            Bit1        : BIT1_OFF,
   264            Bit2        : BIT2_OFF,
   265            Bit3        : BIT3_OFF,
   266            Bit4        : BIT4_OFF,
   267            Bit5        : BIT5_OFF,
   268            Bit6        : BIT6_OFF,
   269            Bit7        : BIT7_OFF
   270        };
   271    
   272        /*! Port 4 Output Register */
   273        config GpioBits8PxOut_t P4OUT = {
   274            Bit0        : BIT0_OFF,
   275            Bit1        : BIT1_OFF,
   276            Bit2        : BIT2_OFF,
   277            Bit3        : BIT3_OFF,
   278            Bit4        : BIT4_OFF,
   279            Bit5        : BIT5_OFF,
   280            Bit6        : BIT6_OFF,
   281            Bit7        : BIT7_OFF
   282        };
   283    
   284        /*! Port 4 Port Select Register 0 */
   285        config GpioBits8PxSel_t P4SEL0 = {
   286            Bit0        : BIT0_OFF,
   287            Bit1        : BIT1_OFF,
   288            Bit2        : BIT2_OFF,
   289            Bit3        : BIT3_OFF,
   290            Bit4        : BIT4_OFF,
   291            Bit5        : BIT5_OFF,
   292            Bit6        : BIT6_OFF,
   293            Bit7        : BIT7_OFF
   294        };
   295    
   296        /*! Port 4 Port Select Register 1 */
   297        config GpioBits8PxSel_t P4SEL1 = {
   298            Bit0        : BIT0_OFF,
   299            Bit1        : BIT1_OFF,
   300            Bit2        : BIT2_OFF,
   301            Bit3        : BIT3_OFF,
   302            Bit4        : BIT4_OFF,
   303            Bit5        : BIT5_OFF,
   304            Bit6        : BIT6_OFF,
   305            Bit7        : BIT7_OFF
   306        };
   307    
   308        /*! Port 4 Direction Register */
   309        config GpioBits8PxDir_t P4DIR = {
   310            Bit0        : BIT0_OFF,
   311            Bit1        : BIT1_OFF,
   312            Bit2        : BIT2_OFF,
   313            Bit3        : BIT3_OFF,
   314            Bit4        : BIT4_OFF,
   315            Bit5        : BIT5_OFF,
   316            Bit6        : BIT6_OFF,
   317            Bit7        : BIT7_OFF
   318        };
   319    
   320        /*! Port 4 Resistor Enable Register */
   321        config GpioBits8PxRen_t P4REN = {
   322            Bit0        : BIT0_OFF,
   323            Bit1        : BIT1_OFF,
   324            Bit2        : BIT2_OFF,
   325            Bit3        : BIT3_OFF,
   326            Bit4        : BIT4_OFF,
   327            Bit5        : BIT5_OFF,
   328            Bit6        : BIT6_OFF,
   329            Bit7        : BIT7_OFF
   330        };
   331    
   332        /*! Port J Output Register */
   333        config GpioBits8PxOut_t PJOUT = {
   334            Bit0        : BIT0_OFF,
   335            Bit1        : BIT1_OFF,
   336            Bit2        : BIT2_OFF,
   337            Bit3        : BIT3_OFF,
   338            Bit4        : BIT4_OFF,
   339            Bit5        : BIT5_OFF,
   340            Bit6        : BIT6_OFF,
   341            Bit7        : BIT7_OFF
   342        };
   343    
   344        /*! Port J Port Select Register 0 */
   345        config GpioBits8PxSel_t PJSEL0 = {
   346            Bit0        : BIT0_OFF,
   347            Bit1        : BIT1_OFF,
   348            Bit2        : BIT2_OFF,
   349            Bit3        : BIT3_OFF,
   350            Bit4        : BIT4_OFF,
   351            Bit5        : BIT5_OFF,
   352            Bit6        : BIT6_OFF,
   353            Bit7        : BIT7_OFF
   354        };
   355    
   356        /*! Port J Port Select Register 1 */
   357        config GpioBits8PxSel_t PJSEL1 = {
   358            Bit0        : BIT0_OFF,
   359            Bit1        : BIT1_OFF,
   360            Bit2        : BIT2_OFF,
   361            Bit3        : BIT3_OFF,
   362            Bit4        : BIT4_OFF,
   363            Bit5        : BIT5_OFF,
   364            Bit6        : BIT6_OFF,
   365            Bit7        : BIT7_OFF
   366        };
   367    
   368        /*! Port J Direction Register */
   369        config GpioBits8PxDir_t PJDIR = {
   370            Bit0        : BIT0_OFF,
   371            Bit1        : BIT1_OFF,
   372            Bit2        : BIT2_OFF,
   373            Bit3        : BIT3_OFF,
   374            Bit4        : BIT4_OFF,
   375            Bit5        : BIT5_OFF,
   376            Bit6        : BIT6_OFF,
   377            Bit7        : BIT7_OFF
   378        };
   379    
   380        /*! Port J Resistor Enable Register */
   381        config GpioBits8PxRen_t PJREN = {
   382            Bit0        : BIT0_OFF,
   383            Bit1        : BIT1_OFF,
   384            Bit2        : BIT2_OFF,
   385            Bit3        : BIT3_OFF,
   386            Bit4        : BIT4_OFF,
   387            Bit5        : BIT5_OFF,
   388            Bit6        : BIT6_OFF,
   389            Bit7        : BIT7_OFF
   390        };
   391    }