esp_common.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Gunar Schorcht
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
20 #ifndef ESP_COMMON_H
21 #define ESP_COMMON_H
22 
23 #ifndef DOXYGEN
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #include "log.h"
30 #include "esp_common_log.h"
31 
32 #define asm __asm__
33 
35 #ifndef XTSTR
36 #define _XTSTR(x) # x
37 #define XTSTR(x) _XTSTR(x)
38 #endif /* XSTR */
39 
40 #if !defined(ICACHE_FLASH)
41 #ifndef ICACHE_RAM_ATTR
42 
43 #define ICACHE_RAM_ATTR __attribute__((section(".iram0.text")))
44 #endif
45 #else /* ICACHE_FLASH */
46 #ifndef ICACHE_RAM_ATTR
47 #define ICACHE_RAM_ATTR
48 #endif
49 #endif /* ICACHE_FLASH */
50 
52 #define NOT_YET_IMPLEMENTED() LOG_INFO("%s not yet implemented\n", __func__)
53 
54 #define NOT_SUPPORTED() LOG_INFO("%s not supported\n", __func__)
55 
56 #if ENABLE_DEBUG
57 
65 #define CHECK_PARAM_RET(cond,err) if (!(cond)) \
66  { \
67  DEBUG("%s parameter condition (" #cond ") " \
68  "not fulfilled\n", __func__); \
69  return err; \
70  }
71 
79 #define CHECK_PARAM(cond) if (!(cond)) \
80  { \
81  DEBUG("%s parameter condition (" #cond ") " \
82  "not fulfilled\n", __func__); \
83  return; \
84  }
85 
86 #else /* ENABLE_DEBUG */
87 
88 #define CHECK_PARAM_RET(cond,err) if (!(cond)) return err;
89 #define CHECK_PARAM(cond) if (!(cond)) return;
90 
91 #endif /* ENABLE_DEBUG */
92 
94 #ifndef MIN
95 #define MIN(a,b) ((a) < (b) ? (a) : (b))
96 #endif
97 
99 #ifndef MAX
100 #define MAX(a,b) ((a) > (b) ? (a) : (b))
101 #endif
102 
107 #define system_get_cpu_freq ets_get_cpu_frequency
108 #define system_update_cpu_freq ets_update_cpu_frequency
109 
114 #ifndef USEC_PER_MSEC
115 #define USEC_PER_MSEC 1000UL
116 #endif
117 
118 #ifndef MSEC_PER_SEC
119 #define MSEC_PER_SEC 1000UL
120 #endif
121 
122 #ifdef __cplusplus
123 }
124 #endif
125 
126 #endif /* DOXYGEN */
127 
128 #endif /* ESP_COMMON_H */
System logging header.