Merge pull request #662 from siddacious/dotstar_fixes

fixes hardware dotstar support for 3.0 and addresses issue #514
This commit is contained in:
Scott Shawcroft 2018-03-09 12:02:53 -08:00 committed by GitHub
commit 9bcdf40410
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 5 deletions

View File

@ -2,8 +2,8 @@
#define MICROPY_HW_MCU_NAME "samd21e18"
// Rev B - Black
// #define MICROPY_HW_APA102_MOSI (&pin_PA00)
// #define MICROPY_HW_APA102_SCK (&pin_PA01)
#define MICROPY_HW_APA102_MOSI (&pin_PA00)
#define MICROPY_HW_APA102_SCK (&pin_PA01)
#define MICROPY_PORT_A (PORT_PA00 | PORT_PA01 | PORT_PA24 | PORT_PA25)
#define MICROPY_PORT_B (0)

View File

@ -34,6 +34,7 @@
#include "hal/include/hal_gpio.h"
#include "hal/include/hal_spi_m_sync.h"
#include "hal/include/hpl_spi_m_sync.h"
#include "supervisor/shared/rgb_led_status.h"
#include "peripherals.h"
#include "pins.h"
@ -59,7 +60,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
if (potential_sercom == NULL ||
#if defined(MICROPY_HW_APA102_SCK) && defined(MICROPY_HW_APA102_MOSI) && !defined(CIRCUITPY_BITBANG_APA102)
(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)) {
#else
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.
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) {
mp_raise_OSError(MP_EIO);
}

View File

@ -70,11 +70,11 @@ void rgb_led_status_init() {
MICROPY_HW_APA102_MOSI,
mp_const_none);
#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
// recursion because reset_pin may call
// 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,
MICROPY_HW_APA102_SCK,