Skip to content

Commit 9bcdf40

Browse files
authored
Merge pull request adafruit#662 from siddacious/dotstar_fixes
fixes hardware dotstar support for 3.0 and addresses issue adafruit#514
2 parents 402e71d + 942b7ff commit 9bcdf40

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

ports/atmel-samd/boards/trinket_m0/mpconfigboard.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#define MICROPY_HW_MCU_NAME "samd21e18"
33

44
// Rev B - Black
5-
// #define MICROPY_HW_APA102_MOSI (&pin_PA00)
6-
// #define MICROPY_HW_APA102_SCK (&pin_PA01)
5+
#define MICROPY_HW_APA102_MOSI (&pin_PA00)
6+
#define MICROPY_HW_APA102_SCK (&pin_PA01)
77

88
#define MICROPY_PORT_A (PORT_PA00 | PORT_PA01 | PORT_PA24 | PORT_PA25)
99
#define MICROPY_PORT_B (0)

ports/atmel-samd/common-hal/busio/SPI.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "hal/include/hal_gpio.h"
3535
#include "hal/include/hal_spi_m_sync.h"
3636
#include "hal/include/hpl_spi_m_sync.h"
37+
#include "supervisor/shared/rgb_led_status.h"
3738

3839
#include "peripherals.h"
3940
#include "pins.h"
@@ -59,7 +60,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
5960
if (potential_sercom == NULL ||
6061
#if defined(MICROPY_HW_APA102_SCK) && defined(MICROPY_HW_APA102_MOSI) && !defined(CIRCUITPY_BITBANG_APA102)
6162
(potential_sercom->SPI.CTRLA.bit.ENABLE != 0 &&
62-
potential_sercom != status_apa102.spi_master_instance.hw &&
63+
potential_sercom != status_apa102.spi_desc.dev.prvt &&
6364
!apa102_sck_in_use)) {
6465
#else
6566
potential_sercom->SPI.CTRLA.bit.ENABLE != 0) {
@@ -113,6 +114,10 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
113114
// Set up SPI clocks on SERCOM.
114115
samd_peripherals_sercom_clock_init(sercom, sercom_index);
115116

117+
#if defined(MICROPY_HW_APA102_SCK) && defined(MICROPY_HW_APA102_MOSI) && !defined(CIRCUITPY_BITBANG_APA102)
118+
// if we're re-using the dotstar sercom, make sure it is disabled or the init will fail out
119+
hri_sercomspi_clear_CTRLA_ENABLE_bit(sercom);
120+
#endif
116121
if (spi_m_sync_init(&self->spi_desc, sercom) != ERR_NONE) {
117122
mp_raise_OSError(MP_EIO);
118123
}

supervisor/shared/rgb_led_status.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ void rgb_led_status_init() {
7070
MICROPY_HW_APA102_MOSI,
7171
mp_const_none);
7272
#else
73-
if (status_apa102.current_baudrate > 0) {
73+
if (!common_hal_busio_spi_deinited(&status_apa102)) {
7474
// Don't use spi_deinit because that leads to infinite
7575
// recursion because reset_pin may call
7676
// rgb_led_status_init.
77-
spi_disable(&status_apa102.spi_master_instance);
77+
spi_m_sync_disable(&status_apa102.spi_desc);
7878
}
7979
common_hal_busio_spi_construct(&status_apa102,
8080
MICROPY_HW_APA102_SCK,

0 commit comments

Comments
 (0)