cancel
Showing results for 
Search instead for 
Did you mean: 

“invalid indirection operand�? error when passing a struct to function in Cosmic compiler and STM8

VYoun
Associate III

I am writing a firmware for stm8 with Cosmic compiler and in ST Visual Develop. I am using astruct as the following:

typedef enum
{
    lcBlack = 0,
    lcRed,
    lcGreen,
    lcOrange
}
led_color_t;
 
    PUBLIC typedef enum
{
    lppEmpty,
    lppStartup,
    lpp_volt_off,
    lpp_volt_warn,
    lpp_volt_over,
    lpp_volt_under,
    lpp_volt_drop,
    lppPause,
    lppHY,
    lppMLZ,
    lppTD,
    lppOnOK,
    lppOff,
    lppLixilTestTouch
}
led_name_t;
 
 
typedef struct
{
    uint8_t             enable;
    led_name_t      led_name;
    led_color_t     led_color;
    uint8_t             prio;
    uint16_t            t_on_0;
    uint16_t            t_off_0;
    uint8_t             cnt_0;
    uint16_t            t_on_1;
    uint16_t            t_off_1;
    uint8_t             cnt_1;
    uint16_t            t_1;
    uint16_t            t_2;
}
led_patt_t;

then I define and initialize an array of structs as the following:

 led_patt_t led_pattern[73] = {
{0, lppEmpty,           lcBlack,       0,      0,       0,      0,      0,       0,      0,      0,       0},
{0, lppStartup,           lcRed,     255,    100,     100,     10,      0,       0,      0,      0,     500},
{1, lpp_volt_off,         lcRed,     210,    100,     100,      2,      0,       0,      0,      0,    1100},
{1, lpp_volt_warn,        lcRed,     210,    150,     150,      2,      0,       0,      0,      0,    1300} 
... }; 

Next I need to define a function that uses the struct array members as the following:

result_t led_pattern_request (led_patt_t led_patt){       
{
    
led_private.pattern_current.color[0]            = led_patt.led_color;
led_private.pattern_current.color[1]            = led_patt.led_color;
led_private.pattern_current.priority            = led_patt.prio;
led_private.pattern_current.time_on_25ms[0]     = (uint8_t)led_patt.t_on_0;
.
.
.
} 

Where

led_data_t led_private; 

Then in my main I call the above function as the following:

led_pattern_request (led_pattern[17]); 

However, after compiling I get the follwing errors:

  • #error cpstm8 ..\src\memory\flash.c:38(36+2) invalid indirection operand
  • #error cpstm8 ..\src\memory\flash.c:38(38) incompatible argument type
  • #error cpstm8 ..\src\memory\flash.c:38(24+11) led_pattern undefined

This is really confusing for me, I also tried to pass a pointer to the struct to the function but I get the same errors. Any help is greatly appreciated. I am new to programming and need your help.

Thank you in advance.

Best regards,

Vouria

0 REPLIES 0