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.

29 lines
694 B

2 years ago
2 years ago
2 years ago
  1. #include "logger.hpp"
  2. extern "C" {
  3. static zchip_uart_t* m_huart;
  4. bool g_enable_log = true;
  5. /*********************************************************************
  6. * @fn _write
  7. *
  8. * @brief Support Printf Function
  9. *
  10. * @param *buf - UART send Data.
  11. * size - Data length
  12. *
  13. * @return size: Data length
  14. */
  15. __attribute__((used)) int _write(int fd, char* buf, int size) {
  16. int i;
  17. for (i = 0; i < size; i++) {
  18. uint8_t c = *buf++;
  19. if (m_huart != NULL) HAL_UART_Transmit(m_huart, &c, 1, 100);
  20. }
  21. return size;
  22. }
  23. void zchip_loggger_init(zchip_uart_t* huart) { m_huart = huart; }
  24. void zchip_loggger_enable(bool enable) { g_enable_log = enable; }
  25. }