Guest User

Untitled

a guest
Jul 12th, 2013
819
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Copyright (C) 2011 J. Coliz <maniacbug@ymail.com>
  3.  
  4. This program is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU General Public License
  6. version 2 as published by the Free Software Foundation.
  7. */
  8.  
  9. /**
  10. * @file printf.h
  11. *
  12. * Setup necessary to direct stdout to the Arduino Serial library, which
  13. * enables 'printf'
  14. */
  15.  
  16. #ifndef __PRINTF_H__
  17. #define __PRINTF_H__
  18.  
  19. #ifdef ARDUINO
  20.  
  21. int serial_putc( char c, FILE * )
  22. {
  23. Serial.write( c );
  24.  
  25. return c;
  26. }
  27.  
  28. void printf_begin(void)
  29. {
  30. fdevopen( &serial_putc, 0 );
  31. }
  32.  
  33. #else
  34. #error This example is only for use on Arduino.
  35. #endif // ARDUINO
  36.  
  37. #endif // __PRINTF_H__
RAW Paste Data