Hi Paul,

Even though the official line is "don't use iostructures", I am still
a big fan of this method.
I have attached the header file I wrote for use with some 2 family parts.
You should find it easy to adapt to 1 family or 5 family parts, also
you should double check that everything is in the correct place for
your chip (i.e. this comes with no guarantees, YMMV, etc).

- Wayne

#ifndef IOSTRUCTURES_H_
#define IOSTRUCTURES_H_

typedef union
{
    volatile unsigned char _byte;
    volatile struct
    {
    UInt8    _bit0:1,
            _bit1:1,
            _bit2:1,
            _bit3:1,
            _bit4:1,
            _bit5:1,
            _bit6:1,
            _bit7:1;
    } _bits;
} __attribute__ ((packed)) bitfield8;

#define pin0    _bits._bit0
#define pin1    _bits._bit1
#define pin2    _bits._bit2
#define pin3    _bits._bit3
#define pin4    _bits._bit4
#define pin5    _bits._bit5
#define pin6    _bits._bit6
#define pin7    _bits._bit7

struct gpioPort1
{
    bitfield8    in;        // addr 0x20
    bitfield8    out;    //         0x21
    bitfield8    dir;    //         0x22
    bitfield8    ifg;    //         0x23
    bitfield8    ies;    //         0x24
    bitfield8    ie;        //         0x25
    bitfield8    sel;     //         0x26
    bitfield8    ren;     //        0x27
    UInt8        pad0[25];
    bitfield8    sel2;     //        0x41
} __attribute__((__packed__));

struct gpioPort2
{
    bitfield8    in;        // addr 0x28
    bitfield8    out;    //         0x29
    bitfield8    dir;    //         0x2A
    bitfield8    ifg;    //         0x2B
    bitfield8    ies;    //         0x2C
    bitfield8    ie;        //         0x2D
    bitfield8    sel;     //         0x2E
    bitfield8    ren;     //        0x2F
    UInt8        pad0[18];
    bitfield8    sel2;     //        0x42
} __attribute__((__packed__));

struct gpioPort3
{
    bitfield8    ren;     // addr 0x10
    UInt8        pad0[7];
    bitfield8    in;        //        0x18
    bitfield8    out;    //         0x19
    bitfield8    dir;    //         0x1A
    bitfield8    sel;     //         0x1B
    UInt8        pad1[39];
    bitfield8    sel2;     //        0x43
} __attribute__((__packed__));

struct gpioPort4
{
    UInt8         pad0[1];// addr 0x10
    bitfield8    ren;     //        0x11
    UInt8        pad1[10];
    bitfield8    in;        //        0x1C
    bitfield8    out;    //         0x1D
    bitfield8    dir;    //         0x1E
    bitfield8    sel;     //         0x1F
    UInt8         pad2[36];
    bitfield8    sel2;     //        0x44
} __attribute__((__packed__));

struct gpioPort5
{
    bitfield8    ren;     // addr 0x12
    UInt8    pad0[29];
    bitfield8    in;        //        0x30
    bitfield8    out;    //         0x31
    bitfield8    dir;    //         0x32
    bitfield8    sel;     //         0x33
    UInt8         pad1[17];
    bitfield8    sel2;     //        0x45
} __attribute__((__packed__));

struct gpioPort6
{
    UInt8         pad0[1];// addr 0x12
    bitfield8    ren;     //        0x13
    UInt8         pad1[32];
    bitfield8    in;        //        0x34
    bitfield8    out;    //         0x35
    bitfield8    dir;    //         0x36
    bitfield8    sel;     //         0x37
    UInt8         pad2[14];
    bitfield8    sel2;     //        0x46
} __attribute__((__packed__));

extern volatile struct gpioPort1 port1 asm("0x0020");
extern volatile struct gpioPort2 port2 asm("0x0028");
extern volatile struct gpioPort3 port3 asm("0x0010");
extern volatile struct gpioPort4 port4 asm("0x0010");
extern volatile struct gpioPort5 port5 asm("0x0012");
extern volatile struct gpioPort6 port6 asm("0x0012");


#endif /*IOSTRUCTURES_H_*/

On Mon, Jul 16, 2012 at 4:28 PM, Paul Voith <p...@voithconsulting.com> wrote:
> Hi all,
>
> I am trying to port code from an earlier release of msp430-gcc and
> having trouble.
>
> Specifically now that <io.h> is depreciated I don't know the expected
> mechanism to support the "port1.out.pin0" nomenclature for referencing
> bit I/O.
>
> In the past there was an installation kit for the tool chain on windows.
> I see now that there is a built zip file for windows (Thanks Matthias!).
> Any info available on how to install this? Perhaps just unzip into a
> searchable directory is all?
>
> The have referred to the manual but it seems out of date for these aspects.
>
> Thanks
> -- Paul
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Mspgcc-users mailing list
> Mspgcc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to