Merge pull request #3754 from hierophect/esp-spi-pinclaim
ESP32S2: fix pin claiming bugs
This commit is contained in:
commit
abff2615cb
@ -204,6 +204,14 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
||||
// hal->dummy_bits = 0;
|
||||
// hal->addr = 0;
|
||||
|
||||
claim_pin(self->clock_pin);
|
||||
if (self->MOSI_pin != NULL) {
|
||||
claim_pin(self->MOSI_pin);
|
||||
}
|
||||
if (self->MISO_pin != NULL) {
|
||||
claim_pin(self->MISO_pin);
|
||||
}
|
||||
|
||||
hal->io_mode = SPI_LL_IO_MODE_NORMAL;
|
||||
|
||||
common_hal_busio_spi_configure(self, 250000, 0, 0, 8);
|
||||
|
@ -96,7 +96,7 @@ void reset_all_pins(void) {
|
||||
}
|
||||
|
||||
void claim_pin(const mcu_pin_obj_t* pin) {
|
||||
in_use[pin->number / 32] |= (1 << pin->number % 32);
|
||||
in_use[pin->number / 32] |= (1 << (pin->number % 32));
|
||||
#ifdef MICROPY_HW_NEOPIXEL
|
||||
if (pin == MICROPY_HW_NEOPIXEL) {
|
||||
neopixel_in_use = true;
|
||||
@ -116,7 +116,7 @@ bool pin_number_is_free(gpio_num_t pin_number) {
|
||||
#endif
|
||||
|
||||
uint8_t offset = pin_number / 32;
|
||||
uint8_t mask = 1 << pin_number % 32;
|
||||
uint32_t mask = 1 << (pin_number % 32);
|
||||
return (never_reset_pins[offset] & mask) == 0 && (in_use[offset] & mask) == 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user