fixes hardware dotstar support for 3.0 and addresses issue #514
This commit is contained in:
parent
402e71dcdd
commit
942b7ffbe0
@ -2,8 +2,8 @@
|
|||||||
#define MICROPY_HW_MCU_NAME "samd21e18"
|
#define MICROPY_HW_MCU_NAME "samd21e18"
|
||||||
|
|
||||||
// Rev B - Black
|
// Rev B - Black
|
||||||
// #define MICROPY_HW_APA102_MOSI (&pin_PA00)
|
#define MICROPY_HW_APA102_MOSI (&pin_PA00)
|
||||||
// #define MICROPY_HW_APA102_SCK (&pin_PA01)
|
#define MICROPY_HW_APA102_SCK (&pin_PA01)
|
||||||
|
|
||||||
#define MICROPY_PORT_A (PORT_PA00 | PORT_PA01 | PORT_PA24 | PORT_PA25)
|
#define MICROPY_PORT_A (PORT_PA00 | PORT_PA01 | PORT_PA24 | PORT_PA25)
|
||||||
#define MICROPY_PORT_B (0)
|
#define MICROPY_PORT_B (0)
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "hal/include/hal_gpio.h"
|
#include "hal/include/hal_gpio.h"
|
||||||
#include "hal/include/hal_spi_m_sync.h"
|
#include "hal/include/hal_spi_m_sync.h"
|
||||||
#include "hal/include/hpl_spi_m_sync.h"
|
#include "hal/include/hpl_spi_m_sync.h"
|
||||||
|
#include "supervisor/shared/rgb_led_status.h"
|
||||||
|
|
||||||
#include "peripherals.h"
|
#include "peripherals.h"
|
||||||
#include "pins.h"
|
#include "pins.h"
|
||||||
@ -59,7 +60,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
|||||||
if (potential_sercom == NULL ||
|
if (potential_sercom == NULL ||
|
||||||
#if defined(MICROPY_HW_APA102_SCK) && defined(MICROPY_HW_APA102_MOSI) && !defined(CIRCUITPY_BITBANG_APA102)
|
#if defined(MICROPY_HW_APA102_SCK) && defined(MICROPY_HW_APA102_MOSI) && !defined(CIRCUITPY_BITBANG_APA102)
|
||||||
(potential_sercom->SPI.CTRLA.bit.ENABLE != 0 &&
|
(potential_sercom->SPI.CTRLA.bit.ENABLE != 0 &&
|
||||||
potential_sercom != status_apa102.spi_master_instance.hw &&
|
potential_sercom != status_apa102.spi_desc.dev.prvt &&
|
||||||
!apa102_sck_in_use)) {
|
!apa102_sck_in_use)) {
|
||||||
#else
|
#else
|
||||||
potential_sercom->SPI.CTRLA.bit.ENABLE != 0) {
|
potential_sercom->SPI.CTRLA.bit.ENABLE != 0) {
|
||||||
@ -113,6 +114,10 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
|||||||
// Set up SPI clocks on SERCOM.
|
// Set up SPI clocks on SERCOM.
|
||||||
samd_peripherals_sercom_clock_init(sercom, sercom_index);
|
samd_peripherals_sercom_clock_init(sercom, sercom_index);
|
||||||
|
|
||||||
|
#if defined(MICROPY_HW_APA102_SCK) && defined(MICROPY_HW_APA102_MOSI) && !defined(CIRCUITPY_BITBANG_APA102)
|
||||||
|
// if we're re-using the dotstar sercom, make sure it is disabled or the init will fail out
|
||||||
|
hri_sercomspi_clear_CTRLA_ENABLE_bit(sercom);
|
||||||
|
#endif
|
||||||
if (spi_m_sync_init(&self->spi_desc, sercom) != ERR_NONE) {
|
if (spi_m_sync_init(&self->spi_desc, sercom) != ERR_NONE) {
|
||||||
mp_raise_OSError(MP_EIO);
|
mp_raise_OSError(MP_EIO);
|
||||||
}
|
}
|
||||||
|
@ -70,11 +70,11 @@ void rgb_led_status_init() {
|
|||||||
MICROPY_HW_APA102_MOSI,
|
MICROPY_HW_APA102_MOSI,
|
||||||
mp_const_none);
|
mp_const_none);
|
||||||
#else
|
#else
|
||||||
if (status_apa102.current_baudrate > 0) {
|
if (!common_hal_busio_spi_deinited(&status_apa102)) {
|
||||||
// Don't use spi_deinit because that leads to infinite
|
// Don't use spi_deinit because that leads to infinite
|
||||||
// recursion because reset_pin may call
|
// recursion because reset_pin may call
|
||||||
// rgb_led_status_init.
|
// rgb_led_status_init.
|
||||||
spi_disable(&status_apa102.spi_master_instance);
|
spi_m_sync_disable(&status_apa102.spi_desc);
|
||||||
}
|
}
|
||||||
common_hal_busio_spi_construct(&status_apa102,
|
common_hal_busio_spi_construct(&status_apa102,
|
||||||
MICROPY_HW_APA102_SCK,
|
MICROPY_HW_APA102_SCK,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user