mirror of https://github.com/arendst/Tasmota.git
Fix max 32-bit bitRead/bitSet size issue
This commit is contained in:
parent
c4c03b7c1b
commit
51af8611bb
|
@ -1327,17 +1327,13 @@ void SetPin(uint32_t lpin, uint32_t gpio) {
|
|||
}
|
||||
|
||||
void DigitalWrite(uint32_t gpio_pin, uint32_t index, uint32_t state) {
|
||||
#ifdef ESP8266
|
||||
static uint32_t pinmode_init = 0; // Pins 0 to 31 !!! - saves 40 bytes code space compared to uint64_t
|
||||
#else
|
||||
static uint64_t pinmode_init = 0; // Pins 0 to 63 !!!
|
||||
#endif
|
||||
static uint32_t pinmode_init[2] = { 0 }; // Pins 0 to 63 !!!
|
||||
|
||||
if (PinUsed(gpio_pin, index)) {
|
||||
uint32_t pin = Pin(gpio_pin, index);
|
||||
if (!bitRead(pinmode_init, pin)) {
|
||||
uint32_t pin = Pin(gpio_pin, index) & 0x3F; // Fix possible overflow over 63 gpios
|
||||
if (!bitRead(pinmode_init[pin / 32], pin % 32)) {
|
||||
bitSet(pinmode_init[pin / 32], pin % 32);
|
||||
pinMode(pin, OUTPUT);
|
||||
bitSet(pinmode_init, pin);
|
||||
}
|
||||
digitalWrite(pin, state &1);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue