[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[solved] Re: Something I don't understand (loops and interrupts)
From: |
BERTRAND Joël |
Subject: |
[solved] Re: Something I don't understand (loops and interrupts) |
Date: |
Fri, 3 Apr 2020 17:56:53 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0 SeaMonkey/2.53.1 |
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