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.comparator.IComparator as Comparator;
    13    import ti.catalog.msp430.peripherals.clock.BCSplus as BCSplus;
    14    
    15    /*!
    16     *  ======== GPIO for MSP430F23x0 ========
    17     *  MSP430 General Purpose Input Output Ports
    18     */
    19    metaonly module GPIO_MSP430F23x0 inherits IGPIO {
    20        /*!
    21         *  ======== create ========
    22         *  Create an instance of this peripheral. Use a customized
    23         *  init function so that we can get access to the Comparator_A
    24         *  and BCS+ instances.
    25         */
    26        create(Comparator.Instance comparator, BCSplus.Instance clock);
    27    
    28    instance:
    29        /*! @_nodoc */
    30        config Comparator.Instance comparator;
    31    
    32        /*! @_nodoc */
    33        config BCSplus.Instance clock;
    34    
    35        /*! Define an array to describe all device pins. The 1st dimension
    36         *  denotes the port, the second the pin on that port. On an
    37         *  MSP430F23x0 device, there are 4 x 8 = 32 pins total.
    38         */
    39    
    40        /* TODO: This here should really be a module-wide feature, rather than an instance feature,
    41         * however due to limitations in XDCtools 3.21.0.0 the data is located here */
    42        /* TODO: For this device the config variable definition has been moved into the
    43         * corresponding XS file due to its size. This needs a more consistent solution. */
    44        config DevicePin_t devicePins[4][8];
    45    
    46        /*! Implementation of Device Pin Functional Configuration */
    47        override config DevicePinFunctionSetting_t devicePinSetting[4][8];
    48    
    49        /*! Determine if each Register needs to be forced set or not */
    50        readonly config ForceSetDefaultRegister_t forceSetDefaultRegister[] =
    51        [
    52            { register : "P1OUT" , regForceSet : true  },
    53            { register : "P1SEL" , regForceSet : false },
    54            { register : "P1DIR" , regForceSet : false },
    55            { register : "P1REN" , regForceSet : false },
    56            { register : "P1IES" , regForceSet : true },
    57            { register : "P1IFG" , regForceSet : true },
    58            { register : "P1IE"  , regForceSet : false },
    59            { register : "P2OUT" , regForceSet : true  },
    60            { register : "P2SEL" , regForceSet : false },
    61            { register : "P2DIR" , regForceSet : false },
    62            { register : "P2REN" , regForceSet : false },
    63            { register : "P2IES" , regForceSet : true },
    64            { register : "P2IFG" , regForceSet : true },
    65            { register : "P2IE"  , regForceSet : false },
    66            { register : "P3OUT" , regForceSet : true  },
    67            { register : "P3SEL" , regForceSet : false },
    68            { register : "P3DIR" , regForceSet : false },
    69            { register : "P3REN" , regForceSet : false },
    70            { register : "P4OUT" , regForceSet : true  },
    71            { register : "P4SEL" , regForceSet : false },
    72            { register : "P4DIR" , regForceSet : false },
    73            { register : "P4REN" , regForceSet : false },
    74        ];
    75    
    76        /*
    77         *  GPIO Digital I/O Registers
    78         *
    79         *  One GIPO instance defines the configuration of an entire,
    80         *  8-bit wide digital I/O port.
    81         */
    82    
    83        /*! Port 1 Output Register */
    84        config GpioBits8PxOut_t P1OUT = {
    85            Bit0        : BIT0_OFF,
    86            Bit1        : BIT1_OFF,
    87            Bit2        : BIT2_OFF,
    88            Bit3        : BIT3_OFF,
    89            Bit4        : BIT4_OFF,
    90            Bit5        : BIT5_OFF,
    91            Bit6        : BIT6_OFF,
    92            Bit7        : BIT7_OFF
    93        };
    94    
    95        /*! Port 1 Port Select Register */
    96        config GpioBits8PxSel_t P1SEL = {
    97            Bit0        : BIT0_OFF,
    98            Bit1        : BIT1_OFF,
    99            Bit2        : BIT2_OFF,
   100            Bit3        : BIT3_OFF,
   101            Bit4        : BIT4_OFF,
   102            Bit5        : BIT5_OFF,
   103            Bit6        : BIT6_OFF,
   104            Bit7        : BIT7_OFF
   105        };
   106    
   107        /*! Port 1 Direction Register */
   108        config GpioBits8PxDir_t P1DIR = {
   109            Bit0        : BIT0_OFF,
   110            Bit1        : BIT1_OFF,
   111            Bit2        : BIT2_OFF,
   112            Bit3        : BIT3_OFF,
   113            Bit4        : BIT4_OFF,
   114            Bit5        : BIT5_OFF,
   115            Bit6        : BIT6_OFF,
   116            Bit7        : BIT7_OFF
   117        };
   118    
   119        /*! Port 1 Resistor Enable Register */
   120        config GpioBits8PxRen_t P1REN = {
   121            Bit0        : BIT0_OFF,
   122            Bit1        : BIT1_OFF,
   123            Bit2        : BIT2_OFF,
   124            Bit3        : BIT3_OFF,
   125            Bit4        : BIT4_OFF,
   126            Bit5        : BIT5_OFF,
   127            Bit6        : BIT6_OFF,
   128            Bit7        : BIT7_OFF
   129        };
   130    
   131        /*! Port 2 Output Register */
   132        config GpioBits8PxOut_t P2OUT = {
   133            Bit0        : BIT0_OFF,
   134            Bit1        : BIT1_OFF,
   135            Bit2        : BIT2_OFF,
   136            Bit3        : BIT3_OFF,
   137            Bit4        : BIT4_OFF,
   138            Bit5        : BIT5_OFF,
   139            Bit6        : BIT6_OFF,
   140            Bit7        : BIT7_OFF
   141        };
   142    
   143        /*! Port 2 Port Select Register */
   144        config GpioBits8PxSel_t P2SEL = {
   145            Bit0        : BIT0_OFF,
   146            Bit1        : BIT1_OFF,
   147            Bit2        : BIT2_OFF,
   148            Bit3        : BIT3_OFF,
   149            Bit4        : BIT4_OFF,
   150            Bit5        : BIT5_OFF,
   151            Bit6        : BIT6,         /* POR default for all 2xx devices */
   152            Bit7        : BIT7          /* POR default for all 2xx devices */
   153        };
   154    
   155        /*! Port 2 Direction Register */
   156        config GpioBits8PxDir_t P2DIR = {
   157            Bit0        : BIT0_OFF,
   158            Bit1        : BIT1_OFF,
   159            Bit2        : BIT2_OFF,
   160            Bit3        : BIT3_OFF,
   161            Bit4        : BIT4_OFF,
   162            Bit5        : BIT5_OFF,
   163            Bit6        : BIT6_OFF,
   164            Bit7        : BIT7_OFF
   165        };
   166    
   167        /*! Port 2 Resistor Enable Register */
   168        config GpioBits8PxRen_t P2REN = {
   169            Bit0        : BIT0_OFF,
   170            Bit1        : BIT1_OFF,
   171            Bit2        : BIT2_OFF,
   172            Bit3        : BIT3_OFF,
   173            Bit4        : BIT4_OFF,
   174            Bit5        : BIT5_OFF,
   175            Bit6        : BIT6_OFF,
   176            Bit7        : BIT7_OFF
   177        };
   178    
   179        /*! Port 3 Output Register */
   180        config GpioBits8PxOut_t P3OUT = {
   181            Bit0        : BIT0_OFF,
   182            Bit1        : BIT1_OFF,
   183            Bit2        : BIT2_OFF,
   184            Bit3        : BIT3_OFF,
   185            Bit4        : BIT4_OFF,
   186            Bit5        : BIT5_OFF,
   187            Bit6        : BIT6_OFF,
   188            Bit7        : BIT7_OFF
   189        };
   190    
   191        /*! Port 3 Port Select Register */
   192        config GpioBits8PxSel_t P3SEL = {
   193            Bit0        : BIT0_OFF,
   194            Bit1        : BIT1_OFF,
   195            Bit2        : BIT2_OFF,
   196            Bit3        : BIT3_OFF,
   197            Bit4        : BIT4_OFF,
   198            Bit5        : BIT5_OFF,
   199            Bit6        : BIT6_OFF,
   200            Bit7        : BIT7_OFF
   201        };
   202    
   203        /*! Port 3 Direction Register */
   204        config GpioBits8PxDir_t P3DIR = {
   205            Bit0        : BIT0_OFF,
   206            Bit1        : BIT1_OFF,
   207            Bit2        : BIT2_OFF,
   208            Bit3        : BIT3_OFF,
   209            Bit4        : BIT4_OFF,
   210            Bit5        : BIT5_OFF,
   211            Bit6        : BIT6_OFF,
   212            Bit7        : BIT7_OFF
   213        };
   214    
   215        /*! Port 3 Resistor Enable Register */
   216        config GpioBits8PxRen_t P3REN = {
   217            Bit0        : BIT0_OFF,
   218            Bit1        : BIT1_OFF,
   219            Bit2        : BIT2_OFF,
   220            Bit3        : BIT3_OFF,
   221            Bit4        : BIT4_OFF,
   222            Bit5        : BIT5_OFF,
   223            Bit6        : BIT6_OFF,
   224            Bit7        : BIT7_OFF
   225        };
   226    
   227        /*! Port 4 Output Register */
   228        config GpioBits8PxOut_t P4OUT = {
   229            Bit0        : BIT0_OFF,
   230            Bit1        : BIT1_OFF,
   231            Bit2        : BIT2_OFF,
   232            Bit3        : BIT3_OFF,
   233            Bit4        : BIT4_OFF,
   234            Bit5        : BIT5_OFF,
   235            Bit6        : BIT6_OFF,
   236            Bit7        : BIT7_OFF
   237        };
   238    
   239        /*! Port 4 Port Select Register */
   240        config GpioBits8PxSel_t P4SEL = {
   241            Bit0        : BIT0_OFF,
   242            Bit1        : BIT1_OFF,
   243            Bit2        : BIT2_OFF,
   244            Bit3        : BIT3_OFF,
   245            Bit4        : BIT4_OFF,
   246            Bit5        : BIT5_OFF,
   247            Bit6        : BIT6_OFF,
   248            Bit7        : BIT7_OFF
   249        };
   250    
   251        /*! Port 4 Direction Register */
   252        config GpioBits8PxDir_t P4DIR = {
   253            Bit0        : BIT0_OFF,
   254            Bit1        : BIT1_OFF,
   255            Bit2        : BIT2_OFF,
   256            Bit3        : BIT3_OFF,
   257            Bit4        : BIT4_OFF,
   258            Bit5        : BIT5_OFF,
   259            Bit6        : BIT6_OFF,
   260            Bit7        : BIT7_OFF
   261        };
   262    
   263        /*! Port 4 Resistor Enable Register */
   264        config GpioBits8PxRen_t P4REN = {
   265            Bit0        : BIT0_OFF,
   266            Bit1        : BIT1_OFF,
   267            Bit2        : BIT2_OFF,
   268            Bit3        : BIT3_OFF,
   269            Bit4        : BIT4_OFF,
   270            Bit5        : BIT5_OFF,
   271            Bit6        : BIT6_OFF,
   272            Bit7        : BIT7_OFF
   273        };
   274    }