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    
    14    /*!
    15     *  ======== GPIO for MSP430F20x1 ========
    16     *  MSP430 General Purpose Input Output Ports
    17     */
    18    metaonly module GPIO_MSP430F20x1 inherits IGPIO {
    19        /*!
    20         *  ======== create ========
    21         *  Create an instance of this peripheral.
    22         */
    23        create(Comparator.Instance comparator);
    24    
    25    instance:
    26        /*! @_nodoc */
    27        config Comparator.Instance comparator;
    28    
    29       /*! Define an array to describe all device pins. The 1st dimension
    30        *  denotes the port, the second the pin on that port. On an
    31        *  MSP430F20x1 device, there are 8 + 2 = 10 pins total.
    32        */
    33    
    34        /* TODO: This here should really be a module-wide feature, rather than an instance feature,
    35         * however due to limitations in XDCtools 3.21.0.0 the data is located here */
    36        readonly config DevicePin_t devicePins[2][8];
    37    
    38        /*! Implementation of Device Pin Functional Configuration */
    39        override config DevicePinFunctionSetting_t devicePinSetting[2][8];
    40    
    41        /*! Determine if each Register needs to be forced set or not */
    42        readonly config ForceSetDefaultRegister_t forceSetDefaultRegister[] =
    43        [
    44            { register : "P1OUT" , regForceSet : true  },
    45            { register : "P1SEL" , regForceSet : false },
    46            { register : "P1DIR" , regForceSet : true  },
    47            { register : "P1REN" , regForceSet : false },
    48            { register : "P1IES" , regForceSet : true },
    49            { register : "P1IFG" , regForceSet : true },
    50            { register : "P1IE"  , regForceSet : false },
    51            { register : "P2OUT" , regForceSet : true  },
    52            { register : "P2SEL" , regForceSet : false },
    53            { register : "P2DIR" , regForceSet : true  },
    54            { register : "P2REN" , regForceSet : false },
    55            { register : "P2IES" , regForceSet : true },
    56            { register : "P2IFG" , regForceSet : true },
    57            { register : "P2IE"  , regForceSet : false }
    58        ];
    59    
    60        /*
    61         *  GPIO Digital I/O Registers
    62         *
    63         *  One GIPO instance defines the configuration of an entire,
    64         *  8-bit wide digital I/O port.
    65         */
    66    
    67        /*! Port 1 Output Register */
    68        config GpioBits8PxOut_t P1OUT = {
    69            Bit0        : BIT0_OFF,
    70            Bit1        : BIT1_OFF,
    71            Bit2        : BIT2_OFF,
    72            Bit3        : BIT3_OFF,
    73            Bit4        : BIT4_OFF,
    74            Bit5        : BIT5_OFF,
    75            Bit6        : BIT6_OFF,
    76            Bit7        : BIT7_OFF
    77        };
    78    
    79        /*! Port 1 Port Select Register */
    80        config GpioBits8PxSel_t P1SEL = {
    81            Bit0        : BIT0_OFF,
    82            Bit1        : BIT1_OFF,
    83            Bit2        : BIT2_OFF,
    84            Bit3        : BIT3_OFF,
    85            Bit4        : BIT4_OFF,
    86            Bit5        : BIT5_OFF,
    87            Bit6        : BIT6_OFF,
    88            Bit7        : BIT7_OFF
    89        };
    90    
    91        /*! Port 1 Direction Register */
    92        config GpioBits8PxDir_t P1DIR = {
    93            Bit0        : BIT0_OFF,
    94            Bit1        : BIT1_OFF,
    95            Bit2        : BIT2_OFF,
    96            Bit3        : BIT3_OFF,
    97            Bit4        : BIT4_OFF,
    98            Bit5        : BIT5_OFF,
    99            Bit6        : BIT6_OFF,
   100            Bit7        : BIT7_OFF
   101        };
   102    
   103        /*! Port 1 Resistor Enable Register */
   104        config GpioBits8PxRen_t P1REN = {
   105            Bit0        : BIT0_OFF,
   106            Bit1        : BIT1_OFF,
   107            Bit2        : BIT2_OFF,
   108            Bit3        : BIT3_OFF,
   109            Bit4        : BIT4_OFF,
   110            Bit5        : BIT5_OFF,
   111            Bit6        : BIT6_OFF,
   112            Bit7        : BIT7_OFF
   113        };
   114    
   115        /*! Port 2 Output Register */
   116        config GpioBits8PxOut_t P2OUT = {
   117            Bit0        : BIT0_OFF,
   118            Bit1        : BIT1_OFF,
   119            Bit2        : BIT2_OFF,
   120            Bit3        : BIT3_OFF,
   121            Bit4        : BIT4_OFF,
   122            Bit5        : BIT5_OFF,
   123            Bit6        : BIT6_OFF,
   124            Bit7        : BIT7_OFF
   125        };
   126    
   127        /*! Port 2 Port Select Register */
   128        config GpioBits8PxSel_t P2SEL = {
   129            Bit0        : BIT0_OFF,
   130            Bit1        : BIT1_OFF,
   131            Bit2        : BIT2_OFF,
   132            Bit3        : BIT3_OFF,
   133            Bit4        : BIT4_OFF,
   134            Bit5        : BIT5_OFF,
   135            Bit6        : BIT6,         /* POR default for all 2xx devices */
   136            Bit7        : BIT7          /* POR default for all 2xx devices */
   137        };
   138    
   139        /*! Port 2 Direction Register */
   140        config GpioBits8PxDir_t P2DIR = {
   141            Bit0        : BIT0_OFF,
   142            Bit1        : BIT1_OFF,
   143            Bit2        : BIT2_OFF,
   144            Bit3        : BIT3_OFF,
   145            Bit4        : BIT4_OFF,
   146            Bit5        : BIT5_OFF,
   147            Bit6        : BIT6_OFF,
   148            Bit7        : BIT7_OFF
   149        };
   150    
   151        /*! Port 2 Resistor Enable Register */
   152        config GpioBits8PxRen_t P2REN = {
   153            Bit0        : BIT0_OFF,
   154            Bit1        : BIT1_OFF,
   155            Bit2        : BIT2_OFF,
   156            Bit3        : BIT3_OFF,
   157            Bit4        : BIT4_OFF,
   158            Bit5        : BIT5_OFF,
   159            Bit6        : BIT6_OFF,
   160            Bit7        : BIT7_OFF
   161        };
   162    
   163    }