avr-libc-dev
[Top][All Lists]
Advanced

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

Re[2]: [avr-libc-dev] Creating a table of numbers with different types


From: Volkmar Dierkes
Subject: Re[2]: [avr-libc-dev] Creating a table of numbers with different types
Date: Sat, 19 Mar 2011 20:07:07 +0100

Hallo Dave,

>>> This works fine so far, but I am in the need to add also an address of
>>> another table in PROGMEM, like this:
>>>
>>> unsigned char foo[] PROGMEM = {0, 1, 2};
>>>
>>> I tried several ways to add this to the list above, like this:
>>>
>>> #define lo8(x) (((int)(x)&0xff))
>>> #define hi8(x) (((int)(x)>>8))
>>>
>>> unsigned char lcd_display_function[] PROGMEM = {
>>>         CLCD_FIFO_CMD_FILLRECT, LOK_FCT0_POSX, LOK_FCT0_POSY, 
>>> LOK_FCT0_ENDX, LOK_FCT0_POSY, SOFTKEY_BORDER0_COLOR,
>>>         lo8(foo), hi8(foo),
>>>         CLCD_FIFO_CMD_SUBEND};

> You might want to create one more level of indirection.
> Have an array of pointers, of which foo is one, and store the index of
> the element rather than the address  of it.

It seems this could be a solution even I have to change the type of
parameters.

> I think that the other way of solving this is to use inline assembler
> to create your variables. Then you can mix up the types and store some
> bytes, store some pointers, etc.

I looked also into this already but without success.

> One other way, which would be pure C, would be to create a custom
> structure which has a mixture of bytes and pointers, and instantiate
> one of those. You may need to use packing to ensure that there are no
> gaps before the pointer (I don't recall if pointers in the AVR require
> 2 byte alignment or not).

Unfortunately this is not possible, the used structures have a
different length.

BTW: Sorry for using the wrong list, but I think that helped me
already a lot, so we can close the issue here.

-- 
Best regards,
 Volkmar




reply via email to

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