Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "UMFEATHERS2 - implement use of DotStar for status led" #4013

Merged
merged 1 commit into from
Jan 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions ports/esp32s2/boards/unexpectedmaker_feathers2/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
#include "supervisor/board.h"
#include "mpconfigboard.h"
#include "shared-bindings/microcontroller/Pin.h"
#include "components/driver/include/driver/gpio.h"
#include "components/soc/include/hal/gpio_hal.h"

void board_init(void) {
// USB
Expand All @@ -49,12 +47,6 @@ void board_init(void) {
common_hal_never_reset_pin(&pin_GPIO30);
common_hal_never_reset_pin(&pin_GPIO31);
common_hal_never_reset_pin(&pin_GPIO32);


// Add LDO2 to never reset list, set to output and enable
common_hal_never_reset_pin(&pin_GPIO21);
gpio_set_direction(pin_GPIO21.number, GPIO_MODE_DEF_OUTPUT);
gpio_set_level(pin_GPIO21.number, true);
}

bool board_requests_safe_mode(void) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@

#define AUTORESET_DELAY_MS 500

#define MICROPY_HW_APA102_MOSI (&pin_GPIO40)
#define MICROPY_HW_APA102_SCK (&pin_GPIO45)
// #define MICROPY_HW_APA102_MOSI (&pin_GPIO40)
// #define MICROPY_HW_APA102_SCK (&pin_GPIO45)

#define DEFAULT_I2C_BUS_SCL (&pin_GPIO9)
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO8)
Expand Down
45 changes: 4 additions & 41 deletions ports/esp32s2/common-hal/microcontroller/Pin.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@
#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

STATIC uint32_t never_reset_pins[2];
STATIC uint32_t in_use[2];

bool apa102_mosi_in_use;
bool apa102_sck_in_use;

STATIC void floating_gpio_reset(gpio_num_t pin_number) {
// This is the same as gpio_reset_pin(), but without the pullup.
// Note that gpio_config resets the iomatrix to GPIO_FUNC as well.
Expand Down Expand Up @@ -87,20 +86,6 @@ void reset_pin_number(gpio_num_t pin_number) {
return;
}
#endif
#ifdef MICROPY_HW_APA102_MOSI
if (pin_number == MICROPY_HW_APA102_MOSI->number ||
pin_number == MICROPY_HW_APA102_SCK->number) {
apa102_mosi_in_use = apa102_mosi_in_use && pin_number != MICROPY_HW_APA102_MOSI->number;
apa102_sck_in_use = apa102_sck_in_use && pin_number != MICROPY_HW_APA102_SCK->number;
if (!apa102_sck_in_use && !apa102_mosi_in_use) {
rgb_led_status_init();
}
return;
}
#endif



}

void common_hal_reset_pin(const mcu_pin_obj_t* pin) {
Expand All @@ -125,11 +110,6 @@ void reset_all_pins(void) {
#ifdef MICROPY_HW_NEOPIXEL
neopixel_in_use = false;
#endif
#ifdef MICROPY_HW_APA102_MOSI
apa102_sck_in_use = false;
apa102_mosi_in_use = false;
#endif

}

void claim_pin(const mcu_pin_obj_t* pin) {
Expand All @@ -139,15 +119,6 @@ void claim_pin(const mcu_pin_obj_t* pin) {
neopixel_in_use = true;
}
#endif
#ifdef MICROPY_HW_APA102_MOSI
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_claim(const mcu_pin_obj_t* pin) {
Expand All @@ -160,18 +131,10 @@ bool pin_number_is_free(gpio_num_t pin_number) {
return !neopixel_in_use;
}
#endif
#ifdef MICROPY_HW_APA102_MOSI
if (pin_number == MICROPY_HW_APA102_MOSI->number) {
return !apa102_mosi_in_use;
}
if (pin_number == MICROPY_HW_APA102_SCK->number) {
return !apa102_sck_in_use;
}
#endif

uint8_t offset = pin_number / 32;
uint32_t mask = 1 << (pin_number % 32);
return (in_use[offset] & mask) == 0;
return (never_reset_pins[offset] & mask) == 0 && (in_use[offset] & mask) == 0;
}

bool common_hal_mcu_pin_is_free(const mcu_pin_obj_t *pin) {
Expand Down
4 changes: 1 addition & 3 deletions ports/esp32s2/common-hal/microcontroller/Pin.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@

#include "peripherals/pins.h"

#ifdef MICROPY_HW_APA102_MOSI
extern bool apa102_sck_in_use;
extern bool apa102_mosi_in_use;
#endif
extern bool apa102_sck_in_use;

#ifdef MICROPY_HW_NEOPIXEL
extern bool neopixel_in_use;
Expand Down