Andrew Reed / Mbed OS CITY1082-i2c_master_wifi_mqtt
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SEGGER.h Source File

SEGGER.h

00001 /*********************************************************************
00002 *                SEGGER Microcontroller GmbH                         *
00003 *        Solutions for real time microcontroller applications        *
00004 **********************************************************************
00005 *                                                                    *
00006 *        (c) 1996 - 2018  SEGGER Microcontroller GmbH                *
00007 *                                                                    *
00008 *        Internet: www.segger.com    Support:  support@segger.com    *
00009 *                                                                    *
00010 **********************************************************************
00011 
00012 ** emWin V5.48 - Graphical user interface for embedded applications **
00013 All  Intellectual Property rights  in the Software belongs to  SEGGER.
00014 emWin is protected by  international copyright laws.  Knowledge of the
00015 source code may not be used to write a similar product.  This file may
00016 only be used in accordance with the following terms:
00017 
00018 The software  has been licensed to  Cypress Semiconductor Corporation,
00019 whose registered  office is situated  at 198 Champion Ct. San Jose, CA 
00020 95134 USA  solely for the  purposes of creating  libraries for Cypress
00021 PSoC3 and  PSoC5 processor-based devices,  sublicensed and distributed
00022 under  the  terms  and  conditions  of  the  Cypress  End User License
00023 Agreement.
00024 Full source code is available at: www.segger.com
00025 
00026 We appreciate your understanding and fairness.
00027 ----------------------------------------------------------------------
00028 Licensing information
00029 Licensor:                 SEGGER Microcontroller Systems LLC
00030 Licensed to:              Cypress Semiconductor Corp, 198 Champion Ct., San Jose, CA 95134, USA
00031 Licensed SEGGER software: emWin
00032 License number:           GUI-00319
00033 License model:            Services and License Agreement, signed June 10th, 2009
00034 Licensed platform:        Any Cypress platform (Initial targets are: PSoC3, PSoC5)
00035 ----------------------------------------------------------------------
00036 Support and Update Agreement (SUA)
00037 SUA period:               2009-06-12 - 2022-07-27
00038 Contact to extend SUA:    sales@segger.com
00039 ----------------------------------------------------------------------
00040 File    : SEGGER.h
00041 Purpose : Global types etc & general purpose utility functions
00042 Revision: $Rev: 6176 $
00043 ---------------------------END-OF-HEADER------------------------------
00044 */
00045 
00046 #ifndef SEGGER_H            // Guard against multiple inclusion
00047 #define SEGGER_H
00048 
00049 #include <stdarg.h>
00050 #include "Global.h"         // Type definitions: U8, U16, U32, I8, I16, I32
00051 
00052 #if defined(__cplusplus)
00053 extern "C" {     /* Make sure we have C-declarations in C++ programs */
00054 #endif
00055 
00056 /*********************************************************************
00057 *
00058 *       Keywords/specifiers
00059 *
00060 **********************************************************************
00061 */
00062 
00063 #ifndef INLINE
00064   #ifdef _WIN32
00065     //
00066     // Microsoft VC6 and newer.
00067     // Force inlining without cost checking.
00068     //
00069     #define INLINE  __forceinline
00070   #else
00071     #if (defined(__GNUC__))
00072       //
00073       // Force inlining with GCC
00074       //
00075       #define INLINE inline __attribute__((always_inline))
00076     #elif (defined(__ICCARM__) || defined(__CC_ARM) || defined(__RX) || defined(__ICCRX__))
00077       //
00078       // Other known compilers.
00079       //
00080       #define INLINE  inline
00081     #else
00082       //
00083       // Unknown compilers.
00084       //
00085       #define INLINE
00086     #endif
00087   #endif
00088 #endif
00089 
00090 /*********************************************************************
00091 *
00092 *       Function-like macros
00093 *
00094 **********************************************************************
00095 */
00096 
00097 #define SEGGER_COUNTOF(a)          (sizeof((a))/sizeof((a)[0]))
00098 #define SEGGER_MIN(a,b)            (((a) < (b)) ? (a) : (b))
00099 #define SEGGER_MAX(a,b)            (((a) > (b)) ? (a) : (b))
00100 
00101 #ifndef   SEGGER_USE_PARA                   // Some compiler complain about unused parameters.
00102   #define SEGGER_USE_PARA(Para) (void)Para  // This works for most compilers.
00103 #endif
00104 
00105 /*********************************************************************
00106 *
00107 *       Defines
00108 *
00109 **********************************************************************
00110 */
00111 
00112 #define SEGGER_PRINTF_FLAG_ADJLEFT    (1 << 0)
00113 #define SEGGER_PRINTF_FLAG_SIGNFORCE  (1 << 1)
00114 #define SEGGER_PRINTF_FLAG_SIGNSPACE  (1 << 2)
00115 #define SEGGER_PRINTF_FLAG_PRECEED    (1 << 3)
00116 #define SEGGER_PRINTF_FLAG_ZEROPAD    (1 << 4)
00117 #define SEGGER_PRINTF_FLAG_NEGATIVE   (1 << 5)
00118 
00119 /*********************************************************************
00120 *
00121 *       Types
00122 *
00123 **********************************************************************
00124 */
00125 
00126 typedef struct {
00127   char* pBuffer;
00128   int   BufferSize;
00129   int   Cnt;
00130 } SEGGER_BUFFER_DESC;
00131 
00132 typedef struct {
00133   int  CacheLineSize;                                 // 0: No Cache. Most Systems such as ARM9 use a 32 bytes cache line size.
00134   void (*pfDMB)       (void);                         // Optional DMB function for Data Memory Barrier to make sure all memory operations are completed.
00135   void (*pfClean)     (void *p, unsigned NumBytes);   // Optional clean function for cached memory.
00136   void (*pfInvalidate)(void *p, unsigned NumBytes);   // Optional invalidate function for cached memory.
00137 } SEGGER_CACHE_CONFIG;
00138 
00139 typedef struct SEGGER_SNPRINTF_CONTEXT_struct SEGGER_SNPRINTF_CONTEXT;
00140 
00141 struct SEGGER_SNPRINTF_CONTEXT_struct {
00142   void*               pContext;                       // Application specific context.
00143   SEGGER_BUFFER_DESC* pBufferDesc;                    // Buffer descriptor to use for output.
00144   void (*pfFlush)(SEGGER_SNPRINTF_CONTEXT *);         // Callback executed once the buffer is full. Callback decides if the buffer gets cleared to store more or not.
00145 };
00146 
00147 typedef struct {
00148   void (*pfStoreChar)       (SEGGER_BUFFER_DESC* pBufferDesc, SEGGER_SNPRINTF_CONTEXT* pContext, char c);
00149   int  (*pfPrintUnsigned)   (SEGGER_BUFFER_DESC* pBufferDesc, SEGGER_SNPRINTF_CONTEXT* pContext, U32 v, unsigned Base, char Flags, int Width, int Precision);
00150   int  (*pfPrintInt)        (SEGGER_BUFFER_DESC* pBufferDesc, SEGGER_SNPRINTF_CONTEXT* pContext, I32 v, unsigned Base, char Flags, int Width, int Precision);
00151 } SEGGER_PRINTF_API;
00152 
00153 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);
00154 
00155 typedef struct SEGGER_PRINTF_FORMATTER {
00156   struct SEGGER_PRINTF_FORMATTER* pNext;              // Pointer to next formatter.
00157   SEGGER_pFormatter               pfFormatter;        // Formatter function.
00158   char                            Specifier;          // Format specifier.
00159 } SEGGER_PRINTF_FORMATTER;
00160 
00161 /*********************************************************************
00162 *
00163 *       Utility functions
00164 *
00165 **********************************************************************
00166 */
00167 
00168 void SEGGER_ARM_memcpy(void* pDest, const void* pSrc, int NumBytes);
00169 void SEGGER_memcpy    (void* pDest, const void* pSrc, int NumBytes);
00170 void SEGGER_memxor    (void* pDest, const void* pSrc, unsigned NumBytes);
00171 
00172 void SEGGER_StoreChar    (SEGGER_BUFFER_DESC* pBufferDesc, char c);
00173 void SEGGER_PrintUnsigned(SEGGER_BUFFER_DESC* pBufferDesc, U32 v, unsigned Base, int Precision);
00174 void SEGGER_PrintInt     (SEGGER_BUFFER_DESC* pBufferDesc, I32 v, unsigned Base, int Precision);
00175 //int  SEGGER_snprintf     (char* pBuffer, int BufferSize, const char* sFormat, ...);
00176 int  SEGGER_vsnprintf    (char* pBuffer, int BufferSize, const char* sFormat, va_list ParamList);
00177 int  SEGGER_vsnprintfEx  (SEGGER_SNPRINTF_CONTEXT* pContext, const char* sFormat, va_list ParamList);
00178 
00179 int  SEGGER_PRINTF_AddFormatter      (SEGGER_PRINTF_FORMATTER* pFormatter, SEGGER_pFormatter pfFormatter, char c);
00180 void SEGGER_PRINTF_AddDoubleFormatter(void);
00181 void SEGGER_PRINTF_AddIPFormatter    (void);
00182 void SEGGER_PRINTF_AddHTMLFormatter  (void);
00183 
00184 #if defined(__cplusplus)
00185 }                /* Make sure we have C-declarations in C++ programs */
00186 #endif
00187 
00188 #endif                      // Avoid multiple inclusion
00189 
00190 /*************************** End of file ****************************/