mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'feature/upgrade_c_cxx_standards' into 'master'
build system: use C17 and C++2a by default Closes IDF-1499, IDFGH-1788, IDFGH-2781, and IDFGH-7617 See merge request espressif/esp-idf!18371
This commit is contained in:
commit
d7cceabbb4
@ -30,6 +30,7 @@
|
||||
# define ASIO_SEPARATE_COMPILATION
|
||||
# define ASIO_STANDALONE
|
||||
# define ASIO_HAS_PTHREADS
|
||||
# define ASIO_DISABLE_CONCEPTS
|
||||
|
||||
# ifdef CONFIG_ASIO_USE_ESP_OPENSSL
|
||||
# define ASIO_USE_ESP_OPENSSL
|
||||
|
@ -127,6 +127,3 @@ else()
|
||||
REQUIRES esp_pm esp_ringbuf freertos soc hal esp_hw_support
|
||||
LDFRAGMENTS linker.lf)
|
||||
endif()
|
||||
|
||||
# uses C11 atomic feature
|
||||
set_source_files_properties(spi_master.c PROPERTIES COMPILE_FLAGS -std=gnu11)
|
||||
|
@ -40,7 +40,10 @@
|
||||
* ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_STR(arr, "Value")
|
||||
* };
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
#if defined(__cplusplus) && __cplusplus >= 202002L
|
||||
#define ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_STR(member, value) .member = value,
|
||||
#define ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(member) .member = { },
|
||||
#elif defined(__cplusplus) && __cplusplus < 202002L
|
||||
#define ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_STR(member, value) { .member = value },
|
||||
#define ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(member) .member = { },
|
||||
#else
|
||||
|
@ -53,6 +53,3 @@ idf_component_register(SRCS "${srcs}"
|
||||
INCLUDE_DIRS ${include}
|
||||
REQUIRES "esp_event" # For using "ESP_EVENT_DECLARE_BASE" in header file
|
||||
PRIV_REQUIRES ${priv_requires})
|
||||
|
||||
# uses C11 atomic feature
|
||||
set_source_files_properties(src/esp_eth.c PROPERTIES COMPILE_FLAGS -std=gnu11)
|
||||
|
@ -25,8 +25,3 @@ idf_component_register(SRCS ${srcs}
|
||||
REQUIRES ${requires}
|
||||
PRIV_REQUIRES ${priv_requires}
|
||||
LDFRAGMENTS linker.lf)
|
||||
|
||||
if(CONFIG_ESP_EVENT_LOOP_PROFILING)
|
||||
# uses C11 atomic feature
|
||||
set_source_files_properties(esp_event.c PROPERTIES COMPILE_FLAGS -std=gnu11)
|
||||
endif()
|
||||
|
@ -37,10 +37,10 @@
|
||||
#endif
|
||||
|
||||
//write value to register
|
||||
#define REG_WRITE(_r, _v) ({ \
|
||||
#define REG_WRITE(_r, _v) do { \
|
||||
ASSERT_IF_DPORT_REG((_r), REG_WRITE); \
|
||||
(*(volatile uint32_t *)(_r)) = (_v); \
|
||||
})
|
||||
} while(0)
|
||||
|
||||
//read value from register
|
||||
#define REG_READ(_r) ({ \
|
||||
@ -55,22 +55,22 @@
|
||||
})
|
||||
|
||||
//set bit or set bits to register
|
||||
#define REG_SET_BIT(_r, _b) ({ \
|
||||
#define REG_SET_BIT(_r, _b) do { \
|
||||
ASSERT_IF_DPORT_REG((_r), REG_SET_BIT); \
|
||||
(*(volatile uint32_t*)(_r) |= (_b)); \
|
||||
})
|
||||
*(volatile uint32_t*)(_r) = (*(volatile uint32_t*)(_r)) | (_b); \
|
||||
} while(0)
|
||||
|
||||
//clear bit or clear bits of register
|
||||
#define REG_CLR_BIT(_r, _b) ({ \
|
||||
#define REG_CLR_BIT(_r, _b) do { \
|
||||
ASSERT_IF_DPORT_REG((_r), REG_CLR_BIT); \
|
||||
(*(volatile uint32_t*)(_r) &= ~(_b)); \
|
||||
})
|
||||
*(volatile uint32_t*)(_r) = (*(volatile uint32_t*)(_r)) & (~(_b)); \
|
||||
} while(0)
|
||||
|
||||
//set bits of register controlled by mask
|
||||
#define REG_SET_BITS(_r, _b, _m) ({ \
|
||||
#define REG_SET_BITS(_r, _b, _m) do { \
|
||||
ASSERT_IF_DPORT_REG((_r), REG_SET_BITS); \
|
||||
(*(volatile uint32_t*)(_r) = (*(volatile uint32_t*)(_r) & ~(_m)) | ((_b) & (_m))); \
|
||||
})
|
||||
*(volatile uint32_t*)(_r) = (*(volatile uint32_t*)(_r) & ~(_m)) | ((_b) & (_m)); \
|
||||
} while(0)
|
||||
|
||||
//get field from register, uses field _S & _V to determine mask
|
||||
#define REG_GET_FIELD(_r, _f) ({ \
|
||||
@ -79,10 +79,10 @@
|
||||
})
|
||||
|
||||
//set field of a register from variable, uses field _S & _V to determine mask
|
||||
#define REG_SET_FIELD(_r, _f, _v) ({ \
|
||||
#define REG_SET_FIELD(_r, _f, _v) do { \
|
||||
ASSERT_IF_DPORT_REG((_r), REG_SET_FIELD); \
|
||||
(REG_WRITE((_r),((REG_READ(_r) & ~((_f##_V) << (_f##_S)))|(((_v) & (_f##_V))<<(_f##_S))))); \
|
||||
})
|
||||
REG_WRITE((_r),((REG_READ(_r) & ~((_f##_V) << (_f##_S)))|(((_v) & (_f##_V))<<(_f##_S)))); \
|
||||
} while(0)
|
||||
|
||||
//get field value from a variable, used when _f is not left shifted by _f##_S
|
||||
#define VALUE_GET_FIELD(_r, _f) (((_r) >> (_f##_S)) & (_f))
|
||||
@ -109,22 +109,22 @@
|
||||
})
|
||||
|
||||
//write value to register
|
||||
#define WRITE_PERI_REG(addr, val) ({ \
|
||||
#define WRITE_PERI_REG(addr, val) do { \
|
||||
ASSERT_IF_DPORT_REG((addr), WRITE_PERI_REG); \
|
||||
(*((volatile uint32_t *)ETS_UNCACHED_ADDR(addr))) = (uint32_t)(val); \
|
||||
})
|
||||
} while(0)
|
||||
|
||||
//clear bits of register controlled by mask
|
||||
#define CLEAR_PERI_REG_MASK(reg, mask) ({ \
|
||||
#define CLEAR_PERI_REG_MASK(reg, mask) do { \
|
||||
ASSERT_IF_DPORT_REG((reg), CLEAR_PERI_REG_MASK); \
|
||||
WRITE_PERI_REG((reg), (READ_PERI_REG(reg)&(~(mask)))); \
|
||||
})
|
||||
} while(0)
|
||||
|
||||
//set bits of register controlled by mask
|
||||
#define SET_PERI_REG_MASK(reg, mask) ({ \
|
||||
#define SET_PERI_REG_MASK(reg, mask) do { \
|
||||
ASSERT_IF_DPORT_REG((reg), SET_PERI_REG_MASK); \
|
||||
WRITE_PERI_REG((reg), (READ_PERI_REG(reg)|(mask))); \
|
||||
})
|
||||
} while(0)
|
||||
|
||||
//get bits of register controlled by mask
|
||||
#define GET_PERI_REG_MASK(reg, mask) ({ \
|
||||
@ -139,10 +139,10 @@
|
||||
})
|
||||
|
||||
//set bits of register controlled by mask and shift
|
||||
#define SET_PERI_REG_BITS(reg,bit_map,value,shift) ({ \
|
||||
#define SET_PERI_REG_BITS(reg,bit_map,value,shift) do { \
|
||||
ASSERT_IF_DPORT_REG((reg), SET_PERI_REG_BITS); \
|
||||
(WRITE_PERI_REG((reg),(READ_PERI_REG(reg)&(~((bit_map)<<(shift))))|(((value) & bit_map)<<(shift)) )); \
|
||||
})
|
||||
WRITE_PERI_REG((reg),(READ_PERI_REG(reg)&(~((bit_map)<<(shift))))|(((value) & (bit_map))<<(shift)) ); \
|
||||
} while(0)
|
||||
|
||||
//get field of register
|
||||
#define GET_PERI_REG_BITS2(reg, mask,shift) ({ \
|
||||
|
@ -39,9 +39,9 @@
|
||||
#ifndef __ASSEMBLER__
|
||||
|
||||
//write value to register
|
||||
#define REG_WRITE(_r, _v) ({ \
|
||||
#define REG_WRITE(_r, _v) do { \
|
||||
(*(volatile uint32_t *)(_r)) = (_v); \
|
||||
})
|
||||
} while(0)
|
||||
|
||||
//read value from register
|
||||
#define REG_READ(_r) ({ \
|
||||
@ -54,19 +54,19 @@
|
||||
})
|
||||
|
||||
//set bit or set bits to register
|
||||
#define REG_SET_BIT(_r, _b) ({ \
|
||||
(*(volatile uint32_t*)(_r) |= (_b)); \
|
||||
})
|
||||
#define REG_SET_BIT(_r, _b) do { \
|
||||
*(volatile uint32_t*)(_r) = (*(volatile uint32_t*)(_r)) | (_b); \
|
||||
} while(0)
|
||||
|
||||
//clear bit or clear bits of register
|
||||
#define REG_CLR_BIT(_r, _b) ({ \
|
||||
(*(volatile uint32_t*)(_r) &= ~(_b)); \
|
||||
})
|
||||
#define REG_CLR_BIT(_r, _b) do { \
|
||||
*(volatile uint32_t*)(_r) = (*(volatile uint32_t*)(_r)) & (~(_b)); \
|
||||
} while(0)
|
||||
|
||||
//set bits of register controlled by mask
|
||||
#define REG_SET_BITS(_r, _b, _m) ({ \
|
||||
(*(volatile uint32_t*)(_r) = (*(volatile uint32_t*)(_r) & ~(_m)) | ((_b) & (_m))); \
|
||||
})
|
||||
#define REG_SET_BITS(_r, _b, _m) do { \
|
||||
*(volatile uint32_t*)(_r) = (*(volatile uint32_t*)(_r) & ~(_m)) | ((_b) & (_m)); \
|
||||
} while(0)
|
||||
|
||||
//get field from register, uses field _S & _V to determine mask
|
||||
#define REG_GET_FIELD(_r, _f) ({ \
|
||||
@ -74,9 +74,9 @@
|
||||
})
|
||||
|
||||
//set field of a register from variable, uses field _S & _V to determine mask
|
||||
#define REG_SET_FIELD(_r, _f, _v) ({ \
|
||||
(REG_WRITE((_r),((REG_READ(_r) & ~((_f##_V) << (_f##_S)))|(((_v) & (_f##_V))<<(_f##_S))))); \
|
||||
})
|
||||
#define REG_SET_FIELD(_r, _f, _v) do { \
|
||||
REG_WRITE((_r),((REG_READ(_r) & ~((_f##_V) << (_f##_S)))|(((_v) & (_f##_V))<<(_f##_S)))); \
|
||||
} while(0)
|
||||
|
||||
//get field value from a variable, used when _f is not left shifted by _f##_S
|
||||
#define VALUE_GET_FIELD(_r, _f) (((_r) >> (_f##_S)) & (_f))
|
||||
@ -102,19 +102,19 @@
|
||||
})
|
||||
|
||||
//write value to register
|
||||
#define WRITE_PERI_REG(addr, val) ({ \
|
||||
#define WRITE_PERI_REG(addr, val) do { \
|
||||
(*((volatile uint32_t *)ETS_UNCACHED_ADDR(addr))) = (uint32_t)(val); \
|
||||
})
|
||||
} while(0)
|
||||
|
||||
//clear bits of register controlled by mask
|
||||
#define CLEAR_PERI_REG_MASK(reg, mask) ({ \
|
||||
#define CLEAR_PERI_REG_MASK(reg, mask) do { \
|
||||
WRITE_PERI_REG((reg), (READ_PERI_REG(reg)&(~(mask)))); \
|
||||
})
|
||||
} while(0)
|
||||
|
||||
//set bits of register controlled by mask
|
||||
#define SET_PERI_REG_MASK(reg, mask) ({ \
|
||||
#define SET_PERI_REG_MASK(reg, mask) do { \
|
||||
WRITE_PERI_REG((reg), (READ_PERI_REG(reg)|(mask))); \
|
||||
})
|
||||
} while(0)
|
||||
|
||||
//get bits of register controlled by mask
|
||||
#define GET_PERI_REG_MASK(reg, mask) ({ \
|
||||
@ -127,9 +127,9 @@
|
||||
})
|
||||
|
||||
//set bits of register controlled by mask and shift
|
||||
#define SET_PERI_REG_BITS(reg,bit_map,value,shift) ({ \
|
||||
(WRITE_PERI_REG((reg),(READ_PERI_REG(reg)&(~((bit_map)<<(shift))))|(((value) & bit_map)<<(shift)) )); \
|
||||
})
|
||||
#define SET_PERI_REG_BITS(reg,bit_map,value,shift) do { \
|
||||
WRITE_PERI_REG((reg),(READ_PERI_REG(reg)&(~((bit_map)<<(shift))))|(((value) & (bit_map))<<(shift)) ); \
|
||||
} while(0)
|
||||
|
||||
//get field of register
|
||||
#define GET_PERI_REG_BITS2(reg, mask,shift) ({ \
|
||||
|
@ -32,9 +32,9 @@
|
||||
#ifndef __ASSEMBLER__
|
||||
|
||||
//write value to register
|
||||
#define REG_WRITE(_r, _v) ({ \
|
||||
#define REG_WRITE(_r, _v) do { \
|
||||
(*(volatile uint32_t *)(_r)) = (_v); \
|
||||
})
|
||||
} while(0)
|
||||
|
||||
//read value from register
|
||||
#define REG_READ(_r) ({ \
|
||||
@ -47,19 +47,19 @@
|
||||
})
|
||||
|
||||
//set bit or set bits to register
|
||||
#define REG_SET_BIT(_r, _b) ({ \
|
||||
(*(volatile uint32_t*)(_r) |= (_b)); \
|
||||
})
|
||||
#define REG_SET_BIT(_r, _b) do { \
|
||||
*(volatile uint32_t*)(_r) = (*(volatile uint32_t*)(_r)) | (_b); \
|
||||
} while(0)
|
||||
|
||||
//clear bit or clear bits of register
|
||||
#define REG_CLR_BIT(_r, _b) ({ \
|
||||
(*(volatile uint32_t*)(_r) &= ~(_b)); \
|
||||
})
|
||||
#define REG_CLR_BIT(_r, _b) do { \
|
||||
*(volatile uint32_t*)(_r) = (*(volatile uint32_t*)(_r)) & (~(_b)); \
|
||||
} while(0)
|
||||
|
||||
//set bits of register controlled by mask
|
||||
#define REG_SET_BITS(_r, _b, _m) ({ \
|
||||
(*(volatile uint32_t*)(_r) = (*(volatile uint32_t*)(_r) & ~(_m)) | ((_b) & (_m))); \
|
||||
})
|
||||
#define REG_SET_BITS(_r, _b, _m) do { \
|
||||
*(volatile uint32_t*)(_r) = (*(volatile uint32_t*)(_r) & ~(_m)) | ((_b) & (_m)); \
|
||||
} while(0)
|
||||
|
||||
//get field from register, uses field _S & _V to determine mask
|
||||
#define REG_GET_FIELD(_r, _f) ({ \
|
||||
@ -67,9 +67,9 @@
|
||||
})
|
||||
|
||||
//set field of a register from variable, uses field _S & _V to determine mask
|
||||
#define REG_SET_FIELD(_r, _f, _v) ({ \
|
||||
(REG_WRITE((_r),((REG_READ(_r) & ~((_f##_V) << (_f##_S)))|(((_v) & (_f##_V))<<(_f##_S))))); \
|
||||
})
|
||||
#define REG_SET_FIELD(_r, _f, _v) do { \
|
||||
REG_WRITE((_r),((REG_READ(_r) & ~((_f##_V) << (_f##_S)))|(((_v) & (_f##_V))<<(_f##_S)))); \
|
||||
} while(0)
|
||||
|
||||
//get field value from a variable, used when _f is not left shifted by _f##_S
|
||||
#define VALUE_GET_FIELD(_r, _f) (((_r) >> (_f##_S)) & (_f))
|
||||
@ -95,19 +95,19 @@
|
||||
})
|
||||
|
||||
//write value to register
|
||||
#define WRITE_PERI_REG(addr, val) ({ \
|
||||
#define WRITE_PERI_REG(addr, val) do { \
|
||||
(*((volatile uint32_t *)ETS_UNCACHED_ADDR(addr))) = (uint32_t)(val); \
|
||||
})
|
||||
} while(0)
|
||||
|
||||
//clear bits of register controlled by mask
|
||||
#define CLEAR_PERI_REG_MASK(reg, mask) ({ \
|
||||
#define CLEAR_PERI_REG_MASK(reg, mask) do { \
|
||||
WRITE_PERI_REG((reg), (READ_PERI_REG(reg)&(~(mask)))); \
|
||||
})
|
||||
} while(0)
|
||||
|
||||
//set bits of register controlled by mask
|
||||
#define SET_PERI_REG_MASK(reg, mask) ({ \
|
||||
#define SET_PERI_REG_MASK(reg, mask) do { \
|
||||
WRITE_PERI_REG((reg), (READ_PERI_REG(reg)|(mask))); \
|
||||
})
|
||||
} while(0)
|
||||
|
||||
//get bits of register controlled by mask
|
||||
#define GET_PERI_REG_MASK(reg, mask) ({ \
|
||||
@ -120,9 +120,9 @@
|
||||
})
|
||||
|
||||
//set bits of register controlled by mask and shift
|
||||
#define SET_PERI_REG_BITS(reg,bit_map,value,shift) ({ \
|
||||
(WRITE_PERI_REG((reg),(READ_PERI_REG(reg)&(~((bit_map)<<(shift))))|(((value) & bit_map)<<(shift)) )); \
|
||||
})
|
||||
#define SET_PERI_REG_BITS(reg,bit_map,value,shift) do { \
|
||||
WRITE_PERI_REG((reg),(READ_PERI_REG(reg)&(~((bit_map)<<(shift))))|(((value) & (bit_map))<<(shift)) ); \
|
||||
} while(0)
|
||||
|
||||
//get field of register
|
||||
#define GET_PERI_REG_BITS2(reg, mask,shift) ({ \
|
||||
|
@ -32,9 +32,9 @@
|
||||
#ifndef __ASSEMBLER__
|
||||
|
||||
//write value to register
|
||||
#define REG_WRITE(_r, _v) ({ \
|
||||
#define REG_WRITE(_r, _v) do { \
|
||||
(*(volatile uint32_t *)(_r)) = (_v); \
|
||||
})
|
||||
} while(0)
|
||||
|
||||
//read value from register
|
||||
#define REG_READ(_r) ({ \
|
||||
@ -47,19 +47,19 @@
|
||||
})
|
||||
|
||||
//set bit or set bits to register
|
||||
#define REG_SET_BIT(_r, _b) ({ \
|
||||
(*(volatile uint32_t*)(_r) |= (_b)); \
|
||||
})
|
||||
#define REG_SET_BIT(_r, _b) do { \
|
||||
*(volatile uint32_t*)(_r) = (*(volatile uint32_t*)(_r)) | (_b); \
|
||||
} while(0)
|
||||
|
||||
//clear bit or clear bits of register
|
||||
#define REG_CLR_BIT(_r, _b) ({ \
|
||||
(*(volatile uint32_t*)(_r) &= ~(_b)); \
|
||||
})
|
||||
#define REG_CLR_BIT(_r, _b) do { \
|
||||
*(volatile uint32_t*)(_r) = (*(volatile uint32_t*)(_r)) & (~(_b)); \
|
||||
} while(0)
|
||||
|
||||
//set bits of register controlled by mask
|
||||
#define REG_SET_BITS(_r, _b, _m) ({ \
|
||||
(*(volatile uint32_t*)(_r) = (*(volatile uint32_t*)(_r) & ~(_m)) | ((_b) & (_m))); \
|
||||
})
|
||||
#define REG_SET_BITS(_r, _b, _m) do { \
|
||||
*(volatile uint32_t*)(_r) = (*(volatile uint32_t*)(_r) & ~(_m)) | ((_b) & (_m)); \
|
||||
} while(0)
|
||||
|
||||
//get field from register, uses field _S & _V to determine mask
|
||||
#define REG_GET_FIELD(_r, _f) ({ \
|
||||
@ -67,9 +67,9 @@
|
||||
})
|
||||
|
||||
//set field of a register from variable, uses field _S & _V to determine mask
|
||||
#define REG_SET_FIELD(_r, _f, _v) ({ \
|
||||
(REG_WRITE((_r),((REG_READ(_r) & ~((_f##_V) << (_f##_S)))|(((_v) & (_f##_V))<<(_f##_S))))); \
|
||||
})
|
||||
#define REG_SET_FIELD(_r, _f, _v) do { \
|
||||
REG_WRITE((_r),((REG_READ(_r) & ~((_f##_V) << (_f##_S)))|(((_v) & (_f##_V))<<(_f##_S)))); \
|
||||
} while(0)
|
||||
|
||||
//get field value from a variable, used when _f is not left shifted by _f##_S
|
||||
#define VALUE_GET_FIELD(_r, _f) (((_r) >> (_f##_S)) & (_f))
|
||||
@ -95,19 +95,19 @@
|
||||
})
|
||||
|
||||
//write value to register
|
||||
#define WRITE_PERI_REG(addr, val) ({ \
|
||||
#define WRITE_PERI_REG(addr, val) do { \
|
||||
(*((volatile uint32_t *)ETS_UNCACHED_ADDR(addr))) = (uint32_t)(val); \
|
||||
})
|
||||
} while(0)
|
||||
|
||||
//clear bits of register controlled by mask
|
||||
#define CLEAR_PERI_REG_MASK(reg, mask) ({ \
|
||||
#define CLEAR_PERI_REG_MASK(reg, mask) do { \
|
||||
WRITE_PERI_REG((reg), (READ_PERI_REG(reg)&(~(mask)))); \
|
||||
})
|
||||
} while(0)
|
||||
|
||||
//set bits of register controlled by mask
|
||||
#define SET_PERI_REG_MASK(reg, mask) ({ \
|
||||
#define SET_PERI_REG_MASK(reg, mask) do { \
|
||||
WRITE_PERI_REG((reg), (READ_PERI_REG(reg)|(mask))); \
|
||||
})
|
||||
} while(0)
|
||||
|
||||
//get bits of register controlled by mask
|
||||
#define GET_PERI_REG_MASK(reg, mask) ({ \
|
||||
@ -120,9 +120,9 @@
|
||||
})
|
||||
|
||||
//set bits of register controlled by mask and shift
|
||||
#define SET_PERI_REG_BITS(reg,bit_map,value,shift) ({ \
|
||||
(WRITE_PERI_REG((reg),(READ_PERI_REG(reg)&(~((bit_map)<<(shift))))|(((value) & bit_map)<<(shift)) )); \
|
||||
})
|
||||
#define SET_PERI_REG_BITS(reg,bit_map,value,shift) do { \
|
||||
WRITE_PERI_REG((reg),(READ_PERI_REG(reg)&(~((bit_map)<<(shift))))|(((value) & (bit_map))<<(shift)) ); \
|
||||
} while(0)
|
||||
|
||||
//get field of register
|
||||
#define GET_PERI_REG_BITS2(reg, mask,shift) ({ \
|
||||
|
@ -38,9 +38,9 @@
|
||||
#ifndef __ASSEMBLER__
|
||||
|
||||
//write value to register
|
||||
#define REG_WRITE(_r, _v) ({ \
|
||||
#define REG_WRITE(_r, _v) do { \
|
||||
(*(volatile uint32_t *)(_r)) = (_v); \
|
||||
})
|
||||
} while(0)
|
||||
|
||||
//read value from register
|
||||
#define REG_READ(_r) ({ \
|
||||
@ -53,19 +53,19 @@
|
||||
})
|
||||
|
||||
//set bit or set bits to register
|
||||
#define REG_SET_BIT(_r, _b) ({ \
|
||||
(*(volatile uint32_t*)(_r) |= (_b)); \
|
||||
})
|
||||
#define REG_SET_BIT(_r, _b) do { \
|
||||
*(volatile uint32_t*)(_r) = (*(volatile uint32_t*)(_r)) | (_b); \
|
||||
} while(0)
|
||||
|
||||
//clear bit or clear bits of register
|
||||
#define REG_CLR_BIT(_r, _b) ({ \
|
||||
(*(volatile uint32_t*)(_r) &= ~(_b)); \
|
||||
})
|
||||
#define REG_CLR_BIT(_r, _b) do { \
|
||||
*(volatile uint32_t*)(_r) = (*(volatile uint32_t*)(_r)) & (~(_b)); \
|
||||
} while(0)
|
||||
|
||||
//set bits of register controlled by mask
|
||||
#define REG_SET_BITS(_r, _b, _m) ({ \
|
||||
(*(volatile uint32_t*)(_r) = (*(volatile uint32_t*)(_r) & ~(_m)) | ((_b) & (_m))); \
|
||||
})
|
||||
#define REG_SET_BITS(_r, _b, _m) do { \
|
||||
*(volatile uint32_t*)(_r) = (*(volatile uint32_t*)(_r) & ~(_m)) | ((_b) & (_m)); \
|
||||
} while(0)
|
||||
|
||||
//get field from register, uses field _S & _V to determine mask
|
||||
#define REG_GET_FIELD(_r, _f) ({ \
|
||||
@ -73,9 +73,9 @@
|
||||
})
|
||||
|
||||
//set field of a register from variable, uses field _S & _V to determine mask
|
||||
#define REG_SET_FIELD(_r, _f, _v) ({ \
|
||||
(REG_WRITE((_r),((REG_READ(_r) & ~((_f##_V) << (_f##_S)))|(((_v) & (_f##_V))<<(_f##_S))))); \
|
||||
})
|
||||
#define REG_SET_FIELD(_r, _f, _v) do { \
|
||||
REG_WRITE((_r),((REG_READ(_r) & ~((_f##_V) << (_f##_S)))|(((_v) & (_f##_V))<<(_f##_S)))); \
|
||||
} while(0)
|
||||
|
||||
//get field value from a variable, used when _f is not left shifted by _f##_S
|
||||
#define VALUE_GET_FIELD(_r, _f) (((_r) >> (_f##_S)) & (_f))
|
||||
@ -101,19 +101,19 @@
|
||||
})
|
||||
|
||||
//write value to register
|
||||
#define WRITE_PERI_REG(addr, val) ({ \
|
||||
#define WRITE_PERI_REG(addr, val) do { \
|
||||
(*((volatile uint32_t *)ETS_UNCACHED_ADDR(addr))) = (uint32_t)(val); \
|
||||
})
|
||||
} while(0)
|
||||
|
||||
//clear bits of register controlled by mask
|
||||
#define CLEAR_PERI_REG_MASK(reg, mask) ({ \
|
||||
#define CLEAR_PERI_REG_MASK(reg, mask) do { \
|
||||
WRITE_PERI_REG((reg), (READ_PERI_REG(reg)&(~(mask)))); \
|
||||
})
|
||||
} while(0)
|
||||
|
||||
//set bits of register controlled by mask
|
||||
#define SET_PERI_REG_MASK(reg, mask) ({ \
|
||||
#define SET_PERI_REG_MASK(reg, mask) do { \
|
||||
WRITE_PERI_REG((reg), (READ_PERI_REG(reg)|(mask))); \
|
||||
})
|
||||
} while(0)
|
||||
|
||||
//get bits of register controlled by mask
|
||||
#define GET_PERI_REG_MASK(reg, mask) ({ \
|
||||
@ -126,9 +126,9 @@
|
||||
})
|
||||
|
||||
//set bits of register controlled by mask and shift
|
||||
#define SET_PERI_REG_BITS(reg,bit_map,value,shift) ({ \
|
||||
(WRITE_PERI_REG((reg),(READ_PERI_REG(reg)&(~((bit_map)<<(shift))))|(((value) & bit_map)<<(shift)) )); \
|
||||
})
|
||||
#define SET_PERI_REG_BITS(reg,bit_map,value,shift) do { \
|
||||
WRITE_PERI_REG((reg),(READ_PERI_REG(reg)&(~((bit_map)<<(shift))))|(((value) & (bit_map))<<(shift)) ); \
|
||||
} while(0)
|
||||
|
||||
//get field of register
|
||||
#define GET_PERI_REG_BITS2(reg, mask,shift) ({ \
|
||||
|
@ -48,9 +48,9 @@
|
||||
#ifndef __ASSEMBLER__
|
||||
|
||||
//write value to register
|
||||
#define REG_WRITE(_r, _v) ({ \
|
||||
#define REG_WRITE(_r, _v) do { \
|
||||
(*(volatile uint32_t *)(_r)) = (_v); \
|
||||
})
|
||||
} while(0)
|
||||
|
||||
//read value from register
|
||||
#define REG_READ(_r) ({ \
|
||||
@ -63,19 +63,19 @@
|
||||
})
|
||||
|
||||
//set bit or set bits to register
|
||||
#define REG_SET_BIT(_r, _b) ({ \
|
||||
(*(volatile uint32_t*)(_r) |= (_b)); \
|
||||
})
|
||||
#define REG_SET_BIT(_r, _b) do { \
|
||||
*(volatile uint32_t*)(_r) = (*(volatile uint32_t*)(_r)) | (_b); \
|
||||
} while(0)
|
||||
|
||||
//clear bit or clear bits of register
|
||||
#define REG_CLR_BIT(_r, _b) ({ \
|
||||
(*(volatile uint32_t*)(_r) &= ~(_b)); \
|
||||
})
|
||||
#define REG_CLR_BIT(_r, _b) do { \
|
||||
*(volatile uint32_t*)(_r) = (*(volatile uint32_t*)(_r)) & (~(_b)); \
|
||||
} while(0)
|
||||
|
||||
//set bits of register controlled by mask
|
||||
#define REG_SET_BITS(_r, _b, _m) ({ \
|
||||
(*(volatile uint32_t*)(_r) = (*(volatile uint32_t*)(_r) & ~(_m)) | ((_b) & (_m))); \
|
||||
})
|
||||
#define REG_SET_BITS(_r, _b, _m) do { \
|
||||
*(volatile uint32_t*)(_r) = (*(volatile uint32_t*)(_r) & ~(_m)) | ((_b) & (_m)); \
|
||||
} while(0)
|
||||
|
||||
//get field from register, uses field _S & _V to determine mask
|
||||
#define REG_GET_FIELD(_r, _f) ({ \
|
||||
@ -83,9 +83,9 @@
|
||||
})
|
||||
|
||||
//set field of a register from variable, uses field _S & _V to determine mask
|
||||
#define REG_SET_FIELD(_r, _f, _v) ({ \
|
||||
(REG_WRITE((_r),((REG_READ(_r) & ~((_f##_V) << (_f##_S)))|(((_v) & (_f##_V))<<(_f##_S))))); \
|
||||
})
|
||||
#define REG_SET_FIELD(_r, _f, _v) do { \
|
||||
REG_WRITE((_r),((REG_READ(_r) & ~((_f##_V) << (_f##_S)))|(((_v) & (_f##_V))<<(_f##_S)))); \
|
||||
} while(0)
|
||||
|
||||
//get field value from a variable, used when _f is not left shifted by _f##_S
|
||||
#define VALUE_GET_FIELD(_r, _f) (((_r) >> (_f##_S)) & (_f))
|
||||
@ -111,19 +111,19 @@
|
||||
})
|
||||
|
||||
//write value to register
|
||||
#define WRITE_PERI_REG(addr, val) ({ \
|
||||
#define WRITE_PERI_REG(addr, val) do { \
|
||||
(*((volatile uint32_t *)ETS_UNCACHED_ADDR(addr))) = (uint32_t)(val); \
|
||||
})
|
||||
} while(0)
|
||||
|
||||
//clear bits of register controlled by mask
|
||||
#define CLEAR_PERI_REG_MASK(reg, mask) ({ \
|
||||
#define CLEAR_PERI_REG_MASK(reg, mask) do { \
|
||||
WRITE_PERI_REG((reg), (READ_PERI_REG(reg)&(~(mask)))); \
|
||||
})
|
||||
} while(0)
|
||||
|
||||
//set bits of register controlled by mask
|
||||
#define SET_PERI_REG_MASK(reg, mask) ({ \
|
||||
#define SET_PERI_REG_MASK(reg, mask) do { \
|
||||
WRITE_PERI_REG((reg), (READ_PERI_REG(reg)|(mask))); \
|
||||
})
|
||||
} while(0)
|
||||
|
||||
//get bits of register controlled by mask
|
||||
#define GET_PERI_REG_MASK(reg, mask) ({ \
|
||||
@ -136,9 +136,9 @@
|
||||
})
|
||||
|
||||
//set bits of register controlled by mask and shift
|
||||
#define SET_PERI_REG_BITS(reg,bit_map,value,shift) ({ \
|
||||
(WRITE_PERI_REG((reg),(READ_PERI_REG(reg)&(~((bit_map)<<(shift))))|(((value) & bit_map)<<(shift)) )); \
|
||||
})
|
||||
#define SET_PERI_REG_BITS(reg,bit_map,value,shift) do { \
|
||||
WRITE_PERI_REG((reg),(READ_PERI_REG(reg)&(~((bit_map)<<(shift))))|(((value) & (bit_map))<<(shift)) ); \
|
||||
} while(0)
|
||||
|
||||
//get field of register
|
||||
#define GET_PERI_REG_BITS2(reg, mask,shift) ({ \
|
||||
|
@ -319,3 +319,22 @@ LCD
|
||||
7. Calling :cpp:func:`i2s_channel_disable` to stop the hardware of I2S channel.
|
||||
|
||||
8. Calling :cpp:func:`i2s_del_channel` to delete and release the resources of the channel if it is not needed any more, but the channel must be disabled before deleting it.
|
||||
|
||||
Register access macros
|
||||
----------------------
|
||||
|
||||
Previously, all register access macros could be used as expressions, so the following was allowed::
|
||||
|
||||
uint32_t val = REG_SET_BITS(reg, mask);
|
||||
|
||||
In IDF v5.0, register access macros which write or read-modify-write the register can no longer be used as expressions, and can only be used as statements. This applies to the following macros: ``REG_WRITE``, ``REG_SET_BIT``, ``REG_CLR_BIT``, ``REG_SET_BITS``, ``REG_SET_FIELD``, ``WRITE_PERI_REG``, ``CLEAR_PERI_REG_MASK``, ``SET_PERI_REG_MASK``, ``SET_PERI_REG_BITS``.
|
||||
|
||||
To store the value which would have been written into the register, split the operation as follows::
|
||||
|
||||
uint32_t new_val = REG_READ(reg) | mask;
|
||||
REG_WRITE(reg, new_val);
|
||||
|
||||
To get the value of the register after modification (which may be different from the value written), add an explicit read::
|
||||
|
||||
REG_SET_BITS(reg, mask);
|
||||
uint32_t new_val = REG_READ(reg);
|
||||
|
@ -4,8 +4,6 @@ idf_component_register(SRCS "esp_mqtt_cxx.cpp"
|
||||
INCLUDE_DIRS "include"
|
||||
)
|
||||
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-std=gnu++17")
|
||||
|
||||
if(TEST_BUILD)
|
||||
message(STATUS "Test build")
|
||||
idf_component_get_property(mqtt_dir mqtt COMPONENT_DIR)
|
||||
|
@ -1,4 +1,2 @@
|
||||
idf_component_register(SRCS "mqtt_ssl_example.cpp"
|
||||
INCLUDE_DIRS ".")
|
||||
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-std=gnu++17")
|
||||
|
@ -1,3 +1,2 @@
|
||||
idf_component_register(SRCS "mqtt_tcp_example.cpp"
|
||||
INCLUDE_DIRS ".")
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-std=gnu++17")
|
||||
|
@ -18,8 +18,8 @@
|
||||
class chat_message
|
||||
{
|
||||
public:
|
||||
enum { header_length = 4 };
|
||||
enum { max_body_length = 512 };
|
||||
static constexpr std::size_t header_length = 4;
|
||||
static constexpr std::size_t max_body_length = 512;
|
||||
|
||||
chat_message()
|
||||
: body_length_(0)
|
||||
|
@ -117,16 +117,57 @@ function(__build_set_default_build_specifications)
|
||||
# go into the final binary so have no impact on size
|
||||
"-ggdb")
|
||||
|
||||
list(APPEND c_compile_options "-std=gnu99")
|
||||
|
||||
list(APPEND cxx_compile_options "-std=gnu++11")
|
||||
|
||||
idf_build_set_property(COMPILE_DEFINITIONS "${compile_definitions}" APPEND)
|
||||
idf_build_set_property(COMPILE_OPTIONS "${compile_options}" APPEND)
|
||||
idf_build_set_property(C_COMPILE_OPTIONS "${c_compile_options}" APPEND)
|
||||
idf_build_set_property(CXX_COMPILE_OPTIONS "${cxx_compile_options}" APPEND)
|
||||
endfunction()
|
||||
|
||||
function(__build_set_lang_version)
|
||||
if(NOT IDF_TARGET STREQUAL "linux")
|
||||
# Building for chip targets: we use a known version of the toolchain.
|
||||
# Use latest supported versions.
|
||||
set(c_std gnu17)
|
||||
set(cxx_std gnu++20)
|
||||
else()
|
||||
enable_language(C CXX)
|
||||
# Building for Linux target, fall back to an older version of the standard
|
||||
# if the preferred one is not supported by the compiler.
|
||||
set(preferred_c_versions gnu17 gnu11 gnu99)
|
||||
set(ver_found FALSE)
|
||||
foreach(c_version ${preferred_c_versions})
|
||||
check_c_compiler_flag("-std=${c_version}" ver_${c_version}_supported)
|
||||
if(ver_${c_version}_supported)
|
||||
set(c_std ${c_version})
|
||||
set(ver_found TRUE)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
if(NOT ver_found)
|
||||
message(FATAL_ERROR "Failed to set C language standard to one of the supported versions: "
|
||||
"${preferred_c_versions}. Please upgrade the host compiler.")
|
||||
endif()
|
||||
|
||||
set(preferred_cxx_versions gnu++20 gnu++2a gnu++17 gnu++14)
|
||||
set(ver_found FALSE)
|
||||
foreach(cxx_version ${preferred_cxx_versions})
|
||||
check_cxx_compiler_flag("-std=${cxx_version}" ver_${cxx_version}_supported)
|
||||
if(ver_${cxx_version}_supported)
|
||||
set(cxx_std ${cxx_version})
|
||||
set(ver_found TRUE)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
if(NOT ver_found)
|
||||
message(FATAL_ERROR "Failed to set C++ language standard to one of the supported versions: "
|
||||
"${preferred_cxx_versions}. Please upgrade the host compiler.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
idf_build_set_property(C_COMPILE_OPTIONS "-std=${c_std}" APPEND)
|
||||
idf_build_set_property(CXX_COMPILE_OPTIONS "-std=${cxx_std}" APPEND)
|
||||
endfunction()
|
||||
|
||||
#
|
||||
# Initialize the build. This gets called upon inclusion of idf.cmake to set internal
|
||||
# properties used for the processing phase of the build.
|
||||
@ -151,6 +192,7 @@ function(__build_init idf_path)
|
||||
idf_build_set_property(IDF_COMPONENT_MANAGER 0)
|
||||
|
||||
__build_set_default_build_specifications()
|
||||
__build_set_lang_version()
|
||||
|
||||
# Add internal components to the build
|
||||
idf_build_get_property(idf_path IDF_PATH)
|
||||
|
@ -36,6 +36,8 @@ if(NOT __idf_env_set)
|
||||
set(IDF_PATH ${idf_path})
|
||||
|
||||
include(GetGitRevisionDescription)
|
||||
include(CheckCCompilerFlag)
|
||||
include(CheckCXXCompilerFlag)
|
||||
include(git_submodules)
|
||||
include(crosstool_version_check)
|
||||
include(kconfig)
|
||||
|
9
tools/test_apps/system/cxx_build_test/CMakeLists.txt
Normal file
9
tools/test_apps/system/cxx_build_test/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
||||
# For more information about build system see
|
||||
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
|
||||
# The following five lines of boilerplate have to be in your project's
|
||||
# CMakeLists in this exact order for cmake to work correctly
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
set(COMPONENTS main)
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(cxx_build_test)
|
7
tools/test_apps/system/cxx_build_test/README.md
Normal file
7
tools/test_apps/system/cxx_build_test/README.md
Normal file
@ -0,0 +1,7 @@
|
||||
# C++ build test
|
||||
|
||||
This build-only app can be used to check if certain headers, macros or features can be successfully compiled in a C++ source file.
|
||||
|
||||
To add a new test, create a new file `main/test_<name>.cpp` and add it to main/CMakeLists.txt.
|
||||
|
||||
If you need to check specific compiler flags, use `set_source_files_properties` CMake function to adjust the compilation flags for the given source file.
|
@ -0,0 +1,4 @@
|
||||
idf_component_register(SRCS cxx_build_test_main.cpp
|
||||
test_soc_reg_macros.cpp
|
||||
INCLUDE_DIRS "."
|
||||
REQUIRES soc)
|
@ -0,0 +1,10 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
extern "C" void app_main(void)
|
||||
{
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
/* Compiling this file checks if SoC register access macros
|
||||
* can be used from C++ successfully. This check is necessary
|
||||
* because C++ 20 deprecates certain uses of 'volatile' qualified
|
||||
* variables.
|
||||
*/
|
||||
#include "soc/soc.h"
|
||||
#include "soc/uart_reg.h"
|
||||
|
||||
|
||||
/* non-static, to prevent the value being optimized out */
|
||||
void sink(uint32_t arg)
|
||||
{
|
||||
}
|
||||
|
||||
void test_reg_macros(void)
|
||||
{
|
||||
REG_WRITE(UART_DATE_REG(0), 1);
|
||||
sink(REG_READ(UART_DATE_REG(0)));
|
||||
sink(REG_GET_BIT(UART_DATE_REG(0), BIT(0)));
|
||||
REG_SET_BIT(UART_DATE_REG(0), BIT(0));
|
||||
REG_CLR_BIT(UART_DATE_REG(0), BIT(0));
|
||||
REG_SET_BITS(UART_DATE_REG(0), BIT(0), BIT(0) | BIT(1));
|
||||
sink(REG_GET_FIELD(UART_DATE_REG(0), UART_DATE));
|
||||
REG_SET_FIELD(UART_DATE_REG(0), UART_DATE, 42);
|
||||
|
||||
sink(READ_PERI_REG(UART_DATE_REG(0)));
|
||||
WRITE_PERI_REG(UART_DATE_REG(0), 1);
|
||||
CLEAR_PERI_REG_MASK(UART_DATE_REG(0), BIT(0));
|
||||
SET_PERI_REG_MASK(UART_DATE_REG(0), BIT(0));
|
||||
sink(GET_PERI_REG_MASK(UART_DATE_REG(0), BIT(0)));
|
||||
sink(GET_PERI_REG_BITS(UART_DATE_REG(0), 2, 1));
|
||||
SET_PERI_REG_BITS(UART_DATE_REG(0), BIT(0) | BIT(1), 1, 2);
|
||||
sink(GET_PERI_REG_BITS2(UART_DATE_REG(0), BIT(0) | BIT(1), 1));
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user