Commit 64322026 authored by Pavel Kral's avatar Pavel Kral Committed by Carles Cufí
Browse files

ext: debug: segger: Terminal sharing using SEGGER_RTT_LOCK/UNLOCK macros



This commit allows to share default RTT (terminal) buffer with various
Zephyr subsystems.

Signed-off-by: default avatarPavel Kral <pavel.kral@omsquare.com>
parent 4ab9ef38
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line

zephyr_include_directories_ifdef(CONFIG_HAS_SEGGER_RTT .)
zephyr_sources_ifdef(CONFIG_HAS_SEGGER_RTT rtt/SEGGER_RTT.c)
zephyr_sources_ifdef(CONFIG_HAS_SEGGER_RTT
	rtt/SEGGER_RTT.c
	rtt/SEGGER_RTT_zephyr.c
	)
zephyr_sources_ifdef(CONFIG_SEGGER_SYSTEMVIEW systemview/SEGGER_SYSVIEW.c)
+6 −1
Original line number Diff line number Diff line
@@ -138,7 +138,12 @@ Revision: $Rev: 9599 $
*       Rowley CrossStudio and GCC
*/
#if (defined __SES_ARM) || (defined __CROSSWORKS_ARM) || (defined __GNUC__)
  #ifdef __ARM_ARCH_6M__
  #ifdef __ZEPHYR__
    #include <kernel.h>
    extern struct k_mutex rtt_term_mutex;
    #define SEGGER_RTT_LOCK() k_mutex_lock(&rtt_term_mutex, K_FOREVER);
    #define SEGGER_RTT_UNLOCK() k_mutex_unlock(&rtt_term_mutex);
  #elif __ARM_ARCH_6M__
    #define SEGGER_RTT_LOCK()   {                                                                   \
                                    unsigned int LockState;                                         \
                                  __asm volatile ("mrs   %0, primask  \n\t"                         \
+20 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2018 omSquare s.r.o.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include <kernel.h>

/*
 * Common mutex for locking access to terminal buffer.
 * Note that SEGGER uses same lock macros for both SEGGER_RTT_Write and
 * SEGGER_RTT_Read functions. Because of this we are not able generally
 * separate up and down access using two mutexes until SEGGER library fix
 * this.
 *
 * If sharing access cause performance problems, consider using another
 * non terminal buffers.
 */

K_MUTEX_DEFINE(rtt_term_mutex);