基质喷涂
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
978 B

3 weeks ago
  1. #include "zlog.h"
  2. #include "project_configs.h"
  3. #include "zbase.h"
  4. bool g_xs_enable_log = true;
  5. UART_HandleTypeDef* debuguart;
  6. /*********************************************************************
  7. * @fn _write
  8. *
  9. * @brief Support Printf Function
  10. *
  11. * @param *buf - UART send Data.
  12. * size - Data length
  13. *
  14. * @return size: Data length
  15. */
  16. // __attribute__((used)) int _write(int fd, char* buf, int size) {
  17. // int i;
  18. //
  19. // for (i = 0; i < size; i++) {
  20. // uint8_t c = *buf++;
  21. // if (debuguart) HAL_UART_Transmit(debuguart, &c, 1, 100);
  22. // }
  23. //
  24. // return size;
  25. // }
  26. void zlog_init(UART_HandleTypeDef* uart) { debuguart = uart; }
  27. void zlog_enable(bool enable) { g_xs_enable_log = enable; }
  28. void zlog(const char* fmt, ...) {
  29. if (g_xs_enable_log) {
  30. va_list args;
  31. va_start(args, fmt);
  32. vprintf(fmt, args);
  33. va_end(args);
  34. }
  35. }
  36. void zlog_raw(const char* info) {
  37. if (g_xs_enable_log) {
  38. printf(info);
  39. }
  40. }