[Top][All Lists]

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

Re: [avr-gcc-list] External 256K FLASH - memory pointer

From: Richard Weickelt
Subject: Re: [avr-gcc-list] External 256K FLASH - memory pointer
Date: Tue, 18 Sep 2012 17:06:46 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120827 Thunderbird/15.0


If a 32 bit
pointer can be somehow declared then this will be pretty elegant. If this
is not possible then the only alternative would be to change the function
parameters as shown below which is not really elegant.
void ReadXFlashBlock (unsigned char *destptr, long sourceaddr, unsigned int 

Yes we can and it has already been suggested: Define Your own abstract data type with an underlying 32 bit integer. You can even overload all operators for it to achieve full pointer semantics. But I would not go so far and overload the dereferencing operator for readability reasons. The signature for Your read function would then look like:
void ReadXFlashBlock (unsigned char* dst, FlashAddress src, unsigned int size);

If templates are Your friends, You can go further and add the value type to Your abstract address type.

This way You avoid ugly casting orgies everywhere in Your code and You can not mess up integers, internal memory pointers and external flash addresses. Ok, these are features of avr-g++, but why not?


reply via email to

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