55 #ifndef SEGGER_H // Guard against multiple inclusion
58 #if (dg_configSYSTEMVIEW == 1)
63 #if defined(__cplusplus)
75 #if (defined(__ICCARM__) || defined(__RX) || defined(__ICCRX__))
81 #if (defined(_WIN32) && !defined(__clang__))
86 #define INLINE __forceinline
87 #elif defined(__GNUC__) || defined(__clang__)
91 #define INLINE inline __attribute__((always_inline))
92 #elif (defined(__CC_ARM))
96 #define INLINE __inline
113 #define SEGGER_COUNTOF(a) (sizeof((a))/sizeof((a)[0]))
114 #define SEGGER_MIN(a,b) (((a) < (b)) ? (a) : (b))
115 #define SEGGER_MAX(a,b) (((a) > (b)) ? (a) : (b))
117 #ifndef SEGGER_USE_PARA // Some compiler complain about unused parameters.
118 #define SEGGER_USE_PARA(Para) (void)Para // This works for most compilers.
121 #define SEGGER_ADDR2PTR(Type, Addr) (((Type*)((PTR_ADDR)(Addr)))) // Allow cast from address to pointer.
122 #define SEGGER_PTR2ADDR(p) (((PTR_ADDR)(p))) // Allow cast from pointer to address.
123 #define SEGGER_PTR2PTR(Type, p) (((Type*)(p))) // Allow cast from one pointer type to another (ignore different size).
124 #define SEGGER_PTR_DISTANCE(p0, p1) (SEGGER_PTR2ADDR(p0) - SEGGER_PTR2ADDR(p1))
133 #define SEGGER_PRINTF_FLAG_ADJLEFT (1 << 0)
134 #define SEGGER_PRINTF_FLAG_SIGNFORCE (1 << 1)
135 #define SEGGER_PRINTF_FLAG_SIGNSPACE (1 << 2)
136 #define SEGGER_PRINTF_FLAG_PRECEED (1 << 3)
137 #define SEGGER_PRINTF_FLAG_ZEROPAD (1 << 4)
138 #define SEGGER_PRINTF_FLAG_NEGATIVE (1 << 5)
151 } SEGGER_BUFFER_DESC;
154 unsigned int CacheLineSize;
155 void (*pfDMB) (void);
156 void (*pfClean) (
void *p,
unsigned long NumBytes);
157 void (*pfInvalidate)(
void *p,
unsigned long NumBytes);
158 } SEGGER_CACHE_CONFIG;
160 typedef struct SEGGER_SNPRINTF_CONTEXT_struct SEGGER_SNPRINTF_CONTEXT;
162 struct SEGGER_SNPRINTF_CONTEXT_struct {
164 SEGGER_BUFFER_DESC* pBufferDesc;
165 void (*pfFlush)(SEGGER_SNPRINTF_CONTEXT* pContext);
169 void (*pfStoreChar) (SEGGER_BUFFER_DESC* pBufferDesc, SEGGER_SNPRINTF_CONTEXT* pContext,
char c);
170 int (*pfPrintUnsigned) (SEGGER_BUFFER_DESC* pBufferDesc, SEGGER_SNPRINTF_CONTEXT* pContext, U32 v,
unsigned Base,
char Flags,
int Width,
int Precision);
171 int (*pfPrintInt) (SEGGER_BUFFER_DESC* pBufferDesc, SEGGER_SNPRINTF_CONTEXT* pContext, I32 v,
unsigned Base,
char Flags,
int Width,
int Precision);
174 typedef void (*SEGGER_pFormatter)(SEGGER_BUFFER_DESC* pBufferDesc, SEGGER_SNPRINTF_CONTEXT* pContext,
const SEGGER_PRINTF_API* pApi, va_list* pParamList,
char Lead,
int Width,
int Precision);
176 typedef struct SEGGER_PRINTF_FORMATTER {
177 struct SEGGER_PRINTF_FORMATTER* pNext;
178 SEGGER_pFormatter pfFormatter;
180 } SEGGER_PRINTF_FORMATTER;
183 U32 (*pfGetHPTimestamp)(void);
184 int (*pfGetUID) (U8 abUID[16]);
197 void SEGGER_ARM_memcpy(
void* pDest,
const void* pSrc,
int NumBytes);
198 void SEGGER_memcpy (
void* pDest,
const void* pSrc,
unsigned NumBytes);
199 void SEGGER_memxor (
void* pDest,
const void* pSrc,
unsigned NumBytes);
204 int SEGGER_atoi (
const char* s);
205 int SEGGER_isalnum (
int c);
206 int SEGGER_isalpha (
int c);
207 unsigned SEGGER_strlen (
const char* s);
208 int SEGGER_tolower (
int c);
209 int SEGGER_strcasecmp (
const char* sText1,
const char* sText2);
210 int SEGGER_strncasecmp(
const char *sText1,
const char *sText2,
unsigned Count);
215 void SEGGER_StoreChar (SEGGER_BUFFER_DESC* pBufferDesc,
char c);
216 void SEGGER_PrintUnsigned(SEGGER_BUFFER_DESC* pBufferDesc, U32 v,
unsigned Base,
int Precision);
217 void SEGGER_PrintInt (SEGGER_BUFFER_DESC* pBufferDesc, I32 v,
unsigned Base,
int Precision);
218 int SEGGER_snprintf (
char* pBuffer,
int BufferSize,
const char* sFormat, ...);
219 int SEGGER_vsnprintf (
char* pBuffer,
int BufferSize,
const char* sFormat, va_list ParamList);
220 int SEGGER_vsnprintfEx (SEGGER_SNPRINTF_CONTEXT* pContext,
const char* sFormat, va_list ParamList);
222 int SEGGER_PRINTF_AddFormatter (SEGGER_PRINTF_FORMATTER* pFormatter, SEGGER_pFormatter pfFormatter,
char c);
223 void SEGGER_PRINTF_AddDoubleFormatter (
void);
224 void SEGGER_PRINTF_AddIPFormatter (
void);
225 void SEGGER_PRINTF_AddBLUEFormatter (
void);
226 void SEGGER_PRINTF_AddCONNECTFormatter(
void);
227 void SEGGER_PRINTF_AddSSLFormatter (
void);
228 void SEGGER_PRINTF_AddSSHFormatter (
void);
229 void SEGGER_PRINTF_AddHTMLFormatter (
void);
234 int SEGGER_BSP_GetUID (U8 abUID[16]);
235 int SEGGER_BSP_GetUID32(U32* pUID);
236 void SEGGER_BSP_SetAPI (
const SEGGER_BSP_API* pAPI);
237 void SEGGER_BSP_SeedUID (
void);
242 void SEGGER_VERSION_GetString(
char acText[8],
unsigned Version);
244 #if defined(__cplusplus)
250 #endif // Avoid multiple inclusion