stubs.c 750 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include "nuclei_sdk_hal.h"
  2. // #define UART_AUTO_ECHO
  3. // TODO uncomment it if you want to print via IAR Breakpoint(C-SPY emulated IO)
  4. // You need to set Library Configuration -> Stdout/Stderr -> Via IAR Breakpoint
  5. // #define DEBUG_IAR_BREAKPOINT
  6. // For more iar dlib stub function
  7. // TODO Implement your own uart_write and uart_read for your debug uart device
  8. #ifndef DEBUG_IAR_BREAKPOINT
  9. // By default print via uart io
  10. int putchar(int ch)
  11. {
  12. if (ch == '\n') {
  13. uart_write(SOC_DEBUG_UART, '\r');
  14. }
  15. uart_write(SOC_DEBUG_UART, ch);
  16. return ch;
  17. }
  18. int getchar(void)
  19. {
  20. int dat;
  21. dat = (int)uart_read(SOC_DEBUG_UART);
  22. #ifdef UART_AUTO_ECHO
  23. uart_write(SOC_DEBUG_UART, (uint8_t)dat);
  24. #endif
  25. return dat;
  26. }
  27. #endif