As part of an experiment I'm conducting in creating a C++ wrapper around AVR 
hardware, I'd like to get C++ objects I've instantiated to live in certain 
parts of the address space.

I have an AVRPort object that looks something like this (simplified):

class
AVRPort
{
public:
    AVRRegisterT            mPin;
    AVRRegisterT            mDirection;
    AVRRegisterT            mPort;
    
    typedef volatile uint8_t            AVRRegisterT;

    //  methods...
};

The PIN, DDR, and PORT registers for port A live at 0x0000, 0x0001, and 0x0002. 
Now, I can access port A successfully via my class by defining this:

#define gPortA          ((AVRPort*) 0x00)
#define gPortB          ((AVRPort*) 0x03)

But I'd much rather define it like this:

extern AVRPort          PortA;
extern AVRPort          PortB;

...

AVRPort                 PortA;
AVRPort                 PortB;

and have it end up in the right place in memory. It seems like it should be 
possible, using a linker script, to put it in the right section.

Is this possible? My current Makefile doesn't seem to use an explicit linker 
script, and it's working fairly well, so I'm hesitant to jump in there and 
break everything by trying to craft one. I'm using a Makefile that came with 
the ChibiOS AVR port.

Suggestions much appreciated. Thanks!

-- 
Rick


_______________________________________________
AVR-chat mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avr-chat

Reply via email to