diff options
Diffstat (limited to 'ports/stm/common-hal/microcontroller/Pin.c')
| -rw-r--r-- | ports/stm/common-hal/microcontroller/Pin.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/ports/stm/common-hal/microcontroller/Pin.c b/ports/stm/common-hal/microcontroller/Pin.c index 996513270..0e333c71c 100644 --- a/ports/stm/common-hal/microcontroller/Pin.c +++ b/ports/stm/common-hal/microcontroller/Pin.c @@ -35,6 +35,10 @@ #ifdef MICROPY_HW_NEOPIXEL bool neopixel_in_use; #endif +#if defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK) +bool apa102_sck_in_use; +bool apa102_mosi_in_use; +#endif #if defined(TFBGA216) GPIO_TypeDef * ports[] = {GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH, GPIOI, GPIOJ, GPIOK}; @@ -66,6 +70,10 @@ void reset_all_pins(void) { #ifdef MICROPY_HW_NEOPIXEL neopixel_in_use = false; #endif + #if defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK) + apa102_sck_in_use = false; + apa102_mosi_in_use = false; + #endif } // Mark pin as free and return it to a quiescent state. @@ -89,6 +97,18 @@ void reset_pin_number(uint8_t pin_port, uint8_t pin_number) { return; } #endif + #if defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK) + if ( + (pin_port == MICROPY_HW_APA102_MOSI->port && pin_number == MICROPY_HW_APA102_MOSI->number) + || (pin_port == MICROPY_HW_APA102_SCK->port && pin_number == MICROPY_HW_APA102_MOSI->number) + ) + { + apa102_mosi_in_use = false; + apa102_sck_in_use = false; + rgb_led_status_init(); + return; + } + #endif } void never_reset_pin_number(uint8_t pin_port, uint8_t pin_number) { @@ -123,6 +143,16 @@ bool common_hal_mcu_pin_is_free(const mcu_pin_obj_t *pin) { return !neopixel_in_use; } #endif + #if defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK) + if (pin == MICROPY_HW_APA102_MOSI) + { + return !apa102_mosi_in_use; + } + if (pin == MICROPY_HW_APA102_SCK) + { + return !apa102_sck_in_use; + } + #endif return pin_number_is_free(pin->port, pin->number); } @@ -146,6 +176,16 @@ void common_hal_mcu_pin_claim(const mcu_pin_obj_t* pin) { neopixel_in_use = true; } #endif + #if defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK) + if (pin == MICROPY_HW_APA102_MOSI) + { + apa102_mosi_in_use = true; + } + if (pin == MICROPY_HW_APA102_SCK) + { + apa102_sck_in_use = true; + } + #endif } void common_hal_mcu_pin_reset_number(uint8_t pin_no) { |
