Skip to content

Commit 58e1ee7

Browse files
Attempt to change MODE to peripheral
1 parent b459802 commit 58e1ee7

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

  • ports/atmel-samd/common-hal/busio

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
6060
if (half_duplex) {
6161
mp_raise_NotImplementedError(MP_ERROR_TEXT("Half duplex SPI is not implemented"));
6262
}
63-
if (slave_mode) {
64-
mp_raise_NotImplementedError(MP_ERROR_TEXT("Slave mode SPI is not implemented"));
65-
}
6663

6764
// Ensure the object starts in its deinit state.
6865
self->clock_pin = NO_PIN;
@@ -148,6 +145,10 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
148145

149146
// Pads must be set after spi_m_sync_init(), which uses default values from
150147
// the prototypical SERCOM.
148+
uint32_t SPI_CONFIG_OFFSETS[] = {0x40003000, 0x40003400, 0x43000000, 0x43000400, 0x43000800, 0x43000C00};
149+
if (slave_mode) {
150+
*((uint32_t*) SPI_CONFIG_OFFSETS[sercom_index]) &= (1<<2);
151+
}
151152
hri_sercomspi_write_CTRLA_DOPO_bf(sercom, dopo);
152153
hri_sercomspi_write_CTRLA_DIPO_bf(sercom, miso_pad);
153154

0 commit comments

Comments
 (0)