Имеется код
CODE
#include "defines.h"
#include <avr/io.h>
#include <avr/iom16.h>
#include <util/delay.h>
#include <ctype.h>
#include <stdint.h>
#include <stdio.h>
#include <avr/pgmspace.h>
#include "lcd.h"
FILE lcd_str = FDEV_SETUP_STREAM(lcd_putChar, NULL, _FDEV_SETUP_WRITE);
//FILE thempr_str = FDEV_SETUP_STREAM(NULL, read_thempr, _FDEV_SETUP_READ);
char szString[] = {"Thermometr 0.0.1 \n"};
void init(void) __attribute__((naked)) __attribute__((section(".init8")));
void init(void)
{
CONF_DATA_PORT = DATA_PINS;
CONF_MANAGER_PORT = _BV(E_PIN) | _BV(RS_PIN) | _BV(RW_PIN);
MANAGER_PORT &= ~_BV(RW_PIN);
initDisplay();
}
int main(void)
{
uint8_t i;
stdout = &lcd_str;
// stdin = &thempr_str;
// fprintf(stdout, "Thermometr 0.0.1");
printf_P(PSTR("Thermometr 0.0.1"));
// Insert code
while(1);
return 0;
}
Если для вывод использовать функцию
Код
fprintf(stdout, "Thermometr 0.0.1");
то всё собирается без проблем.
Если же
Код
printf_P(PSTR("Thermometr 0.0.1"));
то выдает ошибку
CODE
-------------- Clean: Release in thermometr ---------------
Cleaned "thermometr - Release"
-------------- Build: Release in thermometr ---------------
Compiling: lcd.c
Compiling: main.c
main.c: In function ‘main’:
main.c:30:10: warning: unused variable ‘i’
Linking native: bin/Release/thermometr
/usr/lib/avr/lib/libc.a(vfprintf_std.o): In function `vfprintf':
/tmp/buildd/avr-libc-1.7.1/avr/lib/avr2/../../../libc/stdio/vfprintf.c:340: undefined reference to `__mulqi3'
/tmp/buildd/avr-libc-1.7.1/avr/lib/avr2/../../../libc/stdio/vfprintf.c:343: undefined reference to `__mulqi3'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
2 errors, 1 warnings
Вопрос - я чего не понимаю или avr-libc кривоват? Вывод был взят из примера stdiodemo. Компилятор avr-gcc (WinAVR).
Сообщение отредактировал _guardianangel - Sep 4 2011, 10:12