printft.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. File: printf.h
  3. Copyright (C) 2004,2008,2010 Kustaa Nyholm
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with this library; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  15. This library is realy just two files: 'printf.h' and 'printf.c'.
  16. They provide a simple and small (+100 loc) printf functionality to
  17. be used in embedded systems.
  18. I've found them so usefull in debugging that I do not bother with a
  19. debugger at all.
  20. They are distributed in source form, so to use them, just compile them
  21. into your project.
  22. The formats supported by this implementation are: 'd' 'u' 'c' 's' 'x' 'X'.
  23. Zero padding and field width (limited to 255) are also supported.
  24. The memory foot print of course depends on the target cpu, compiler and
  25. compiler options, but a rough guestimate (based on a HC08 target) is about
  26. 600 - 1100 bytes for code and some twenty bytes of static data. Note
  27. that this printf is not re-entrant.
  28. Note that the code expects that int size is 16 bits, and that char is
  29. 8 bits.
  30. To use the printf you need to supply your own character output function,
  31. something like :
  32. void putchar (char c)
  33. {
  34. while (!SERIAL_PORT_EMPTY) ;
  35. SERIAL_PORT_TX_REGISTER = c;
  36. }
  37. For further details see the source code.
  38. regs Kusti, 7.3.2010
  39. */
  40. #ifndef __PRINTFT__
  41. #define __PRINTFT__
  42. #include <stdarg.h>
  43. void printft(char *fmt, ...);
  44. #endif