2011-07-07 02:59:06 +00:00
|
|
|
/*
|
2011-12-18 18:56:12 +00:00
|
|
|
Copyright (C) 2011 J. Coliz <maniacbug@ymail.com>
|
2011-07-07 02:59:06 +00:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
version 2 as published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file printf.h
|
|
|
|
*
|
|
|
|
* Setup necessary to direct stdout to the Arduino Serial library, which
|
|
|
|
* enables 'printf'
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __PRINTF_H__
|
|
|
|
#define __PRINTF_H__
|
|
|
|
|
2011-12-18 18:56:12 +00:00
|
|
|
#ifdef ARDUINO
|
|
|
|
|
2011-07-07 02:59:06 +00:00
|
|
|
int serial_putc( char c, FILE * )
|
|
|
|
{
|
|
|
|
Serial.write( c );
|
|
|
|
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
void printf_begin(void)
|
|
|
|
{
|
|
|
|
fdevopen( &serial_putc, 0 );
|
|
|
|
}
|
|
|
|
|
2011-12-18 18:56:12 +00:00
|
|
|
#else
|
|
|
|
#error This example is only for use on Arduino.
|
|
|
|
#endif // ARDUINO
|
|
|
|
|
2011-07-07 02:59:06 +00:00
|
|
|
#endif // __PRINTF_H__
|