@@ -29,12 +29,33 @@ Original Source:
2929#include < driver/spi_master.h>
3030#include < driver/rtc_io.h>
3131#include < driver/periph_ctrl.h>
32- #include < soc/soc.h>
3332#include < soc/rtc.h>
33+ #include < soc/soc.h>
3434#include < soc/i2c_reg.h>
3535#include < soc/i2c_struct.h>
3636#include < esp_log.h>
3737
38+ #include < soc/apb_ctrl_reg.h>
39+ #include < soc/efuse_reg.h>
40+
41+ #if defined (ESP_IDF_VERSION_VAL)
42+ #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(3, 4, 0)
43+
44+ // include <esp_efuse.h> でエラーが出るバージョンが存在するため、エラー回避用の記述を行ってからincludeする。;
45+ #define _ROM_SECURE_BOOT_H_
46+ #define MAX_KEY_DIGESTS 3
47+ struct ets_secure_boot_key_digests
48+ {
49+ const void *key_digests[MAX_KEY_DIGESTS];
50+ bool allow_key_revoke;
51+ };
52+ typedef struct ets_secure_boot_key_digests ets_secure_boot_key_digests_t ;
53+
54+ #include < esp_efuse.h>
55+ #define USE_ESP_EFUSE_GET_PKG_VER
56+ #endif
57+ #endif
58+
3859#if __has_include(<soc/i2c_periph.h>)
3960 #include < soc/i2c_periph.h>
4061#endif
@@ -69,6 +90,23 @@ namespace lgfx
6990 return div_num << 12 | ((div_num-1 )>>1 ) << 6 | div_num | pre << 18 ;
7091 }
7192
93+ uint32_t get_pkg_ver (void )
94+ {
95+ #if defined ( USE_ESP_EFUSE_GET_PKG_VER )
96+ return esp_efuse_get_pkg_ver ();
97+ #else
98+ uint32_t pkg_ver = REG_GET_FIELD (EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_VER_PKG);
99+ if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4)
100+ {
101+ if (REG_READ (APB_CTRL_DATE_REG) & 0x80000000 )
102+ { // ESP32PICOV302
103+ return 6 ;
104+ }
105+ }
106+ return pkg_ver;
107+ #endif
108+ }
109+
72110// ----------------------------------------------------------------------------
73111
74112 void pinMode (int_fast16_t pin, pin_mode_t mode)
0 commit comments