Forum: Mikrocontroller und Digitale Elektronik irsnd Callback function


von Thomas G. (funker_67)


Lesenswert?

Hallo,

ich habe ein Problem und hoffe Ihr könnt mir dabei helfen.

Es geht um einen IR-Sender mit einem ATTiny45 Controller. Als IDE 
benutze ich Atmel Studio 4.19. Die Hardware funktioniert einwandfrei. 
Die IR-LED leuchtet und der IR-Empfänger kann die Signale empfangen und 
dekodieren. Alles OK.
Jetzt wollte ich die Callback-Funktion, nach der Beschreibung auf der 
Projektseite einbauen. Dabei gibt der Compiler eine Fehlermeldung aus 
die ich nicht verstehe.

Build started 1.7.2018 at 10:36:57
avr-gcc -mmcu=attiny45 -Wl,-Map=irsnd.map irsnd-main-avr.o irsnd.o 
-o irsnd.elf
irsnd-main-avr.o: In function `main':
C:\Users\Thomas\Documents\IR-FB_Sender\IRSND_Astudio4\default/../irsnd-m 
ain-avr.c:96:  undefined reference to `irsnd_set_callback_ptr'
collect2: ld returned 1 exit status
make: *** [irsnd.elf] Fehler 1
Build failed with 1 errors and 0 warnings...

Link zur IR-Sender Seite: https://www.mikrocontroller.net/articles/IRSND

Hier mein Code des Hauptprogramms:
1
/*---------------------------------------------------------------------------------------------------------------------------------------------------
2
 * irsnd-main-avr.c - demo main module to test IRSND encoder on AVRs
3
 *
4
 * Copyright (c) 2010-2016 Frank Meyer - frank(at)fli4l.de
5
 *
6
 * $Id: irsnd-main-avr.c,v 1.3 2016/09/09 08:01:11 fm Exp $
7
 *
8
 * ATMEGA88 @ 8 MHz internal RC      Osc with BODLEVEL 4.3V: lfuse: 0xE2 hfuse: 0xDC efuse: 0xF9
9
 * ATMEGA88 @ 8 MHz external Crystal Osc with BODLEVEL 4.3V: lfuse: 0xFF hfuse: 0xDC efuse: 0xF9
10
 *
11
 * This program is free software; you can redistribute it and/or modify
12
 * it under the terms of the GNU General Public License as published by
13
 * the Free Software Foundation; either version 2 of the License, or
14
 * (at your option) any later version.
15
 *---------------------------------------------------------------------------------------------------------------------------------------------------
16
 */
17
#include "irsnd.h"
18
19
#ifndef F_CPU
20
#  error F_CPU unknown
21
#endif
22
23
void
24
timer1_init (void)
25
{
26
#if defined (__AVR_ATtiny45__) || defined (__AVR_ATtiny85__)                // ATtiny45 / ATtiny85:
27
    OCR1C   =  (F_CPU / F_INTERRUPTS / 4) - 1;                              // compare value: 1/15000 of CPU frequency, presc = 4
28
    TCCR1   = (1 << CTC1) | (1 << CS11) | (1 << CS10);                      // switch CTC Mode on, set prescaler to 4
29
#else                                                                       // ATmegaXX:
30
    OCR1A   =  (F_CPU / F_INTERRUPTS) - 1;                                  // compare value: 1/15000 of CPU frequency
31
    TCCR1B  = (1 << WGM12) | (1 << CS10);                                   // switch CTC Mode on, set prescaler to 1
32
#endif
33
34
#ifdef TIMSK1
35
    TIMSK1  = 1 << OCIE1A;                                                  // OCIE1A: Interrupt by timer compare
36
#else
37
    TIMSK   = 1 << OCIE1A;                                                  // OCIE1A: Interrupt by timer compare
38
#endif
39
}
40
41
#ifdef TIM1_COMPA_vect                                                      // ATtiny84
42
#define COMPA_VECT  TIM1_COMPA_vect
43
#else
44
#define COMPA_VECT  TIMER1_COMPA_vect                                       // ATmega
45
#endif
46
47
48
#define LED_PORT PORTB                                  // LED at PB2
49
#define LED_DDR  DDRB
50
#define LED_PIN  2
51
52
/*---------------------------------------------------------------------------------------------------------------------------------------------------
53
 * timer 1 compare handler, called every 1/10000 sec
54
 *---------------------------------------------------------------------------------------------------------------------------------------------------
55
 */
56
ISR(COMPA_VECT)                                                             // Timer1 output compare A interrupt service routine, called every 1/15000 sec
57
{
58
    (void) irsnd_ISR();                                                     // call irsnd ISR
59
    // call other timer interrupt routines here...
60
}
61
62
/*-----------------------------------------------------------------------------------------------------------------------
63
 * Called (back) from IRSND module
64
 * This example switches a LED (which is connected to Vcc)
65
 *-----------------------------------------------------------------------------------------------------------------------
66
 */
67
68
void led_callback (uint8_t on)
69
{
70
    if (on)
71
    {
72
       LED_PORT &= ~(1 << LED_PIN);
73
    }
74
    else
75
    {
76
       LED_PORT |= (1 << LED_PIN);
77
    }
78
}
79
80
/*---------------------------------------------------------------------------------------------------------------------------------------------------
81
 * MAIN: main routine
82
 *---------------------------------------------------------------------------------------------------------------------------------------------------
83
 */
84
85
int
86
main (void)
87
{
88
89
    IRMP_DATA irmp_data;
90
  
91
92
     LED_DDR |= (1 << LED_PIN);         // LED pin to output
93
    LED_PORT |= (1 << LED_PIN);        // switch LED off (active low)
94
    irsnd_init ();
95
  timer1_init();
96
    irsnd_set_callback_ptr (led_callback);
97
    sei ();               // enable interrupts
98
                                                                 
99
100
    for (;;)
101
    {
102
        irmp_data.protocol = IRMP_IR60_PROTOCOL;                            // use IR60 protocol
103
        irmp_data.address  = 0x00FF;                                        // set address to 0x00FF
104
        irmp_data.command  = 0x0001;                                        // set command to 0x0001
105
        irmp_data.flags    = 0;                                             // don't repeat frame
106
107
        irsnd_send_data (&irmp_data, TRUE);                                 // send frame, wait for completion
108
        _delay_ms (1000);
109
110
    }
111
}

und hier noch der Code des config-Files:
1
/*---------------------------------------------------------------------------------------------------------------------------------------------------
2
 * irsndconfig.h
3
 *
4
 * DO NOT INCLUDE THIS FILE, WILL BE INCLUDED BY IRSND.H!
5
 *
6
 * Copyright (c) 2010-2016 Frank Meyer - frank(at)fli4l.de
7
 *
8
 * $Id: irsndconfig.h,v 1.91 2018/02/19 10:25:25 fm Exp $
9
 *
10
 * This program is free software; you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation; either version 2 of the License, or
13
 * (at your option) any later version.
14
 *---------------------------------------------------------------------------------------------------------------------------------------------------
15
 */
16
17
#ifndef _IRSNDCONFIG_H_
18
#define _IRSNDCONFIG_H_
19
20
#if !defined(_IRSND_H_)
21
#  error please include only irsnd.h, not irsndconfig.h
22
#endif
23
24
// #define IRSND_DEBUG 1                                // activate debugging
25
26
/*---------------------------------------------------------------------------------------------------------------------------------------------------
27
 * F_INTERRUPTS: number of interrupts per second, should be in the range from 10000 to 20000, typically 15000
28
 *---------------------------------------------------------------------------------------------------------------------------------------------------
29
 */
30
#ifndef F_INTERRUPTS
31
#  define F_INTERRUPTS                          15000   // interrupts per second
32
#endif
33
34
/*---------------------------------------------------------------------------------------------------------------------------------------------------
35
 * Change settings from 1 to 0 if you want to disable one or more encoders.
36
 * This saves program space.
37
 * 1 enable  decoder
38
 * 0 disable decoder
39
 *---------------------------------------------------------------------------------------------------------------------------------------------------
40
 */
41
42
// typical protocols, disable here!             Enable  Remarks                 F_INTERRUPTS            Program Space
43
#define IRSND_SUPPORT_SIRCS_PROTOCOL            0       // Sony SIRCS           >= 10000                 ~200 bytes
44
#define IRSND_SUPPORT_NEC_PROTOCOL              0       // NEC + APPLE          >= 10000                 ~100 bytes
45
#define IRSND_SUPPORT_SAMSUNG_PROTOCOL          0       // Samsung + Samsung32  >= 10000                 ~300 bytes
46
#define IRSND_SUPPORT_MATSUSHITA_PROTOCOL       0       // Matsushita           >= 10000                 ~200 bytes
47
#define IRSND_SUPPORT_KASEIKYO_PROTOCOL         0       // Kaseikyo             >= 10000                 ~300 bytes
48
49
// more protocols, enable here!                 Enable  Remarks                 F_INTERRUPTS            Program Space
50
#define IRSND_SUPPORT_DENON_PROTOCOL            0       // DENON, Sharp         >= 10000                 ~200 bytes
51
#define IRSND_SUPPORT_RC5_PROTOCOL              1       // RC5                  >= 10000                 ~150 bytes
52
#define IRSND_SUPPORT_RC6_PROTOCOL              0       // RC6                  >= 10000                 ~250 bytes
53
#define IRSND_SUPPORT_RC6A_PROTOCOL             0       // RC6A                 >= 10000                 ~250 bytes
54
#define IRSND_SUPPORT_JVC_PROTOCOL              0       // JVC                  >= 10000                 ~150 bytes
55
#define IRSND_SUPPORT_NEC16_PROTOCOL            0       // NEC16                >= 10000                 ~150 bytes
56
#define IRSND_SUPPORT_NEC42_PROTOCOL            0       // NEC42                >= 10000                 ~150 bytes
57
#define IRSND_SUPPORT_IR60_PROTOCOL             1       // IR60 (SDA2008)       >= 10000                 ~250 bytes
58
#define IRSND_SUPPORT_GRUNDIG_PROTOCOL          0       // Grundig              >= 10000                 ~300 bytes
59
#define IRSND_SUPPORT_SIEMENS_PROTOCOL          0       // Siemens, Gigaset     >= 15000                 ~150 bytes
60
#define IRSND_SUPPORT_NOKIA_PROTOCOL            0       // Nokia                >= 10000                 ~400 bytes
61
62
// exotic protocols, enable here!               Enable  Remarks                 F_INTERRUPTS            Program Space
63
#define IRSND_SUPPORT_BOSE_PROTOCOL             0       // BOSE                 >= 10000                 ~100 bytes
64
#define IRSND_SUPPORT_KATHREIN_PROTOCOL         0       // Kathrein             >= 10000                 DON'T CHANGE, NOT SUPPORTED YET!
65
#define IRSND_SUPPORT_NUBERT_PROTOCOL           0       // NUBERT               >= 10000                 ~100 bytes
66
#define IRSND_SUPPORT_FAN_PROTOCOL              0       // FAN (ventilator)     >= 10000                 ~100 bytes
67
#define IRSND_SUPPORT_SPEAKER_PROTOCOL          0       // SPEAKER              >= 10000                 ~100 bytes
68
#define IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL     0       // Bang&Olufsen         >= 10000                 ~250 bytes
69
#define IRSND_SUPPORT_RECS80_PROTOCOL           0       // RECS80               >= 15000                 ~100 bytes
70
#define IRSND_SUPPORT_RECS80EXT_PROTOCOL        0       // RECS80EXT            >= 15000                 ~100 bytes
71
#define IRSND_SUPPORT_THOMSON_PROTOCOL          0       // Thomson              >= 10000                 ~250 bytes
72
#define IRSND_SUPPORT_NIKON_PROTOCOL            0       // NIKON                >= 10000                 ~150 bytes
73
#define IRSND_SUPPORT_NETBOX_PROTOCOL           0       // Netbox keyboard      >= 10000                 DON'T CHANGE, NOT SUPPORTED YET!
74
#define IRSND_SUPPORT_ORTEK_PROTOCOL            0       // ORTEK (Hama)         >= 10000                 DON'T CHANGE, NOT SUPPORTED YET!
75
#define IRSND_SUPPORT_TELEFUNKEN_PROTOCOL       0       // Telefunken 1560      >= 10000                 ~150 bytes
76
#define IRSND_SUPPORT_FDC_PROTOCOL              0       // FDC IR keyboard      >= 10000 (better 15000)  ~150 bytes
77
#define IRSND_SUPPORT_RCCAR_PROTOCOL            0       // RC CAR               >= 10000 (better 15000)  ~150 bytes
78
#define IRSND_SUPPORT_ROOMBA_PROTOCOL           0       // iRobot Roomba        >= 10000                 ~150 bytes
79
#define IRSND_SUPPORT_RUWIDO_PROTOCOL           0       // RUWIDO, T-Home       >= 15000                 ~250 bytes
80
#define IRSND_SUPPORT_A1TVBOX_PROTOCOL          0       // A1 TV BOX            >= 15000 (better 20000)  ~200 bytes
81
#define IRSND_SUPPORT_LEGO_PROTOCOL             0       // LEGO Power RC        >= 20000                 ~150 bytes
82
#define IRSND_SUPPORT_RCMM_PROTOCOL             0       // RCMM 12,24, or 32    >= 20000                 DON'T CHANGE, NOT SUPPORTED YET!
83
#define IRSND_SUPPORT_LGAIR_PROTOCOL            0       // LG Air Condition     >= 10000                 ~150 bytes.
84
#define IRSND_SUPPORT_SAMSUNG48_PROTOCOL        0       // Samsung48            >= 10000                 ~100 bytes
85
#define IRSND_SUPPORT_PENTAX_PROTOCOL           0       // Pentax               >= 10000                 ~150 bytes
86
#define IRSND_SUPPORT_S100_PROTOCOL             0       // S100                 >= 10000                 ~150 bytes
87
#define IRSND_SUPPORT_ACP24_PROTOCOL            0       // ACP24                >= 10000                 ~150 bytes
88
#define IRSND_SUPPORT_TECHNICS_PROTOCOL         0       // TECHNICS             >= 10000                 DON'T CHANGE, NOT SUPPORTED YET!
89
#define IRSND_SUPPORT_PANASONIC_PROTOCOL        0       // PANASONIC Beamer     >= 10000                 ~150 bytes
90
#define IRSND_SUPPORT_MITSU_HEAVY_PROTOCOL      0       // Mitsubishi-Heavy Aircondition, similar Timing to Panasonic beamer
91
#define IRSND_SUPPORT_IRMP16_PROTOCOL           0       // IRMP specific        >= 15000                 ~250 bytes
92
93
94
/*---------------------------------------------------------------------------------------------------------------------------------------------------
95
 * AVR XMega section:
96
 *
97
 * Change hardware pin here:                    IRSND_XMEGA_OC0A = OC0A on ATxmegas  supporting OC0A, e.g. ATxmega128A1U
98
 *                                              IRSND_XMEGA_OC0B = OC0B on ATxmegas  supporting OC0B, e.g. ATxmega128A1U
99
 *                                              IRSND_XMEGA_OC0C = OC0C on ATxmegas  supporting OC0C, e.g. ATxmega128A1U
100
 *                                              IRSND_XMEGA_OC0D = OC0D on ATxmegas  supporting OC0D, e.g. ATxmega128A1U
101
 *                                              IRSND_XMEGA_OC1A = OC1A on ATxmegas  supporting OC1A, e.g. ATxmega128A1U
102
 *                                              IRSND_XMEGA_OC1B = OC1B on ATxmegas  supporting OC1B, e.g. ATxmega128A1U
103
 *---------------------------------------------------------------------------------------------------------------------------------------------------
104
 */
105
#if defined(__AVR_XMEGA__)                                              // XMEGA
106
#  define IRSND_PORT_PRE                        PORTD
107
#  define XMEGA_Timer                           TCD0
108
#  define IRSND_OCx                             IRSND_XMEGA_OC0B        // use OC0B
109
110
/*---------------------------------------------------------------------------------------------------------------------------------------------------
111
 * AVR ATMega/ATTiny section:
112
 *
113
 * Change hardware pin here:                    IRSND_OC2  = OC2  on ATmegas         supporting OC2,  e.g. ATmega8
114
 *                                              IRSND_OC2A = OC2A on ATmegas         supporting OC2A, e.g. ATmega88
115
 *                                              IRSND_OC2B = OC2B on ATmegas         supporting OC2B, e.g. ATmega88
116
 *                                              IRSND_OC0  = OC0  on ATmegas         supporting OC0,  e.g. ATmega162
117
 *                                              IRSND_OC0A = OC0A on ATmegas/ATtinys supporting OC0A, e.g. ATtiny84, ATtiny85, ATtiny87/167
118
 *                                              IRSND_OC0B = OC0B on ATmegas/ATtinys supporting OC0B, e.g. ATtiny84, ATtiny85
119
 *---------------------------------------------------------------------------------------------------------------------------------------------------
120
 */
121
#elif defined(ATMEL_AVR)
122
#  define IRSND_OCx                             IRSND_OC0B              // use OC2B
123
124
/*---------------------------------------------------------------------------------------------------------------------------------------------------
125
 * PIC C18 or XC8 section:
126
 *
127
 * Change hardware pin here:                    IRSND_PIC_CCP1 = RC2 on PIC 18F2550/18F4550, ...
128
 *                                              IRSND_PIC_CCP2 = RC1 on PIC 18F2550/18F4550, ...
129
 *---------------------------------------------------------------------------------------------------------------------------------------------------
130
 */
131
#elif defined(PIC_C18)                                                  // C18 or XC8 compiler
132
#  if defined(__12F1840)                                                // XC8 compiler
133
#    define Pre_Scaler                          1                       // define prescaler for timer2 e.g. 1,4,16
134
#    define F_CPU                               32000000UL              // PIC frequency: set your freq here
135
#    define PIC_Scaler                          2                       // PIC needs /2 extra in IRSND_FREQ_32_KHZ calculation for right value
136
137
#  else                                                                 // C18 compiler
138
#    define IRSND_OCx                           IRSND_PIC_CCP2          // Use PWMx for PIC
139
                                                                        // change other PIC C18 specific settings:
140
#    define F_CPU                               48000000UL              // PIC frequency: set your freq here
141
#    define Pre_Scaler                          4                       // define prescaler for timer2 e.g. 1,4,16
142
#    define PIC_Scaler                          2                       // PIC needs /2 extra in IRSND_FREQ_32_KHZ calculation for right value
143
#  endif
144
145
/*---------------------------------------------------------------------------------------------------------------------------------------------------
146
 * ARM STM32 section:
147
 *---------------------------------------------------------------------------------------------------------------------------------------------------
148
 */
149
#elif defined (ARM_STM32)                                               // use B6 as IR output on STM32
150
#  define IRSND_PORT_LETTER                     B
151
#  define IRSND_BIT_NUMBER                      6
152
#  define IRSND_TIMER_NUMBER                    4
153
#  define IRSND_TIMER_CHANNEL_NUMBER            1                       // only channel 1 can be used at the moment, others won't work
154
155
/*---------------------------------------------------------------------------------------------------------------------------------------------------
156
 * Teensy 3.x with teensyduino gcc compiler
157
 *---------------------------------------------------------------------------------------------------------------------------------------------------
158
 */
159
#elif defined (TEENSY_ARM_CORTEX_M4)
160
#  define IRSND_PIN                             5                       // choose an arduino pin with PWM function!
161
162
/*---------------------------------------------------------------------------------------------------------------------------------------------------
163
 * Other target systems
164
 *---------------------------------------------------------------------------------------------------------------------------------------------------
165
 */
166
#elif !defined (UNIX_OR_WINDOWS)
167
#  error target system not defined.
168
#endif
169
170
/*---------------------------------------------------------------------------------------------------------------------------------------------------
171
 * ESP8266 (Arduino, see IRSEND.ino)
172
 *---------------------------------------------------------------------------------------------------------------------------------------------------
173
 */
174
#elif defined (__xtensa__)
175
#  define IRSND_PIN                             0                       // choose an arduino pin with PWM function!
176
177
/*---------------------------------------------------------------------------------------------------------------------------------------------------
178
 * Use Callbacks to indicate output signal or something else
179
 *---------------------------------------------------------------------------------------------------------------------------------------------------
180
 */
181
#ifndef IRSND_USE_CALLBACK
182
#  define IRSND_USE_CALLBACK                    1                       // flag: 0 = don't use callbacks, 1 = use callbacks, default is 0
183
#endif
184
185
#endif // _IRSNDCONFIG_H_

Wie baue ich die Callback-Funktion so ein das ein unmoduliertes Signal 
an einem weiteren Pin auszugeben wird?

Vielen Dank für eure Hilfe

Thomas

von devzero (Gast)


Lesenswert?

Den Setter gibts nicht. Setzst Du das define?
#ifndef IRSND_USE_CALLBACK
#  define IRSND_USE_CALLBACK                    1 
// flag: 0 = don't use callbacks, 1 = use callbacks, default is 0
#endif

Da ist ein ifndef. Wird das ggf. wo auf 0 gesetzt?

von Rufus Τ. F. (rufus) Benutzerseite


Lesenswert?

Die Fehlermeldung sagt aus, daß es keinen Code für die Funktion 
"irsnd_set_callback_ptr" gibt.

Der Funktionsprototyp steht wohl in "irsnd.h" drin, aber die 
Implementierung der Funktion fehlt in in irsnd.c.

Und wenn man da nachsieht, sieht man, daß die mit bedingter Compilierung 
übersetzt wird:
1
#if IRSND_USE_CALLBACK == 1
2
void
3
irsnd_set_callback_ptr (void (*cb)(uint8_t))
4
{
5
    irsnd_callback_ptr = cb;
6
}
7
#endif // IRSND_USE_CALLBACK == 1


Da Du das in Deiner Konfigurationsdatei auch angegeben hast, musst Du 
irsnd.c erneut übersetzen. Ein "make clean" gefolgt von einem "make all" 
sollte das Problem lösen.

Wenn es das nicht tut, ist IRSND_USE_CALLBACK irgendwo anders vor dem 
Einbinden Deiner Konfigurationsdatei bereits definiert -- suche danach.

von Thomas G. (funker_67)


Lesenswert?

Vielen Dank für Eure Antworten.

Die Funktion ist in der config-Datei freigeschaltet. Sollte also gehen.

Das "make clean" gefolgt von einem "make all" hat leider nicht geholfen

Ich habe die Definition von IRSND_USE_CALLBACK gesucht und in der Datei 
irsnd.c ab Zeile 532 und ab Zeile 597 gefunden. Laut Projektbeschreibung 
soll man nur die Datei irsnd.h mit #include einbinden. Das habe ich so 
gemacht.

Die Datei irsnd.c mit #include einbinden hat nicht funktioniert.

Thomas

von Rufus Τ. F. (rufus) Benutzerseite


Lesenswert?

Thomas G. schrieb:
> Ich habe die Definition von IRSND_USE_CALLBACK gesucht und in der Datei
> irsnd.c ab Zeile 532 und ab Zeile 597 gefunden.

Das ist nicht die Definition von IRSND_USE_CALLBACK.

An der ersten Stelle wird der Funktionspointer "irsnd_callback_ptr" 
definiert, wenn das Macro IRSND_USE_CALLBACK den Wert 1 hat, an der 
zweiten Stelle wird Deine fehlende Funktion definiert (d.h. 
implementiert), wenn das Macro den Wert 1 hat.

Entweder übersetzt Du irsnd.c nicht, oder Du hast irgendwo das Macro auf 
einen anderen Wert als 1 gesetzt.

Zeig mal Deinen Compileraufruf.

Der von ganz oben ist nur der Linkeraufruf, der bereits anderswo 
übersetzte Objektdateien zusammenpackt:

> avr-gcc -mmcu=attiny45 -Wl,-Map=irsnd.map irsnd-main-avr.o irsnd.o -o irsnd.elf


Wo kommt Deine irsnd.o her? Hast Du die tatsächlich mit Deinem 
Make-Aufruf neu erzeugt? Achte auf das Dateidatum.

von Thomas G. (funker_67)


Lesenswert?

Die Datei irsnd.o ist frisch übersetzt. Sie hat das heutige Datum und 
die aktuelle Zeit.
1
rm -rf irsnd-main-avr.o irsnd.o  irsnd.elf dep/* irsnd.hex irsnd.eep irsnd.lss irsnd.map
2
Build succeeded with 0 Warnings...
3
avr-gcc  -mmcu=attiny45 -Wall -gdwarf-2 -std=gnu99                                                 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT irsnd-main-avr.o -MF dep/irsnd-main-avr.o.d  -c  ../irsnd-
4
main-avr.c
5
6
../irsnd-main-avr.c: In function 'main':
7
../irsnd-main-avr.c:96:5: warning: implicit declaration of function 'irsnd_set_callback_ptr'
8
avr-gcc  -mmcu=attiny45 -Wall -gdwarf-2 -std=gnu99                                                 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT irsnd.o -MF dep/irsnd.o.d  -c  ../irsnd.c
9
../irsnd.c: In function 'irsnd_send_data':
10
../irsnd.c:980:21: warning: unused variable 'address'
11
../irsnd.c: In function 'irsnd_ISR':
12
../irsnd.c:1637:33: warning: unused variable 'pause_0_len'
13
../irsnd.c:1636:33: warning: unused variable 'pulse_0_len'
14
../irsnd.c:1635:33: warning: unused variable 'pause_1_len'
15
../irsnd.c:1634:33: warning: unused variable 'pulse_1_len'
16
avr-gcc -mmcu=attiny45 -Wl,-Map=irsnd.map irsnd-main-avr.o irsnd.o     -o irsnd.elf
17
irsnd-main-avr.o: In function `main':
18
C:\Users\Thomas\Documents\Arbeitsgemeinschaft\Bauanleitungen\IR-FB_Sender\IRSND_Astudio4\default/../irsnd-main-avr.c:96: undefined reference to `irsnd_set_callback_ptr'
19
collect2: ld returned 1 exit status
20
make: *** [irsnd.elf] Fehler 1
21
Build failed with 1 errors and 6 warnings...

Das hat er gemeldet als ich eben F7 Build gemacht habe.

von STK500-Besitzer (Gast)


Lesenswert?

Thomas G. schrieb:
> ../irsnd-main-avr.c:96:5: warning: implicit declaration of function
> 'irsnd_set_callback_ptr'
> avr-gcc  -mmcu=attiny45 -Wall -gdwarf-2 -std=gnu99

Die Funktion 'irsnd_set_callback_ptr' sollte in der .h deklariert 
werden.

von Rufus Τ. F. (rufus) Benutzerseite


Lesenswert?

STK500-Besitzer schrieb:
> Die Funktion 'irsnd_set_callback_ptr' sollte in der .h deklariert
> werden.

Das wird sie auch, wenn das Macro IRSND_USE_CALLBACK den Wert 1 hat.

Offensichtlich ist das nicht der Fall.

Also wird die Konfigurationsdatei, in der Thomas das eingetragen hat, 
nicht ausgewertet.

von Thomas G. (funker_67)


Lesenswert?

Am Anfang (ab Zeile 18) der Datei irsnd.h steht folgendes:
1
.
2
.
3
.
4
#include "irmpsystem.h"
5
#ifndef IRSND_USE_AS_LIB
6
#  include "irsndconfig.h"
7
#endif
8
.
9
.
10
.

Da komme ich nicht mit. Muß ich da in der IDE was einstellen?

von Rufus Τ. F. (rufus) Benutzerseite


Lesenswert?

Ist in irmpsystem.h oder in Deinem Makefile irgendwo das Macro 
IRSND_USE_AS_LIB definiert?

Wenn das der Fall ist --und da genügt die reine Definition, der Wert ist 
irrelevant!--, dann wird Deine Konfigurationsdatei nicht eingebunden.

von Thomas G. (funker_67)


Lesenswert?

Nein ich habe es in beiden nicht gefunden.

Ich füge beides mal trotzdem hier ein.
1
/*---------------------------------------------------------------------------------------------------------------------------------------------------
2
 * irmpsystem.h - system specific includes and defines
3
 *
4
 * Copyright (c) 2009-2016 Frank Meyer - frank(at)fli4l.de
5
 *
6
 * $Id: irmpsystem.h,v 1.26 2017/08/25 12:24:18 fm Exp $
7
 *
8
 * This program is free software; you can redistribute it and/or modify
9
 * it under the terms of the GNU General Public License as published by
10
 * the Free Software Foundation; either version 2 of the License, or
11
 * (at your option) any later version.
12
 *---------------------------------------------------------------------------------------------------------------------------------------------------
13
 */
14
15
#ifndef _IRMPSYSTEM_H_
16
#define _IRMPSYSTEM_H_
17
18
#if !defined(_IRMP_H_) && !defined(_IRSND_H_)
19
#  error please include only irmp.h or irsnd.h, not irmpsystem.h
20
#endif
21
22
#if defined(__18CXX)                                                                // Microchip PIC C18 compiler
23
#  define PIC_C18
24
#elif defined(__XC8)                                                                // PIC XC8 compiler
25
#  include <xc.h>
26
#  define PIC_C18
27
#elif defined(__PCM__) || defined(__PCB__) || defined(__PCH__)                      // CCS PIC compiler
28
#  define PIC_CCS
29
#elif defined(STM32L1XX_MD) || defined(STM32L1XX_MDP) || defined(STM32L1XX_HD)      // ARM STM32
30
#  include <stm32l1xx.h>
31
#  define ARM_STM32
32
#  define ARM_STM32L1XX
33
#  define F_CPU (SysCtlClockGet())
34
#elif defined(STM32F10X_LD) || defined(STM32F10X_LD_VL) \
35
   || defined(STM32F10X_MD) || defined(STM32F10X_MD_VL) \
36
   || defined(STM32F10X_HD) || defined(STM32F10X_HD_VL) \
37
   || defined(STM32F10X_XL) || defined(STM32F10X_CL)                                // ARM STM32
38
#  include <stm32f10x.h>
39
#  define ARM_STM32
40
#  define ARM_STM32F10X
41
#  define F_CPU (SysCtlClockGet())
42
#elif defined(STM32F4XX)                                                            // ARM STM32
43
#  include <stm32f4xx.h>
44
#  define ARM_STM32
45
#  define ARM_STM32F4XX
46
#elif defined(__SDCC_stm8)                                                          // STM8
47
#  define SDCC_STM8
48
#elif defined(TARGET_IS_BLIZZARD_RA2)                                               // TI Stellaris (tested on Stellaris Launchpad with Code Composer Studio)
49
#  define STELLARIS_ARM_CORTEX_M4
50
#  define F_CPU (SysCtlClockGet())
51
#elif defined(__xtensa__)                                                           // ESP8266 (Arduino)
52
#  include "Arduino.h"
53
#  include "ets_sys.h"
54
#  include "osapi.h"
55
#  include "gpio.h"
56
#  include "os_type.h"
57
#  include "c_types.h"
58
#  define uint_fast8_t uint8_t
59
#  define uint_fast16_t uint16_t
60
#elif defined(TEENSYDUINO) && (defined(__MK20DX256__) || defined(__MK20DX128__))    // Teensy 3.x (tested on Teensy 3.1 in Arduino 1.6.5 / Teensyduino 1.2.5)
61
#  include <core_pins.h>
62
#  define TEENSY_ARM_CORTEX_M4
63
#elif defined(unix) || defined(WIN32) || defined(__APPLE__)                         // Unix/Linux or Windows or Apple
64
#  define UNIX_OR_WINDOWS
65
#elif defined(__MBED__)                                                             // mbed platform
66
// #include "mbed.h"                                                                // if mbed.h is used, source must be compiled as cpp
67
#include "gpio_api.h"
68
#else
69
#  define ATMEL_AVR                                                                 // ATMEL AVR
70
#endif
71
72
#include <string.h>
73
74
#ifdef UNIX_OR_WINDOWS                                                              // Analyze on Unix/Linux or Windows
75
#  include <stdio.h>
76
#  include <stdlib.h>
77
#  define F_CPU 8000000L
78
#  define ANALYZE
79
#  ifdef unix
80
#    include <stdint.h>
81
#  else
82
typedef unsigned char                   uint8_t;
83
typedef unsigned short                  uint16_t;
84
#  endif
85
#endif
86
87
88
#if defined(ATMEL_AVR)
89
#  include <stdint.h>
90
#  include <stdio.h>
91
#  include <avr/io.h>
92
#  include <util/delay.h>
93
#  include <avr/pgmspace.h>
94
#  include <avr/interrupt.h>
95
#  define IRSND_OC2                     0       // OC2
96
#  define IRSND_OC2A                    1       // OC2A
97
#  define IRSND_OC2B                    2       // OC2B
98
#  define IRSND_OC0                     3       // OC0
99
#  define IRSND_OC0A                    4       // OC0A
100
#  define IRSND_OC0B                    5       // OC0B
101
102
#  define IRSND_XMEGA_OC0A              0       // OC0A
103
#  define IRSND_XMEGA_OC0B              1       // OC0B
104
#  define IRSND_XMEGA_OC0C              2       // OC0C
105
#  define IRSND_XMEGA_OC0D              3       // OC0D
106
#  define IRSND_XMEGA_OC1A              4       // OC1A
107
#  define IRSND_XMEGA_OC1B              5       // OC1B
108
109
#elif defined(STELLARIS_ARM_CORTEX_M4)
110
111
#  include "inc/hw_ints.h"
112
#  include "inc/hw_memmap.h"
113
#  include "inc/hw_types.h"
114
#  include "inc/hw_gpio.h"
115
#  include "driverlib/fpu.h"
116
#  include "driverlib/sysctl.h"
117
#  include "driverlib/interrupt.h"
118
#  include "driverlib/gpio.h"
119
#  include "driverlib/rom.h"
120
#  include "driverlib/systick.h"
121
#  include "driverlib/pin_map.h"
122
#  include "driverlib/timer.h"
123
#  define PROGMEM
124
#  define memcpy_P                      memcpy
125
#  define APP_SYSTICKS_PER_SEC          32
126
127
#elif defined(ARM_STM32F10X)
128
129
#  include "stm32f10x_gpio.h"
130
#  include "stm32f10x_rcc.h"
131
#  include "stm32f10x_tim.h"
132
#  include "misc.h"
133
#  define PROGMEM
134
#  define memcpy_P                      memcpy
135
136
#elif defined(SDCC_STM8)
137
138
#  include "stm8s.h"
139
#  define PROGMEM
140
#  define memcpy_P                      memcpy
141
#  define __attribute__(x)
142
#  define uint_fast8_t                  uint8_t
143
#  define uint_fast16_t                 uint16_t
144
145
#elif defined(TEENSY_ARM_CORTEX_M4)
146
#  define PROGMEM
147
#  define memcpy_P                      memcpy
148
149
#elif defined(__xtensa__)
150
#  define PROGMEM
151
#  define memcpy_P                      memcpy
152
153
#elif defined(__MBED__)
154
#  define PROGMEM
155
#  define memcpy_P                      memcpy
156
157
#else
158
#  define PROGMEM
159
#  define memcpy_P                      memcpy
160
161
#endif
162
163
#if defined(PIC_CCS) || defined(PIC_C18)
164
typedef unsigned char                   uint8_t;
165
typedef unsigned short                  uint16_t;
166
typedef unsigned char                   uint_fast8_t;
167
typedef unsigned short                  uint_fast16_t;
168
#endif
169
170
#if defined (PIC_C18)                                                               // PIC C18 or XC8 compiler
171
#  include <p18cxxx.h>                                                              // main PIC18 h file
172
#ifndef __XC8
173
#  include <timers.h>                                                               // timer lib
174
#  include <pwm.h>                                                                  // pwm lib
175
#endif
176
#  define IRSND_PIC_CCP1                1                                           // PIC C18 RC2 = PWM1 module
177
#  define IRSND_PIC_CCP2                2                                           // PIC C18 RC1 = PWM2 module
178
#endif
179
180
#ifndef TRUE
181
#  define TRUE                          1
182
#  define FALSE                         0
183
#endif
184
185
#if defined(PIC_C18)
186
#define IRMP_PACKED_STRUCT
187
#else
188
#define IRMP_PACKED_STRUCT              __attribute__ ((__packed__))
189
#endif
190
191
typedef struct IRMP_PACKED_STRUCT
192
{
193
    uint8_t                             protocol;                                   // protocol, e.g. NEC_PROTOCOL
194
    uint16_t                            address;                                    // address
195
    uint16_t                            command;                                    // command
196
    uint8_t                             flags;                                      // flags, e.g. repetition
197
} IRMP_DATA;
198
199
#endif // _IRMPSYSTEM_H_

hier noch das makefile
1
###############################################################################
2
# Makefile for the project irsnd
3
###############################################################################
4
5
## General Flags
6
PROJECT = irsnd
7
MCU = attiny45
8
TARGET = irsnd.elf
9
CC = avr-gcc
10
11
CPP = avr-g++
12
13
## Options common to compile, link and assembly rules
14
COMMON = -mmcu=$(MCU)
15
16
## Compile options common for all C compilation units.
17
CFLAGS = $(COMMON)
18
CFLAGS += -Wall -gdwarf-2 -std=gnu99                                                   -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
19
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d 
20
21
## Assembly specific flags
22
ASMFLAGS = $(COMMON)
23
ASMFLAGS += $(CFLAGS)
24
ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2
25
26
## Linker flags
27
LDFLAGS = $(COMMON)
28
LDFLAGS +=  -Wl,-Map=irsnd.map
29
30
31
## Intel Hex file production flags
32
HEX_FLASH_FLAGS = -R .eeprom -R .fuse -R .lock -R .signature
33
34
HEX_EEPROM_FLAGS = -j .eeprom
35
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
36
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings
37
38
39
## Objects that must be built in order to link
40
OBJECTS = irsnd-main-avr.o irsnd.o 
41
42
## Objects explicitly added by the user
43
LINKONLYOBJECTS = 
44
45
## Build
46
all: $(TARGET) irsnd.hex irsnd.eep irsnd.lss size
47
48
## Compile
49
irsnd-main-avr.o: ../irsnd-main-avr.c
50
  $(CC) $(INCLUDES) $(CFLAGS) -c  $<
51
52
irsnd.o: ../irsnd.c
53
  $(CC) $(INCLUDES) $(CFLAGS) -c  $<
54
55
##Link
56
$(TARGET): $(OBJECTS)
57
   $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)
58
59
%.hex: $(TARGET)
60
  avr-objcopy -O ihex $(HEX_FLASH_FLAGS)  $< $@
61
62
%.eep: $(TARGET)
63
  -avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0
64
65
%.lss: $(TARGET)
66
  avr-objdump -h -S $< > $@
67
68
size: ${TARGET}
69
  @echo
70
  @avr-size -C --mcu=${MCU} ${TARGET}
71
72
## Clean target
73
.PHONY: clean
74
clean:
75
  -rm -rf $(OBJECTS) irsnd.elf dep/* irsnd.hex irsnd.eep irsnd.lss irsnd.map
76
77
78
## Other dependencies
79
-include $(shell mkdir dep 2>NUL) $(wildcard dep/*)

von Rufus Τ. F. (rufus) Benutzerseite


Lesenswert?

Bau jetzt bitte mal folgendes in Deinen eigenen Quelltext ein, und zwar 
unmittelbar vor diesen Zeilen:
1
void
2
timer1_init (void)


1
#ifndef _IRMPSYSTEM_H_
2
#  error irmpsystem.h nicht eingebunden
3
#endif
4
5
#ifndef _IRSNDCONFIG_H_
6
#  error Konfigurationsdatei nicht eingebunden
7
#endif
8
9
#ifdef IRSND_USE_AS_LIB
10
#  error IRSND_USE_AS_LIB ist definiert
11
#endif
12
13
#if IRSND_USE_CALLBACK != 1
14
#  error IRSND_USE_CALLBACK ist nicht 1
15
#endif

Was geschieht?

von Frank M. (ukw) (Moderator) Benutzerseite


Lesenswert?

Thomas G. schrieb:
> undefined reference to `irsnd_set_callback_ptr'

Der Fehler ist in irsndconfig.h.

Ändere bitte den Bereich:
1
/*-----------------------------------------------------------------------------------------------------------------
2
 * Other target systems
3
 *------------------------------------------------------------------------------------------------------------------
4
 */
5
#elif !defined (UNIX_OR_WINDOWS)
6
#  error target system not defined.
7
#endif
8
9
/*-----------------------------------------------------------------------------------------------------------------
10
 * ESP8266 (Arduino, see IRSEND.ino)
11
 *------------------------------------------------------------------------------------------------------------------
12
 */
13
#elif defined (__xtensa__)
14
#  define IRSND_PIN                             0                       // choose an arduino pin with PWM function!

ab in:
1
/*-----------------------------------------------------------------------------------------------------------------
2
 * ESP8266 (Arduino, see IRSEND.ino)
3
 *------------------------------------------------------------------------------------------------------------------
4
 */
5
#elif defined (__xtensa__)
6
#  define IRSND_PIN                             0                       // choose an arduino pin with PWM function!
7
8
/*-----------------------------------------------------------------------------------------------------------------
9
 * Other target systems
10
 *------------------------------------------------------------------------------------------------------------------
11
 */
12
#elif !defined (UNIX_OR_WINDOWS)
13
#  error target system not defined.
14
#endif

Die beiden Blöcke werden also derart vertauscht, dass dass #endif 
unten steht. Durch das #endif an falscher Stelle wurde das 
nachfolgende IRSND_USE_CALLBACK erst gar nicht definiert.

Ich werde das fürs nächste Release korrigieren. Danke für den Hinweis.

von Thomas G. (funker_67)


Lesenswert?

Hallo Rufus,

danke für den Tip. Ich habe es eingebaut und als Fehler kam:

"IRSND_USE_CALLBACK ist nicht 1"

Hallo Frank,

so funktioniert es. Der Linker war zufrieden und ich natürlich auch.

Ich danke Euch für die große Hilfe. Ohne hätte ich es nicht geschafft 
und es letztendlich in Hardware gelöst. Meine C Kenntnisse reichen 
leider nicht soweit.

Also vielen Dank an alle die mitgeholfen haben das Problem zu lösen vor 
allen an Rufus und Frank.

Viele Grüße
Thomas

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.