esp_common.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2019 Gunar Schorcht
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
19 #ifndef DOXYGEN
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 #include "log.h"
26 #include "esp_common_log.h"
27 #include "macros/utils.h"
28 #include "macros/xtstr.h"
29 
30 #if !defined(ICACHE_FLASH)
31 #ifndef ICACHE_RAM_ATTR
33 #define ICACHE_RAM_ATTR __attribute__((section(".iram0.text")))
34 #endif
35 #else /* ICACHE_FLASH */
36 #ifndef ICACHE_RAM_ATTR
37 #define ICACHE_RAM_ATTR
38 #endif
39 #endif /* ICACHE_FLASH */
40 
41 #ifndef RTC_BSS_ATTR
42 #define RTC_BSS_ATTR __attribute__((section(".rtc.bss")))
43 #endif
44 
45 #ifdef CPU_ESP8266
46 #ifndef RTC_DATA_ATTR
47 #define RTC_DATA_ATTR __attribute__((section(".rtc.data")))
48 #endif
49 #endif
50 
52 #define NOT_YET_IMPLEMENTED() LOG_INFO("%s not yet implemented\n", __func__)
54 #define NOT_SUPPORTED() LOG_INFO("%s not supported\n", __func__)
55 
56 #if ENABLE_DEBUG
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 
97 #ifdef CPU_ESP32
98 #define system_get_cpu_freq ets_get_cpu_frequency
99 #define system_update_cpu_freq ets_update_cpu_frequency
100 #endif /* CPU_FAM_ESP32 */
106 #ifndef USEC_PER_MSEC
107 #define USEC_PER_MSEC 1000UL
108 #endif
109 
110 #ifndef MSEC_PER_SEC
111 #define MSEC_PER_SEC 1000UL
112 #endif
113 
114 #ifdef __cplusplus
115 }
116 #endif
117 
118 #endif /* DOXYGEN */
119 
Various helper macros.
Common log macros for ESP SoCs.
Macro to return string representation of x.