123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- #include "sdk_common.h"
- #if NRF_MODULE_ENABLED(RETARGET)
- #if !defined(NRF_LOG_USES_RTT) || NRF_LOG_USES_RTT != 1
- #if !defined(HAS_SIMPLE_UART_RETARGET)
- #include <stdio.h>
- #include <stdint.h>
- #include "app_uart.h"
- #include "nrf_error.h"
- #if defined(__CC_ARM)
- struct __FILE { int handle; };
- FILE __stdout;
- FILE __stdin;
- int fgetc(FILE * p_file)
- {
- uint8_t input;
- while (app_uart_get(&input) == NRF_ERROR_NOT_FOUND)
- {
-
- }
- return input;
- }
- int fputc(int ch, FILE * p_file)
- {
- UNUSED_PARAMETER(p_file);
- UNUSED_VARIABLE(app_uart_put((uint8_t)ch));
- return ch;
- }
- #elif defined(__GNUC__) && defined(__SES_ARM)
- int __getchar(FILE * p_file)
- {
- uint8_t input;
- while (app_uart_get(&input) == NRF_ERROR_NOT_FOUND)
- {
-
- }
- return input;
- }
- #if defined(__SES_VERSION) && (__SES_VERSION >= 34000)
- int __putchar(int ch, __printf_tag_ptr tag_ptr)
- {
- UNUSED_PARAMETER(tag_ptr);
- UNUSED_VARIABLE(app_uart_put((uint8_t)ch));
- return ch;
- }
- #else
- int __putchar(int ch, FILE * p_file)
- {
- UNUSED_PARAMETER(p_file);
- UNUSED_VARIABLE(app_uart_put((uint8_t)ch));
- return ch;
- }
- #endif
- #elif defined(__GNUC__) && !defined(__SES_ARM)
- int _write(int file, const char * p_char, int len)
- {
- int i;
- UNUSED_PARAMETER(file);
- for (i = 0; i < len; i++)
- {
- UNUSED_VARIABLE(app_uart_put(*p_char++));
- }
- return len;
- }
- int _read(int file, char * p_char, int len)
- {
- UNUSED_PARAMETER(file);
- while (app_uart_get((uint8_t *)p_char) == NRF_ERROR_NOT_FOUND)
- {
-
- }
- return 1;
- }
- #elif defined(__ICCARM__)
- size_t __write(int handle, const unsigned char * buffer, size_t size)
- {
- int i;
- UNUSED_PARAMETER(handle);
- for (i = 0; i < size; i++)
- {
- UNUSED_VARIABLE(app_uart_put(*buffer++));
- }
- return size;
- }
- size_t __read(int handle, unsigned char * buffer, size_t size)
- {
- UNUSED_PARAMETER(handle);
- UNUSED_PARAMETER(size);
- while (app_uart_get((uint8_t *)buffer) == NRF_ERROR_NOT_FOUND)
- {
-
- }
- return 1;
- }
- long __lseek(int handle, long offset, int whence)
- {
- return -1;
- }
- int __close(int handle)
- {
- return 0;
- }
- int remove(const char * filename)
- {
- return 0;
- }
- #endif
- #endif
- #endif
- #endif
|