Add is_system_pin

This commit is contained in:
fvanroie 2021-02-23 20:40:16 +01:00
parent e97d7459f4
commit c5204b48d5
7 changed files with 32 additions and 0 deletions

View File

@ -77,6 +77,10 @@ class BaseDevice {
{ {
return 0; return 0;
} }
virtual bool is_system_pin(uint8_t pin)
{
return false;
}
}; };
} // namespace dev } // namespace dev

View File

@ -122,6 +122,16 @@ uint16_t Esp32Device::get_cpu_frequency()
return ESP.getCpuFreqMHz(); return ESP.getCpuFreqMHz();
} }
bool Esp32Device::is_system_pin(uint8_t pin)
{
if((pin >= 6) && (pin <= 11)) return true; // integrated SPI flash
if((pin == 37) || (pin == 38)) return true; // unavailable
if(psramFound()) {
if((pin == 16) || (pin == 17)) return true; // PSRAM
}
return false;
}
} // namespace dev } // namespace dev
#if defined(LANBONL8) #if defined(LANBONL8)

View File

@ -39,6 +39,8 @@ class Esp32Device : public BaseDevice {
uint8_t get_heap_fragmentation() override; uint8_t get_heap_fragmentation() override;
uint16_t get_cpu_frequency() override; uint16_t get_cpu_frequency() override;
bool is_system_pin(uint8_t pin) override;
private: private:
std::string _hostname; std::string _hostname;

View File

@ -109,6 +109,13 @@ uint16_t Esp8266Device::get_cpu_frequency()
return ESP.getCpuFreqMHz(); return ESP.getCpuFreqMHz();
} }
bool Esp8266Device::is_system_pin(uint8_t pin)
{
if((pin >= 6) && (pin <= 11)) return true; // integrated SPI flash
if((pin >= 12) && (pin <= 14)) return true; // HSPI
return false;
}
} // namespace dev } // namespace dev
dev::Esp8266Device haspDevice; dev::Esp8266Device haspDevice;

View File

@ -41,6 +41,8 @@ class Esp8266Device : public BaseDevice {
uint8_t get_heap_fragmentation() override; uint8_t get_heap_fragmentation() override;
uint16_t get_cpu_frequency() override; uint16_t get_cpu_frequency() override;
bool is_system_pin(uint8_t pin) override;
private: private:
std::string _hostname; std::string _hostname;

View File

@ -119,6 +119,11 @@ uint16_t Win32Device::get_cpu_frequency()
return 0; return 0;
} }
bool Win32Device::is_system_pin(uint8_t pin)
{
return false;
}
} // namespace dev } // namespace dev
dev::Win32Device haspDevice; dev::Win32Device haspDevice;

View File

@ -59,6 +59,8 @@ class Win32Device : public BaseDevice {
uint8_t get_heap_fragmentation(); uint8_t get_heap_fragmentation();
uint16_t get_cpu_frequency(); uint16_t get_cpu_frequency();
bool is_system_pin(uint8_t pin) override;
private: private:
std::string _hostname; std::string _hostname;