mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-04 18:03:20 +03:00
Check ESP8285 at runtime (#8604)
* esp_is_8285() at runtime * less code with less statics, just read again
This commit is contained in:
parent
8decdc380a
commit
5d4ae86565
@ -20,18 +20,19 @@
|
|||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <eagle_soc.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
/* precache()
|
/* precache()
|
||||||
* pre-loads flash data into the flash cache
|
* pre-loads flash data into the flash cache
|
||||||
* if f==0, preloads instructions starting at the address we were called from.
|
* if f==0, preloads instructions starting at the address we were called from.
|
||||||
* otherwise preloads flash at the given address.
|
* otherwise preloads flash at the given address.
|
||||||
* All preloads are word aligned.
|
* All preloads are word aligned.
|
||||||
*/
|
*/
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void precache(void *f, uint32_t bytes) {
|
void precache(void *f, uint32_t bytes) {
|
||||||
// Size of a cache page in bytes. We only need to read one word per
|
// Size of a cache page in bytes. We only need to read one word per
|
||||||
// page (ie 1 word in 8) for this to work.
|
// page (ie 1 word in 8) for this to work.
|
||||||
@ -46,6 +47,20 @@ void precache(void *f, uint32_t bytes) {
|
|||||||
(void)x;
|
(void)x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** based on efuse data, we could determine what type of chip this is
|
||||||
|
* - https://github.com/espressif/esptool/blob/f04d34bcab29ace798d2d3800ba87020cccbbfdd/esptool.py#L1060-L1070
|
||||||
|
* - https://github.com/espressif/ESP8266_RTOS_SDK/blob/3c055779e9793e5f082afff63a011d6615e73639/components/esp8266/include/esp8266/efuse_register.h#L20-L21
|
||||||
|
*/
|
||||||
|
bool esp_is_8285() {
|
||||||
|
const uint32_t data[] {
|
||||||
|
READ_PERI_REG(0x3ff00050), // aka MAC0
|
||||||
|
READ_PERI_REG(0x3ff00058), // aka CHIPID
|
||||||
|
};
|
||||||
|
|
||||||
|
return ((data[0] & (1 << 4)) > 0)
|
||||||
|
|| ((data[1] & (1 << 16)) > 0);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -122,10 +122,21 @@ inline int esp_get_cpu_freq_mhz()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Call this function in your setup() to cause the phase locked version of the generator to
|
// Call this function in your setup() to cause the phase locked version of the generator to
|
||||||
// be linked in automatically. Otherwise, the default PWM locked version will be used.
|
// be linked in automatically. Otherwise, the default PWM locked version will be used.
|
||||||
void enablePhaseLockedWaveform(void);
|
void enablePhaseLockedWaveform(void);
|
||||||
|
|
||||||
|
// Determine when the sketch runs on ESP8285
|
||||||
|
#if !defined(CORE_MOCK)
|
||||||
|
bool __attribute__((const, nothrow)) esp_is_8285();
|
||||||
|
#else
|
||||||
|
inline bool esp_is_8285()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -30,7 +30,10 @@
|
|||||||
#define NUM_DIGITAL_PINS 17
|
#define NUM_DIGITAL_PINS 17
|
||||||
#define NUM_ANALOG_INPUTS 1
|
#define NUM_ANALOG_INPUTS 1
|
||||||
|
|
||||||
#define isFlashInterfacePin(p) ((p) >= 6 && (p) <= 11)
|
#define isFlashInterfacePin(p)\
|
||||||
|
(esp_is_8285()\
|
||||||
|
? ((p) == 6 || (p) == 7 || (p) == 8 || (p) == 11)\
|
||||||
|
: ((p) >= 6 && (p) <= 11))
|
||||||
|
|
||||||
#define analogInputToDigitalPin(p) ((p > 0) ? NOT_A_PIN : 0)
|
#define analogInputToDigitalPin(p) ((p > 0) ? NOT_A_PIN : 0)
|
||||||
#define digitalPinToInterrupt(p) (((p) < EXTERNAL_NUM_INTERRUPTS)? (p) : NOT_AN_INTERRUPT)
|
#define digitalPinToInterrupt(p) (((p) < EXTERNAL_NUM_INTERRUPTS)? (p) : NOT_AN_INTERRUPT)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user