ARM: get sersendf.c/.h in.
Needed a bit a tweak to adjust va_arg() to 32 bit. Tests ran fine, at the end it turned out mendel.c had an obsolete #include.
This commit is contained in:
parent
5dec638919
commit
43b2ac6e0b
|
|
@ -97,7 +97,7 @@ TARGET = $(PROGRAM).hex
|
|||
#SOURCES = $(wildcard *.c)
|
||||
# Until the generic ARM port is completed, we'd have to wrap all sources
|
||||
# in #ifdef __AVR__. To avoid this, build only a selection for now:
|
||||
SOURCES = mendel.c cpu.c serial.c sermsg.c
|
||||
SOURCES = mendel.c cpu.c serial.c sermsg.c sersendf.c
|
||||
SOURCES += mbed-pinmap.c
|
||||
ifeq ($(MCU), lpc1114)
|
||||
SOURCES += mbed-system_LPC11xx.c
|
||||
|
|
|
|||
1
mendel.c
1
mendel.c
|
|
@ -40,7 +40,6 @@
|
|||
#include "temp.h"
|
||||
#include "watchdog.h"
|
||||
#include "debug.h"
|
||||
#include "sersendf.h"
|
||||
#include "heater.h"
|
||||
#include "analog.h"
|
||||
#include "pinio.h"
|
||||
|
|
|
|||
13
sersendf.c
13
sersendf.c
|
|
@ -94,10 +94,15 @@
|
|||
\code sersendf_P(PSTR("X:%ld Y:%ld temp:%u.%d flags:%sx Q%su/%su%c\n"), target.X, target.Y, current_temp >> 2, (current_temp & 3) * 25, dda.allflags, mb_head, mb_tail, (queue_full()?'F':(queue_empty()?'E':' '))) \endcode
|
||||
*/
|
||||
|
||||
#ifdef SIMULATOR
|
||||
#define GET_ARG(T) (va_arg(args, int))
|
||||
#else
|
||||
/**
|
||||
va_arg() takes "fully promoted types" only, see example in Linux' va_arg
|
||||
man page. This covers platforms >= 16 bits and arguments up to 32 bits.
|
||||
64 bit arguments on a 32 bit platform will produce a severe warning.
|
||||
*/
|
||||
#if __SIZEOF_INT__ == 2
|
||||
#define GET_ARG(T) (va_arg(args, T))
|
||||
#elif __SIZEOF_INT__ >= 4
|
||||
#define GET_ARG(T) ((T)va_arg(args, int))
|
||||
#endif
|
||||
|
||||
void sersendf_P(PGM_P format_P, ...) {
|
||||
|
|
@ -130,7 +135,7 @@ void sersendf_P(PGM_P format_P, ...) {
|
|||
j = 0;
|
||||
break;
|
||||
case 'c':
|
||||
serial_writechar(GET_ARG(uint16_t));
|
||||
serial_writechar((uint8_t)GET_ARG(uint16_t));
|
||||
j = 0;
|
||||
break;
|
||||
case 'x':
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
#include "arduino.h"
|
||||
|
||||
|
||||
void sersendf(char *format, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
void sersendf_P(PGM_P format_P, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
// No __attribute__ ((format (printf, 1, 2)) here because %q isn't supported.
|
||||
void sersendf(char *format, ...);
|
||||
void sersendf_P(PGM_P format_P, ...);
|
||||
|
||||
#endif /* _SERSENDF_H */
|
||||
|
|
|
|||
Loading…
Reference in New Issue