Ich möchte, dass mein Programm einen Kompilierzeitfehler wie "LCD_PORT nicht definiert" flasht, wenn es nicht im Programm selbst definiert ist. Dafür habe ich die Header-Datei wie folgt modifiziert
.
.
.
#if LCD_IO_MODE
#ifndef LCD_PORT
#error LCD_PORT not defined //(e.g. #define LCD_PORT PORTA/B/C/D)
#endif
#define LCD_DATA0_PORT LCD_PORT /**< port for 4bit data bit 0 */
#define LCD_DATA1_PORT LCD_PORT /**< port for 4bit data bit 1 */
.
.
.
...
Aber auch nach der Definition des LCD_PORT (wie im folgenden Programm) blinkt der Fehler.
#include <avr/io.h>
#include <lcd.h>
#define LCD_PORT PORTA
int main(void)
{
lcd_init(LCD_DISP_ON_CURSOR);
lcd_home();
lcd_gotoxy(0,4);
lcd_puts("Hello world!!");
}
Das Problem besteht wahrscheinlich darin, dass der Präprozessor sequentiell arbeitet, also sollten Sie die Definition vor dem Include ausführen. Versuche Folgendes:
#include <avr/io.h>
#define LCD_PORT PORTA
#include <lcd.h>
Jippie