IZAR Flight Controller
1.0.0
IZAR Flight Controller running with an ESP32.
esp_idf_lib_helpers.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2019 Tomoyuki Sakurai <y@trombik.org>
3
*
4
* Permission to use, copy, modify, and distribute this software for any
5
* purpose with or without fee is hereby granted, provided that the above
6
* copyright notice and this permission notice appear in all copies.
7
*
8
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
*/
16
17
#if !defined(__ESP_IDF_LIB_HELPERS__H__)
18
#define __ESP_IDF_LIB_HELPERS__H__
19
20
/* XXX this header file does not need to include freertos/FreeRTOS.h.
21
* but without it, ESP8266 RTOS SDK does not include `sdkconfig.h` in correct
22
* order. as this header depends on sdkconfig.h, sdkconfig.h must be included
23
* first. however, the SDK includes this header first, then includes
24
* `sdkconfig.h` when freertos/FreeRTOS.h is not explicitly included. an
25
* evidence can be found in `build/${COMPONENT}/${COMPONENT}.d` in a failed
26
* build.
27
*/
28
#include <freertos/FreeRTOS.h>
29
#include <esp_idf_version.h>
30
31
#if !defined(ESP_IDF_VERSION) || !defined(ESP_IDF_VERSION_VAL)
32
#error Unknown ESP-IDF/ESP8266 RTOS SDK version
33
#endif
34
35
/* Minimal supported version for ESP32, ESP32S2 */
36
#define HELPER_ESP32_MIN_VER ESP_IDF_VERSION_VAL(3, 3, 5)
37
/* Minimal supported version for ESP8266 */
38
#define HELPER_ESP8266_MIN_VER ESP_IDF_VERSION_VAL(3, 3, 0)
39
40
/* HELPER_TARGET_IS_ESP32
41
* 1 when the target is esp32
42
*/
43
#if defined(CONFIG_IDF_TARGET_ESP32) \
44
|| defined(CONFIG_IDF_TARGET_ESP32S2) \
45
|| defined(CONFIG_IDF_TARGET_ESP32S3) \
46
|| defined(CONFIG_IDF_TARGET_ESP32C2) \
47
|| defined(CONFIG_IDF_TARGET_ESP32C3) \
48
|| defined(CONFIG_IDF_TARGET_ESP32C5) \
49
|| defined(CONFIG_IDF_TARGET_ESP32C6) \
50
|| defined(CONFIG_IDF_TARGET_ESP32P4) \
51
|| defined(CONFIG_IDF_TARGET_ESP32C61) \
52
|| defined(CONFIG_IDF_TARGET_ESP32H2)
53
#define HELPER_TARGET_IS_ESP32 (1)
54
55
/* HELPER_TARGET_IS_ESP8266
56
* 1 when the target is esp8266
57
*/
58
#elif defined(CONFIG_IDF_TARGET_ESP8266)
59
#define HELPER_TARGET_IS_ESP8266 (1)
60
#else
61
#error BUG: cannot determine the target
62
#endif
63
64
#if HELPER_TARGET_IS_ESP32 && ESP_IDF_VERSION < HELPER_ESP32_MIN_VER
65
#error Unsupported ESP-IDF version. Please update!
66
#endif
67
68
#if HELPER_TARGET_IS_ESP8266 && ESP_IDF_VERSION < HELPER_ESP8266_MIN_VER
69
#error Unsupported ESP8266 RTOS SDK version. Please update!
70
#endif
71
72
/* HELPER_SPI_HOST_DEFAULT
73
*
74
* The default SPI_HOST for spi_host_device_t
75
*/
76
#if CONFIG_IDF_TARGET_ESP32
77
#define HELPER_SPI_HOST_DEFAULT HSPI_HOST
78
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
79
#define HELPER_SPI_HOST_DEFAULT SPI2_HOST
80
#elif CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C5 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32C61
81
#define HELPER_SPI_HOST_DEFAULT SPI1_HOST
82
#elif CONFIG_IDF_TARGET_ESP32H2
83
#define HELPER_SPI_HOST_DEFAULT SPI1_HOST
84
#elif CONFIG_IDF_TARGET_ESP32P4
85
#define HELPER_SPI_HOST_DEFAULT SPI1_HOST
86
#endif
87
88
/* show the actual values for debugging */
89
#if DEBUG
90
#define VALUE_TO_STRING(x) #x
91
#define VALUE(x) VALUE_TO_STRING(x)
92
#define VAR_NAME_VALUE(var) #var "=" VALUE(var)
93
#pragma message(VAR_NAME_VALUE(CONFIG_IDF_TARGET_ESP32C3))
94
#pragma message(VAR_NAME_VALUE(CONFIG_IDF_TARGET_ESP32H2))
95
#pragma message(VAR_NAME_VALUE(CONFIG_IDF_TARGET_ESP32S2))
96
#pragma message(VAR_NAME_VALUE(CONFIG_IDF_TARGET_ESP32))
97
#pragma message(VAR_NAME_VALUE(CONFIG_IDF_TARGET_ESP8266))
98
#pragma message(VAR_NAME_VALUE(ESP_IDF_VERSION_MAJOR))
99
#endif
100
101
#endif
lib
esp_idf_lib_helpers
esp_idf_lib_helpers.h
Generated by
1.14.0