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    /*!
    13     *  ======== Led ========
    14     *  Simple LED manager
    15     */
    16    @ModuleStartup
    17    module Led
    18    {
    19        const Ptr PORT0 = 0x11;  /* only defined on msp430x33x devices */
    20        const Ptr PORT1 = 0x21;
    21        const Ptr PORT2 = 0x29;
    22        const Ptr PORT3 = 0x19;
    23        const Ptr PORT4 = 0x1D;
    24        const Ptr PORT5 = 0x31;
    25        const Ptr PORT6 = 0x35;
    26        const Ptr PORT7 = 0x3A;  /* = 0x39 for msp430x41x2 devices */
    27        const Ptr PORT8 = 0x3B;
    28    
    29        const Ptr PORTA_L = 0x202;  /* port 1 */
    30        const Ptr PORTA_H = 0x203;  /* port 2 */
    31        const Ptr PORTB_L = 0x222;  /* port 3 */
    32        const Ptr PORTB_H = 0x223;  /* port 4 */
    33        const Ptr PORTC_L = 0x242;  /* port 5 */
    34        const Ptr PORTC_H = 0x243;  /* port 6 */
    35        const Ptr PORTD_L = 0x262;  /* port 7 */
    36        const Ptr PORTD_H = 0x263;  /* port 8 */
    37        const Ptr PORTE_L = 0x282;  /* port 9 */
    38        const Ptr PORTE_H = 0x283;  /* port 10 */
    39        const Ptr PORTF_L = 0x2A2;  /* port 11 */
    40        
    41        const Ptr PORT0DIR = 0x12;  /* only defined on msp430x33x devices */
    42        const Ptr PORT1DIR = 0x22;
    43        const Ptr PORT2DIR = 0x2A;
    44        const Ptr PORT3DIR = 0x1A;
    45        const Ptr PORT4DIR = 0x1E;
    46        const Ptr PORT5DIR = 0x32;
    47        const Ptr PORT6DIR = 0x36;
    48        const Ptr PORT7DIR = 0x3C;  /* = 0x3A for msp430x41x2 devices */
    49        const Ptr PORT8DIR = 0x3D;
    50    
    51        const Ptr PORTADIR_L = 0x204;
    52        const Ptr PORTADIR_H = 0x205;
    53        const Ptr PORTBDIR_L = 0x224;
    54        const Ptr PORTBDIR_H = 0x225;
    55        const Ptr PORTCDIR_L = 0x244;
    56        const Ptr PORTCDIR_H = 0x245;
    57        const Ptr PORTDDIR_L = 0x264;
    58        const Ptr PORTDDIR_H = 0x265;
    59        const Ptr PORTEDIR_L = 0x284;
    60        const Ptr PORTEDIR_H = 0x285;
    61        const Ptr PORTFDIR_L = 0x2A4;
    62        
    63        /*!
    64         *  ======== PORT ========
    65         *  Address of 8-bit output port to use
    66         */
    67        config Ptr PORT = PORT1;
    68    
    69        /*!
    70         *  ======== DIRCFG ========
    71         *  Address of GPIO configuration register
    72         */
    73        config Ptr DIRCFG = PORT1DIR;
    74        
    75        /*!
    76         *  ======== RED ========
    77         *  Port mask for a red LED
    78         */
    79        config Bits8 RED = 0x1;             /* platform dependent pin */
    80    
    81        /*!
    82         *  ======== GREEN ========
    83         *  Port mask for a green LED
    84         */
    85        config Bits8 GREEN = 0x2;           /* platform dependent pin */
    86    
    87        /*!
    88         *  ======== off ========
    89         *  Turn specified LED off
    90         */
    91        @DirectCall
    92        Void off(Bits8 mask);
    93    
    94        /*!
    95         *  ======== on ========
    96         *  Turn specified LED on
    97         */
    98        @DirectCall
    99        Void on(Bits8 mask);
   100    
   101        /*!
   102         *  ======== toggle ========
   103         *  Toggle the state of specified LED
   104         */
   105        @DirectCall
   106        Void toggle(Bits8 mask);
   107    }