drivers/rtt: check whether Jlink is connected
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
This commit is contained in:
parent
980462bf27
commit
e1553e8407
|
@ -89,4 +89,27 @@
|
|||
|
||||
#define RTT_USE_ASM 0
|
||||
|
||||
#define SEGGER_RTT_FLAG_UP(ch) (((FAR SEGGER_RTT_BUFFER_UP *)((FAR char *) \
|
||||
&_SEGGER_RTT.aUp[ch] + SEGGER_RTT_UNCACHED_OFF))->Flags)
|
||||
#define SEGGER_RTT_RDOFF_UP(ch) (((FAR SEGGER_RTT_BUFFER_UP *)((FAR char *) \
|
||||
&_SEGGER_RTT.aUp[ch] + SEGGER_RTT_UNCACHED_OFF))->RdOff)
|
||||
|
||||
#define SEGGER_RTT_IS_CONNECTED(ch) (SEGGER_RTT_RDOFF_UP(ch) != 0)
|
||||
#define SEGGER_RTT_IS_FIFO_MODE(ch) (SEGGER_RTT_FLAG_UP(ch) == SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL)
|
||||
|
||||
/* Determine whether JLink is connected, and use FIFO mode
|
||||
* after connection to ensure that data is not lost.
|
||||
*/
|
||||
|
||||
#define SEGGER_RTT_BLOCK_IF_FIFO_FULL(ch) \
|
||||
do \
|
||||
{ \
|
||||
if (!SEGGER_RTT_IS_FIFO_MODE(ch) && SEGGER_RTT_IS_CONNECTED(ch)) \
|
||||
{ \
|
||||
SEGGER_RTT_SetFlagsUpBuffer(ch, SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL); \
|
||||
SEGGER_RTT_SetFlagsDownBuffer(ch, SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#endif /* __DRIVERS_SEGGER_CONFIG_SEGGER_RTT_CONF_H */
|
||||
|
|
|
@ -43,6 +43,8 @@ static void rttstream_putc(FAR struct lib_outstream_s *this, int ch)
|
|||
{
|
||||
FAR struct lib_rttoutstream_s *stream =
|
||||
(FAR struct lib_rttoutstream_s *)this;
|
||||
|
||||
SEGGER_RTT_BLOCK_IF_FIFO_FULL(0);
|
||||
stream->public.nput += SEGGER_RTT_PutChar(stream->channel, ch);
|
||||
}
|
||||
|
||||
|
@ -55,7 +57,10 @@ static int rttstream_puts(FAR struct lib_outstream_s *this,
|
|||
{
|
||||
FAR struct lib_rttoutstream_s *stream =
|
||||
(FAR struct lib_rttoutstream_s *)this;
|
||||
int ret = SEGGER_RTT_Write(stream->channel, buf, len);
|
||||
int ret;
|
||||
|
||||
SEGGER_RTT_BLOCK_IF_FIFO_FULL(0);
|
||||
ret = SEGGER_RTT_Write(stream->channel, buf, len);
|
||||
stream->public.nput += ret;
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
int syslog_rtt_putc(FAR struct syslog_channel_s *channel, int ch)
|
||||
{
|
||||
SEGGER_RTT_BLOCK_IF_FIFO_FULL(0);
|
||||
SEGGER_RTT_PutChar(0, ch);
|
||||
return ch;
|
||||
}
|
||||
|
@ -39,5 +40,6 @@ int syslog_rtt_putc(FAR struct syslog_channel_s *channel, int ch)
|
|||
ssize_t syslog_rtt_write(FAR struct syslog_channel_s *channel,
|
||||
FAR const char *buffer, size_t buflen)
|
||||
{
|
||||
SEGGER_RTT_BLOCK_IF_FIFO_FULL(0);
|
||||
return SEGGER_RTT_Write(0, buffer, buflen);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue