summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Shawcroft <scott@chickadee.tech>2016-10-21 11:59:02 -0700
committerScott Shawcroft <scott@chickadee.tech>2016-10-21 15:44:09 -0700
commiteb62d03e338aec65d357336c48d8db4a451748fb (patch)
tree6892236a4148a4ada94f0a8d226e5ad311ef8fee
parent8b1526e95eeb5c324b6009d6d77a622bb131886a (diff)
atmel-samd: Add flash write activity LED.
-rw-r--r--atmel-samd/boards/metro_m0_flash/mpconfigboard.h1
-rw-r--r--atmel-samd/spi_flash.c13
2 files changed, 13 insertions, 1 deletions
diff --git a/atmel-samd/boards/metro_m0_flash/mpconfigboard.h b/atmel-samd/boards/metro_m0_flash/mpconfigboard.h
index b9d2f5f02..a4e1e3fc5 100644
--- a/atmel-samd/boards/metro_m0_flash/mpconfigboard.h
+++ b/atmel-samd/boards/metro_m0_flash/mpconfigboard.h
@@ -4,6 +4,7 @@
#define MICROPY_HW_BOARD_NAME "Adafruit Metro M0 with Flash (Experimental)"
#define MICROPY_HW_MCU_NAME "samd21g18"
+#define MICROPY_HW_LED_MSC PIN_PA17
#define MICROPY_HW_LED_TX PIN_PA27
#define MICROPY_HW_LED_RX PIN_PB03
diff --git a/atmel-samd/spi_flash.c b/atmel-samd/spi_flash.c
index 5424ee6ea..fef630eff 100644
--- a/atmel-samd/spi_flash.c
+++ b/atmel-samd/spi_flash.c
@@ -198,7 +198,6 @@ static bool copy_block(uint32_t src_address, uint32_t dest_address) {
void spi_flash_init(void) {
if (!spi_flash_is_initialised) {
-
struct spi_config config_spi_master;
spi_get_config_defaults(&config_spi_master);
config_spi_master.mux_setting = SPI_FLASH_MUX_SETTING;
@@ -218,6 +217,12 @@ void spi_flash_init(void) {
port_pin_set_config(SPI_FLASH_CS, &pin_conf);
flash_disable();
+ // Activity LED for flash writes.
+ #ifdef MICROPY_HW_LED_MSC
+ port_pin_set_config(MICROPY_HW_LED_MSC, &pin_conf);
+ port_pin_set_output_level(MICROPY_HW_LED_MSC, false);
+ #endif
+
uint8_t jedec_id_request[4] = {CMD_READ_JEDEC_ID, 0x00, 0x00, 0x00};
uint8_t response[4] = {0x00, 0x00, 0x00, 0x00};
flash_enable();
@@ -377,6 +382,9 @@ static void spi_flash_flush_keep_cache(bool keep_cache) {
if (current_sector == NO_SECTOR_LOADED) {
return;
}
+ #ifdef MICROPY_HW_LED_MSC
+ port_pin_set_output_level(MICROPY_HW_LED_MSC, true);
+ #endif
// If we've cached to the flash itself flush from there.
if (ram_cache == NULL) {
flush_scratch_flash();
@@ -384,6 +392,9 @@ static void spi_flash_flush_keep_cache(bool keep_cache) {
flush_ram_cache(keep_cache);
}
current_sector = NO_SECTOR_LOADED;
+ #ifdef MICROPY_HW_LED_MSC
+ port_pin_set_output_level(MICROPY_HW_LED_MSC, false);
+ #endif
}
// External flash function used. If called externally we assume we won't need