xprintf.h 1.6 KB

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