embox
1/**
2* @file
3* @brief SEGGER RTT
4*
5* @author Alexander Kalmuk
6* @date 06.05.2020
7*/
8
9#include <drivers/diag.h>10#include "SEGGER_RTT.h"11
12static int rtt_diag_init(const struct diag *diag) {13SEGGER_RTT_Init();14return 0;15}
16
17static void rtt_diag_putc(const struct diag *diag, char ch) {18/* RTT lost charachters, so we should check whether there is a room19* for a char, but on the other hand, we can block forever here if
20* we are running without JLINK attached (nobody reads buffer and overflow occurs).
21* So just put char without checking for possible overflows. */
22#if 023int ret;24
25do {26ret = SEGGER_RTT_PutChar(0, ch);27} while (!ret);28#else29SEGGER_RTT_PutChar(0, ch);30#endif31}
32
33static char rtt_diag_getc(const struct diag *diag) {34return 0;35}
36
37static int rtt_diag_kbhit(const struct diag *diag) {38return 0;39}
40
41DIAG_OPS_DEF(42.init = rtt_diag_init,43.putc = rtt_diag_putc,44.getc = rtt_diag_getc,45.kbhit = rtt_diag_kbhit,46);47