diff options
| author | Scott Shawcroft <scott@chickadee.tech> | 2016-11-01 11:03:12 -0700 |
|---|---|---|
| committer | Scott Shawcroft <scott@chickadee.tech> | 2016-11-01 11:03:12 -0700 |
| commit | 674f3d46e85611b48bd77fd2a15b5849841742a0 (patch) | |
| tree | e5687d143c95c2216133856bb059b953d7c2c989 /atmel-samd/main.c | |
| parent | 19e5f1fef245fa21441e52c4da932aaf2f7d62da (diff) | |
atmel-samd: Reset all SERCOMs except the SPI flash one if used. #29
Diffstat (limited to 'atmel-samd/main.c')
| -rw-r--r-- | atmel-samd/main.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/atmel-samd/main.c b/atmel-samd/main.c index 560e27287..1fbe7b298 100644 --- a/atmel-samd/main.c +++ b/atmel-samd/main.c @@ -200,6 +200,21 @@ void reset_mp() { pin_init0(); } +void reset_samd21() { + // Reset all SERCOMs except the one being used by the SPI flash. + Sercom *sercom_instances[SERCOM_INST_NUM] = SERCOM_INSTS; + for (int i = 0; i < SERCOM_INST_NUM; i++) { + #ifdef SPI_FLASH_SERCOM + if (sercom_instances[i] == SPI_FLASH_SERCOM) { + continue; + } + #endif + sercom_instances[i]->SPI.CTRLA.bit.SWRST = 1; + } + + // TODO(tannewt): Reset all of the pins too. +} + void start_mp() { #ifdef AUTORESET_DELAY_MS mp_hal_stdout_tx_str("\r\n"); @@ -259,6 +274,7 @@ int main(int argc, char **argv) { } if (exit_code == PYEXEC_FORCED_EXIT) { mp_hal_stdout_tx_str("soft reboot\r\n"); + reset_samd21(); reset_mp(); start_mp(); } else if (exit_code != 0) { |
