Loading...
Searching...
No Matches
esp_common.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2019 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
9#pragma once
10
21
22#ifndef DOXYGEN
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28#include "log.h"
29#include "esp_common_log.h"
30#include "macros/utils.h"
31#include "macros/xtstr.h"
32
33#if !defined(ICACHE_FLASH)
34#ifndef ICACHE_RAM_ATTR
36#define ICACHE_RAM_ATTR __attribute__((section(".iram0.text")))
37#endif
38#else /* ICACHE_FLASH */
39#ifndef ICACHE_RAM_ATTR
40#define ICACHE_RAM_ATTR
41#endif
42#endif /* ICACHE_FLASH */
43
44#ifndef RTC_BSS_ATTR
45#define RTC_BSS_ATTR __attribute__((section(".rtc.bss")))
46#endif
47
48#ifdef CPU_ESP8266
49#ifndef RTC_DATA_ATTR
50#define RTC_DATA_ATTR __attribute__((section(".rtc.data")))
51#endif
52#endif
53
55#define NOT_YET_IMPLEMENTED() LOG_INFO("%s not yet implemented\n", __func__)
57#define NOT_SUPPORTED() LOG_INFO("%s not supported\n", __func__)
58
59#if ENABLE_DEBUG
68#define CHECK_PARAM_RET(cond, err) if (!(cond)) \
69 { \
70 DEBUG("%s parameter condition (" #cond ") " \
71 "not fulfilled\n", __func__); \
72 return err; \
73 }
74
82#define CHECK_PARAM(cond) if (!(cond)) \
83 { \
84 DEBUG("%s parameter condition (" #cond ") " \
85 "not fulfilled\n", __func__); \
86 return; \
87 }
88
89#else /* ENABLE_DEBUG */
90
91#define CHECK_PARAM_RET(cond, err) if (!(cond)) { return err; }
92#define CHECK_PARAM(cond) if (!(cond)) { return; }
93
94#endif /* ENABLE_DEBUG */
95
100#ifdef CPU_ESP32
101#define system_get_cpu_freq ets_get_cpu_frequency
102#define system_update_cpu_freq ets_update_cpu_frequency
103#endif /* CPU_FAM_ESP32 */
105
107
109#ifndef USEC_PER_MSEC
110#define USEC_PER_MSEC 1000UL
111#endif
112
113#ifndef MSEC_PER_SEC
114#define MSEC_PER_SEC 1000UL
115#endif
116
117#ifdef __cplusplus
118}
119#endif
120
121#endif /* DOXYGEN */
122
Various helper macros.
Common log macros for ESP SoCs.
Macro to return string representation of x.