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.

33 lines
731 B

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