1
0

xprintf.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*------------------------------------------------------------------------*/
  2. /* Universal string handler for user console interface (C)ChaN, 2021 */
  3. /*------------------------------------------------------------------------*/
  4. #ifndef XPRINTF_DEF
  5. #define XPRINTF_DEF
  6. #include <string.h>
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. #define XF_USE_OUTPUT 1 /* 1: Enable output functions */
  11. #define XF_CRLF 0 /* 1: Convert \n ==> \r\n in the output char */
  12. #define XF_USE_DUMP 0 /* 1: Enable put_dump function */
  13. #define XF_USE_LLI 0 /* 1: Enable long long integer in size prefix ll */
  14. #define XF_USE_FP 1 /* 1: Enable support for floating point in type e and f */
  15. #define XF_DPC '.' /* Decimal separator for floating point */
  16. #define XF_USE_INPUT 0 /* 1: Enable input functions */
  17. #define XF_INPUT_ECHO 0 /* 1: Echo back input chars in xgets function */
  18. #if defined(__GNUC__) && __GNUC__ >= 10
  19. #pragma GCC diagnostic ignored "-Wcast-function-type"
  20. #endif
  21. #if XF_USE_OUTPUT
  22. #define xdev_out(func) xfunc_output = (void(*)(int))(func)
  23. extern void (*xfunc_output)(int);
  24. void xputc (int chr);
  25. void xfputc (void (*func)(int), int chr);
  26. void xputs (const char* str);
  27. void xfputs (void (*func)(int), const char* str);
  28. void xprintf (const char* fmt, ...);
  29. void xsprintf (char* buff, const char* fmt, ...);
  30. void xfprintf (void (*func)(int), const char* fmt, ...);
  31. void put_dump (const void* buff, unsigned long addr, int len, size_t width);
  32. void xputs_P (const __flash char* str);
  33. void xfputs_P (void (*func)(int), const __flash char* str);
  34. #endif
  35. #if XF_USE_INPUT
  36. #define xdev_in(func) xfunc_input = (int(*)(void))(func)
  37. extern int (*xfunc_input)(void);
  38. int xgets (char* buff, int len);
  39. int xatoi (char** str, long* res);
  40. #endif
  41. #ifdef XF_USE_FP
  42. int xatof (const char **str, double *res);
  43. #endif
  44. #ifdef __cplusplus
  45. }
  46. #endif
  47. #endif