add microcontroller toggles for status LED

crypto-aes
Hierophect 3 years ago
parent 51078cc38f
commit a4797327cd
  1. 10
      ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.h
  2. 38
      ports/stm32f4/common-hal/microcontroller/Pin.c

@ -35,13 +35,13 @@
#define AUTORESET_DELAY_MS 500
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000)
#define MICROPY_HW_NEOPIXEL &pin_PC00
#define MICROPY_HW_NEOPIXEL (&pin_PC00)
// On-board flash
#define SPI_FLASH_MOSI_PIN &pin_PB05
#define SPI_FLASH_MISO_PIN &pin_PB04
#define SPI_FLASH_SCK_PIN &pin_PB03
#define SPI_FLASH_CS_PIN &pin_PA15
#define SPI_FLASH_MOSI_PIN (&pin_PB05)
#define SPI_FLASH_MISO_PIN (&pin_PB04)
#define SPI_FLASH_SCK_PIN (&pin_PB03)
#define SPI_FLASH_CS_PIN (&pin_PA15)
#define DEFAULT_I2C_BUS_SCL (&pin_PB06)
#define DEFAULT_I2C_BUS_SDA (&pin_PB07)

@ -26,6 +26,8 @@
*/
#include "shared-bindings/microcontroller/Pin.h"
#include "shared-bindings/digitalio/DigitalInOut.h"
#include "supervisor/shared/rgb_led_status.h"
#include "py/mphal.h"
#include "stm32f4/pins.h"
@ -34,13 +36,6 @@
#ifdef MICROPY_HW_NEOPIXEL
bool neopixel_in_use;
#endif
#ifdef MICROPY_HW_APA102_MOSI
bool apa102_sck_in_use;
bool apa102_mosi_in_use;
#endif
#ifdef SPEAKER_ENABLE_PIN
bool speaker_enable_in_use;
#endif
#if MCU_PACKAGE == 144
#define GPIO_PORT_COUNT 7
@ -64,6 +59,10 @@ void reset_all_pins(void) {
for (uint8_t i = 0; i < GPIO_PORT_COUNT; i++) {
HAL_GPIO_DeInit(ports[i], ~never_reset_pins[i]);
}
#ifdef MICROPY_HW_NEOPIXEL
neopixel_in_use = false;
#endif
}
// Mark pin as free and return it to a quiescent state.
@ -71,13 +70,18 @@ void reset_pin_number(uint8_t pin_port, uint8_t pin_number) {
if (pin_port == 0x0F) {
return;
}
// Clear claimed bit.
// Clear claimed bit & reset
claimed_pins[pin_port] &= ~(1<<pin_number);
// Reset the pin
HAL_GPIO_DeInit(ports[pin_port], 1<<pin_number);
}
#ifdef MICROPY_HW_NEOPIXEL
if (pin_port == MICROPY_HW_NEOPIXEL->port && pin_number == MICROPY_HW_NEOPIXEL->number) {
neopixel_in_use = false;
rgb_led_status_init();
return;
}
#endif
}
void never_reset_pin_number(uint8_t pin_port, uint8_t pin_number) {
never_reset_pins[pin_port] |= 1<<pin_number;
@ -94,6 +98,12 @@ void common_hal_reset_pin(const mcu_pin_obj_t* pin) {
void claim_pin(const mcu_pin_obj_t* pin) {
// Set bit in claimed_pins bitmask.
claimed_pins[pin->port] |= 1<<pin->number;
#ifdef MICROPY_HW_NEOPIXEL
if (pin == MICROPY_HW_NEOPIXEL) {
neopixel_in_use = true;
}
#endif
}
bool pin_number_is_free(uint8_t pin_port, uint8_t pin_number) {
@ -101,6 +111,12 @@ bool pin_number_is_free(uint8_t pin_port, uint8_t pin_number) {
}
bool common_hal_mcu_pin_is_free(const mcu_pin_obj_t *pin) {
#ifdef MICROPY_HW_NEOPIXEL
if (pin == MICROPY_HW_NEOPIXEL) {
return !neopixel_in_use;
}
#endif
return pin_number_is_free(pin->port, pin->number);
}

Loading…
Cancel
Save