menu.h // Forward structure declarations struct MENU_Item_Collection_ struct; typedef struct MENU_Item_Collection_ struct MENU_Item_Collection_t; struct MENU_Item_Collection_ struct { U8 menu_mask; U8 menu_enter; U8 menu_exit; U8 item_group; U8 item_group_index; U8 item_type; PGM_VOID_P item_p; }; void update_screen (MENU_Item_Collection_t const * menu_items); //----------- end menu.h --------------// menu.c void update_screen (MENU_Item_Collection_t const * menu_items) { U8 item_group = 0; item_group = pgm_read_byte(menu_items ->item_group); ... ... } //----------- end menu.c --------------// setup.c #include menu.h const MENU_Item_Collection_t PROGMEM menu_items_pgm[] = { {0xFF,0x01,0x00,0x01,0x00,0x01,&menu_1} ,{0xFF,0x00,0x00,0x01,0x01,0x03,&menu_2} ,{0xBF,0x00,0x00,0x01,0x02,0x03,&menu_3} ,{0x9F,0x00,0x00,0x01,0x03,0x03,&menu_4} ,{...} ,{...} } Some_function (void) { update_screen (&menu_items_pgm[2]); ... ... } //----------- end setup.c --------------//
Whatever I try to get the pointer to my structure, I get the wrong values in the 'update_screen' function. If I use a different cast than const *, I get an error from the compiler, or else, I can’t reference to the different elements in the structure.
Any ideas what I’m doing wrong (it's probably something stupid)?