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.communication.USI as USI;
    13    import ti.catalog.msp430.peripherals.adc.ADC10 as ADC10;
    14    
    15    /*!
    16     *  ======== GPIO for MSP430G2230 ========
    17     *  MSP430 General Purpose Input Output Ports
    18     */
    19    metaonly module GPIO_MSP430G2230 inherits IGPIO {
    20        /*!
    21         *  ======== create ========
    22         *  Create an instance of this peripheral.
    23         */
    24        create(USI.Instance usi, ADC10.Instance adc10);
    25    
    26    instance:
    27        /*! @_nodoc */
    28        config USI.Instance usi;
    29    
    30        /*! @_nodoc */
    31        config ADC10.Instance adc10;
    32    
    33       /*! Define an array to describe all device pins. The 1st dimension
    34        *  denotes the port, the second the pin on that port. On an
    35        *  MSP430G2230 device, there are 8 + 1 = 8 pins total.
    36        */
    37    
    38        /* TODO: This here should really be a module-wide feature, rather than an instance feature,
    39         * however due to limitations in XDCtools 3.21.0.0 the data is located here */
    40        /* TODO: For this device the config variable definition has been moved into the
    41         * corresponding XS file due to its size. This needs a more consistent solution. */
    42        config DevicePin_t devicePins[1][8];
    43    
    44        /*! Implementation of Device Pin Functional Configuration */
    45        override config DevicePinFunctionSetting_t devicePinSetting[1][8];
    46    
    47        /*! Determine if each Register needs to be forced set or not */
    48        readonly config ForceSetDefaultRegister_t forceSetDefaultRegister[] =
    49        [
    50            { register : "P1OUT" , regForceSet : true  },
    51            { register : "P1SEL" , regForceSet : false },
    52            { register : "P1DIR" , regForceSet : false },
    53            { register : "P1REN" , regForceSet : false },
    54            { register : "P1IES" , regForceSet : true },
    55            { register : "P1IFG" , regForceSet : true },
    56            { register : "P1IE"  , regForceSet : false }
    57        ];
    58    
    59        /*
    60         *  GPIO Digital I/O Registers
    61         *
    62         *  One GIPO instance defines the configuration of an entire,
    63         *  8-bit wide digital I/O port.
    64         */
    65    
    66        /*! Port 1 Output Register */
    67        config GpioBits8PxOut_t P1OUT = {
    68            Bit0        : BIT0_OFF,
    69            Bit1        : BIT1_OFF,
    70            Bit2        : BIT2_OFF,
    71            Bit3        : BIT3_OFF,
    72            Bit4        : BIT4_OFF,
    73            Bit5        : BIT5_OFF,
    74            Bit6        : BIT6_OFF,
    75            Bit7        : BIT7_OFF
    76        };
    77    
    78        /*! Port 1 Port Select Register */
    79        config GpioBits8PxSel_t P1SEL = {
    80            Bit0        : BIT0_OFF,
    81            Bit1        : BIT1_OFF,
    82            Bit2        : BIT2_OFF,
    83            Bit3        : BIT3_OFF,
    84            Bit4        : BIT4_OFF,
    85            Bit5        : BIT5_OFF,
    86            Bit6        : BIT6_OFF,
    87            Bit7        : BIT7_OFF
    88        };
    89    
    90        /*! Port 1 Direction Register */
    91        config GpioBits8PxDir_t P1DIR = {
    92            Bit0        : BIT0_OFF,
    93            Bit1        : BIT1_OFF,
    94            Bit2        : BIT2_OFF,
    95            Bit3        : BIT3_OFF,
    96            Bit4        : BIT4_OFF,
    97            Bit5        : BIT5_OFF,
    98            Bit6        : BIT6_OFF,
    99            Bit7        : BIT7_OFF
   100        };
   101    
   102        /*! Port 1 Resistor Enable Register */
   103        config GpioBits8PxRen_t P1REN = {
   104            Bit0        : BIT0_OFF,
   105            Bit1        : BIT1_OFF,
   106            Bit2        : BIT2_OFF,
   107            Bit3        : BIT3_OFF,
   108            Bit4        : BIT4_OFF,
   109            Bit5        : BIT5_OFF,
   110            Bit6        : BIT6_OFF,
   111            Bit7        : BIT7_OFF
   112        };
   113    }