Ich habe in meinem Programm ein globales Array mit Funktionspointern,
das im Flashspeicher liegen soll. Das Programm funktioniert wie es soll,
allerdings bekomme ich beim Compilieren eine Warnung (siehe unten). Hier
erstmal die relevanten Codeteile:
Damit ich von verschiedenen Programmteilen auf das Array zugreifen kann,
habe ich es in einem Headerfile als extern deklariert:
1 | // vtimer_config.h
|
2 |
|
3 | #define VTIMER_CLIENT_NUM 2
|
1 | // vtimer.h
|
2 |
|
3 | #include "vtimer_config.h"
|
4 |
|
5 | // Callback function prototype
|
6 | typedef void (*vtimer_callback_t)(void);
|
7 |
|
8 | // Callback function array (must be defined by user)
|
9 | extern const PROGMEM vtimer_callback_t vtimer_callback[VTIMER_CLIENT_NUM];
|
Die Definition des Arrays erfolgt im Hauptprogramm:
1 | // main.c
|
2 |
|
3 | #include "vtimer.h"
|
4 |
|
5 | void client_callback_1(void)
|
6 | {
|
7 | leds_toggle(LED_GREEN);
|
8 | }
|
9 |
|
10 | void client_callback_2(void)
|
11 | {
|
12 | leds_toggle(LED_RED);
|
13 | }
|
14 |
|
15 | const PROGMEM vtimer_callback_t vtimer_callback[VTIMER_CLIENT_NUM] = {
|
16 | client_callback_1,
|
17 | client_callback_2,
|
18 | };
|
In vtimer.c wird in einer ISR auf das globale Array zugegriffen, um die
Callback-Funktion aufzurufen:
1 | // vtimer.c
|
2 |
|
3 | #include "vtimer.h"
|
4 |
|
5 | ISR(RTC_COMP_vect)
|
6 | {
|
7 | // [...]
|
8 | ((vtimer_callback_t) pgm_read_word(&vtimer_callback[i]))();
|
9 | // [...]
|
10 | }
|
Es funktioniert auch alles so weit. Allerdings bekomme ich beim
Compilieren von vtimer.c folgende Compilerwarnung:
1 | In function '__vector_11':
|
2 | [Pfad]\vtimer.h(20,40): uninitialized variable 'vtimer_callback' put into program memory area [-Wuninitialized]
|
Hat das etwas zu bedeuten? Wird das Array wirklich nochmal in vtimer.c
angelegt? Das Programm funktioniert wie gesagt, verwendet wird also
offensichtlich schon das Array aus main.c. Soll ich die Warnung
ignorieren? Bzw. gibt es eine Möglichkeit, sie loszuwerden?
Ich benutzte AVR-Studio 6.0 mit dem AVR-GCC 4.6.2, der standardmäßig
dabei ist.
Danke schonmal!