avr-chat
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-chat] Forcing C++ object instances to certain memory locations


From: Rick Mann
Subject: [avr-chat] Forcing C++ object instances to certain memory locations
Date: Sat, 5 Feb 2011 03:14:16 -0800

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]