I have written in a header :

static gpio_t i_led[i_max] =
            {
                    { &PORTD, &PIND, 3, 0 },
                    { &PORTD, &PIND, 4, 0 },
                    { &PORTD, &PIND, 5, 0 },
                    { &PORTD, &PIND, 6, 0 },
                    { &PORTD, &PIND, 7, 0 },
                    { &PORTB, &PINB, 0, 0 },
                    { &PORTB, &PINB, 1, 0 },
                    { &PORTB, &PINB, 2, 0 },
                    { &PORTB, &PINB, 3, 0 },
                    { &PORTB, &PINB, 4, 0 }
            };

        Note the "static" keyword. With this keyword, table is different in
each file that includes this header ! Solution is :

typedef volatile struct
{
    volatile uint8_t    *port;
    volatile uint8_t    *pin;
    volatile uint8_t    bitNo;
    volatile int8_t     timer;
} gpio_t;

#ifdef __MAIN__
    volatile gpio_t i_led[i_max] =
            {
                    { &PORTD, &PIND, 3, 0 },
                    { &PORTD, &PIND, 4, 0 },
                    { &PORTD, &PIND, 5, 0 },
                    { &PORTD, &PIND, 6, 0 },
                    { &PORTD, &PIND, 7, 0 },
                    { &PORTB, &PINB, 0, 0 },
                    { &PORTB, &PINB, 1, 0 },
                    { &PORTB, &PINB, 2, 0 },
                    { &PORTB, &PINB, 3, 0 },
                    { &PORTB, &PINB, 4, 0 }
            };
#else
    extern volatile gpio_t i_led[i_max];
#endif

        And my firmware runs as expected.

        Regards,

        JKB

Reply via email to