2021-04-20 10:59:47 +01:00
|
|
|
/*
|
2021-06-11 15:44:57 +01:00
|
|
|
esp32x_fixes.h - fix esp32x toolchain
|
2021-04-20 10:59:47 +01:00
|
|
|
|
|
|
|
Copyright (C) 2021 Theo Arends
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Xtensa toolchain declares `int32_t` as `int` but RISC-V toolchain
|
|
|
|
* declares `int32_t` as `long int` which causes compilation errors.
|
2021-08-22 10:49:27 +01:00
|
|
|
*
|
2021-04-20 10:59:47 +01:00
|
|
|
* See:
|
|
|
|
* https://github.com/espressif/esp-idf/issues/6906
|
|
|
|
* https://github.com/espressif/arduino-esp32/issues/5086
|
2021-08-22 10:49:27 +01:00
|
|
|
*
|
|
|
|
* You need to add the following lines in `build_flags`:
|
2021-04-20 10:59:47 +01:00
|
|
|
* -I$PROJECT_DIR/include
|
2021-06-11 15:44:57 +01:00
|
|
|
* -include "esp32x_fixes.h"
|
2021-04-20 10:59:47 +01:00
|
|
|
*/
|
|
|
|
#ifdef __riscv
|
|
|
|
|
|
|
|
#undef __INT32_TYPE__
|
|
|
|
#define __INT32_TYPE__ int
|
|
|
|
|
|
|
|
#undef __UINT32_TYPE__
|
|
|
|
#define __UINT32_TYPE__ unsigned int
|
|
|
|
|
|
|
|
#endif // __riscv
|
2021-06-10 18:07:20 +01:00
|
|
|
|
2021-08-22 10:49:27 +01:00
|
|
|
//alias, deprecated for the chips after esp32s2
|
|
|
|
#ifdef CONFIG_IDF_TARGET_ESP32
|
|
|
|
#define SPI_HOST SPI1_HOST
|
|
|
|
#define HSPI_HOST SPI2_HOST
|
|
|
|
#define VSPI_HOST SPI3_HOST
|
|
|
|
|
|
|
|
#elif CONFIG_IDF_TARGET_ESP32S2
|
|
|
|
// SPI_HOST (SPI1_HOST) is not supported by the SPI Master and SPI Slave driver on ESP32-S2 and later
|
|
|
|
#define SPI_HOST SPI1_HOST
|
|
|
|
#define FSPI_HOST SPI2_HOST
|
|
|
|
#define HSPI_HOST SPI3_HOST
|
|
|
|
#define VSPI_HOST SPI3_HOST
|
|
|
|
|
2022-01-30 11:55:03 +00:00
|
|
|
#elif CONFIG_IDF_TARGET_ESP32S3
|
|
|
|
// SPI_HOST (SPI1_HOST) is not supported by the SPI Master and SPI Slave driver on ESP32-S2 and later
|
|
|
|
#define SPI_HOST SPI1_HOST
|
|
|
|
#define FSPI_HOST SPI2_HOST
|
|
|
|
#define HSPI_HOST SPI3_HOST
|
|
|
|
#define VSPI_HOST SPI3_HOST
|
2023-11-13 12:44:47 +00:00
|
|
|
// SPI_MOSI_DLEN_REG is not defined anymore in esp32s3
|
2022-02-01 13:41:01 +00:00
|
|
|
#define SPI_MOSI_DLEN_REG(x) SPI_MS_DLEN_REG(x)
|
2022-01-30 11:55:03 +00:00
|
|
|
|
2023-11-13 12:44:47 +00:00
|
|
|
#elif CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6
|
2021-08-22 10:49:27 +01:00
|
|
|
#define SPI_HOST SPI1_HOST
|
|
|
|
#define HSPI_HOST SPI2_HOST
|
2023-11-13 12:44:47 +00:00
|
|
|
#define VSPI_HOST SPI2_HOST /* No SPI3_host on C2/C6 */
|
2023-08-21 16:32:54 +01:00
|
|
|
#define VSPI SPI
|
2023-11-13 12:44:47 +00:00
|
|
|
// SPI_MOSI_DLEN_REG is not defined anymore
|
2023-08-21 16:32:54 +01:00
|
|
|
#define SPI_MOSI_DLEN_REG(x) SPI_MS_DLEN_REG(x)
|
|
|
|
|
2021-08-22 10:49:27 +01:00
|
|
|
#endif // TARGET
|
2024-05-16 20:19:34 +01:00
|
|
|
|
|
|
|
// This trick makes sure that 'lto' optimizer does not inline `delay()
|
|
|
|
// so we can override it with `-Wl,--wrap=delay` linker directive
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
#endif // _cplusplus
|
|
|
|
void delay(__UINT32_TYPE__ ms) __attribute__((noinline)) __attribute__ ((noclone));
|