Merge pull request #3436 from jepler/fix-spi-sercom4
samd: SPI: improve conditional code
This commit is contained in:
commit
5116375604
@ -286,8 +286,6 @@ SRC_ASF += \
|
||||
$(BUILD)/asf4/$(CHIP_FAMILY)/hpl/sdhc/hpl_sdhc.o: CFLAGS += -Wno-cast-align -Wno-implicit-fallthrough
|
||||
endif
|
||||
|
||||
$(BUILD)/asf4/$(CHIP_FAMILY)/hpl/sercom/hpl_sercom.o: CFLAGS += -Wno-maybe-uninitialized
|
||||
|
||||
SRC_ASF := $(addprefix asf4/$(CHIP_FAMILY)/, $(SRC_ASF))
|
||||
|
||||
SRC_C += \
|
||||
|
@ -98,8 +98,8 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
||||
uint8_t miso_pad = 0;
|
||||
uint8_t dopo = 255;
|
||||
|
||||
// Special case for SAMR boards.
|
||||
#ifdef PIN_PC19
|
||||
// Special case for SAMR21 boards. (feather_radiofruit_zigbee)
|
||||
#if defined(PIN_PC19F_SERCOM4_PAD0)
|
||||
if (miso == &pin_PC19) {
|
||||
if (mosi == &pin_PB30 && clock == &pin_PC18) {
|
||||
sercom = SERCOM4;
|
||||
@ -113,8 +113,9 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
||||
dopo = samd_peripherals_get_spi_dopo(clock_pad, mosi_pad);
|
||||
}
|
||||
// Error, leave SERCOM unset to throw an exception later.
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
for (int i = 0; i < NUM_SERCOMS_PER_PIN; i++) {
|
||||
sercom_index = clock->sercom[i].index; // 2 for SERCOM2, etc.
|
||||
if (sercom_index >= SERCOM_INST_NUM) {
|
||||
@ -125,10 +126,11 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
||||
#if defined(MICROPY_HW_APA102_SCK) && defined(MICROPY_HW_APA102_MOSI) && !CIRCUITPY_BITBANG_APA102
|
||||
(potential_sercom->SPI.CTRLA.bit.ENABLE != 0 &&
|
||||
potential_sercom != status_apa102.spi_desc.dev.prvt &&
|
||||
!apa102_sck_in_use)) {
|
||||
!apa102_sck_in_use)
|
||||
#else
|
||||
potential_sercom->SPI.CTRLA.bit.ENABLE != 0) {
|
||||
potential_sercom->SPI.CTRLA.bit.ENABLE != 0
|
||||
#endif
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
clock_pinmux = PINMUX(clock->number, (i == 0) ? MUX_C : MUX_D);
|
||||
@ -171,9 +173,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifdef PIN_PC19
|
||||
}
|
||||
#endif
|
||||
if (sercom == NULL) {
|
||||
mp_raise_ValueError(translate("Invalid pins"));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user