diff options
| author | Scott Shawcroft <scott.shawcroft@gmail.com> | 2016-12-06 10:31:38 -0800 |
|---|---|---|
| committer | Scott Shawcroft <scott.shawcroft@gmail.com> | 2016-12-07 15:21:14 -0800 |
| commit | 0ae344841ff048424b886e1f386b16c0c9ba4ee2 (patch) | |
| tree | 358f0e2044672d38dc863b243aea734b2e41337c /atmel-samd/main.c | |
| parent | bb9c751b502a7bda49027d5ee195f8110b1493f9 (diff) | |
atmel-samd & esp8266: Make sure pins are not already in use.
This prevents corrupting previous functional objects by stealing their pins
out from under them. It prevents this by ensuring that pins are in default
state before claiming them. It also verifies pins are released correctly and
reset on soft reset.
Fixes #4, instantiating a second class will fail.
Fixes #29, pins are now reset too.
Diffstat (limited to 'atmel-samd/main.c')
| -rw-r--r-- | atmel-samd/main.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/atmel-samd/main.c b/atmel-samd/main.c index 014ff950b..adbca42ea 100644 --- a/atmel-samd/main.c +++ b/atmel-samd/main.c @@ -163,10 +163,22 @@ void reset_samd21(void) { continue; } #endif + #ifdef MICROPY_HW_APA102_SERCOM + if (sercom_instances[i] == MICROPY_HW_APA102_SERCOM) { + continue; + } + #endif sercom_instances[i]->SPI.CTRLA.bit.SWRST = 1; } - // TODO(tannewt): Reset all of the pins too. + struct system_pinmux_config config; + system_pinmux_get_config_defaults(&config); + config.powersave = true; + + uint32_t pin_mask[2] = PORT_OUT_IMPLEMENTED; + + system_pinmux_group_set_config(&(PORT->Group[0]), pin_mask[0] & ~MICROPY_PORT_A, &config); + system_pinmux_group_set_config(&(PORT->Group[1]), pin_mask[1] & ~MICROPY_PORT_B, &config); } bool maybe_run(const char* filename, int* ret) { |
