diff options
| author | Dan Halbert <halbert@halwitz.org> | 2019-10-25 11:15:34 -0400 |
|---|---|---|
| committer | Dan Halbert <halbert@halwitz.org> | 2019-10-25 11:15:34 -0400 |
| commit | cdeb0857a9fec1bde99d492e7d4ef3713a29b921 (patch) | |
| tree | 533c430c84db3e1618cddb581a3c866289ab469f /supervisor/shared | |
| parent | 3683ee3ffa5b6da2574e1618b539b68cbc7e8db5 (diff) | |
Initial Itsy nRF52840 defn
Diffstat (limited to 'supervisor/shared')
| -rw-r--r-- | supervisor/shared/rgb_led_status.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/supervisor/shared/rgb_led_status.c b/supervisor/shared/rgb_led_status.c index 4d9371516..0a03094ea 100644 --- a/supervisor/shared/rgb_led_status.c +++ b/supervisor/shared/rgb_led_status.c @@ -74,8 +74,14 @@ uint16_t status_rgb_color[3] = { static uint32_t current_status_color = 0; #endif - +static bool rgb_led_status_init_in_progress = false; void rgb_led_status_init() { + if (rgb_led_status_init_in_progress) { + // Avoid recursion. + return; + } + rgb_led_status_init_in_progress = true; + #ifdef MICROPY_HW_NEOPIXEL common_hal_digitalio_digitalinout_construct(&status_neopixel, MICROPY_HW_NEOPIXEL); // Pretend we aren't using the pins. digitalio.DigitalInOut @@ -91,10 +97,9 @@ void rgb_led_status_init() { mp_const_none); #else if (!common_hal_busio_spi_deinited(&status_apa102)) { - // Don't use spi_deinit because that leads to infinite - // recursion because reset_pin_number may call - // rgb_led_status_init. - spi_m_sync_disable(&status_apa102.spi_desc); + // This may call us recursively if reset_pin_number() is called, + // The rgb_led_status_init_in_progress guard will prevent further recursion. + common_hal_busio_spi_deinit(&status_apa102); } common_hal_busio_spi_construct(&status_apa102, MICROPY_HW_APA102_SCK, @@ -149,6 +154,8 @@ void rgb_led_status_init() { current_status_color = 0x1000000; // Not a valid color new_status_color(rgb); #endif + + rgb_led_status_init_in_progress = false; } void reset_status_led() { |
