summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Shawcroft <scott@chickadee.tech>2016-10-25 15:06:05 -0700
committerScott Shawcroft <scott@chickadee.tech>2016-10-25 15:06:05 -0700
commitd05299f57a28f8dfbc34a2c5a1f296b12e817e06 (patch)
treedd67154419057efced9662ead17885e06edcd31d
parent3a5aad516a9a5de261e2acdd7a2dc7ecd28f0950 (diff)
atmel-samd: Add D13 led as mass storage write indicator.
-rw-r--r--atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h2
-rw-r--r--atmel-samd/boards/feather_m0_basic/mpconfigboard.h2
-rw-r--r--atmel-samd/internal_flash.c17
3 files changed, 19 insertions, 2 deletions
diff --git a/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h b/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h
index e6029a4b9..f820ce4a5 100644
--- a/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h
+++ b/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h
@@ -1,5 +1,5 @@
// LEDs
-#define MICROPY_HW_LED1 PIN_PA17 // red
+#define MICROPY_HW_LED_MSC PIN_PA17 // red
// #define UART_REPL
#define USB_REPL
diff --git a/atmel-samd/boards/feather_m0_basic/mpconfigboard.h b/atmel-samd/boards/feather_m0_basic/mpconfigboard.h
index 08a3ab0b3..a5b3ef063 100644
--- a/atmel-samd/boards/feather_m0_basic/mpconfigboard.h
+++ b/atmel-samd/boards/feather_m0_basic/mpconfigboard.h
@@ -1,5 +1,5 @@
// LEDs
-#define MICROPY_HW_LED1 PIN_PA17 // red
+#define MICROPY_HW_LED_MSC PIN_PA17 // red
// #define UART_REPL
#define USB_REPL
diff --git a/atmel-samd/internal_flash.c b/atmel-samd/internal_flash.c
index 444c174da..68a3100c5 100644
--- a/atmel-samd/internal_flash.c
+++ b/atmel-samd/internal_flash.c
@@ -33,6 +33,7 @@
#include "extmod/fsusermount.h"
#include "asf/sam0/drivers/nvm/nvm.h"
+#include "asf/sam0/drivers/port/port.h"
#include "internal_flash.h"
@@ -51,6 +52,16 @@ void internal_flash_init(void) {
config_nvm.manual_page_write = false;
nvm_set_config(&config_nvm);
internal_flash_is_initialised = true;
+
+ // Activity LED for flash writes.
+ #ifdef MICROPY_HW_LED_MSC
+ struct port_config pin_conf;
+ port_get_config_defaults(&pin_conf);
+
+ pin_conf.direction = PORT_PIN_DIR_OUTPUT;
+ port_pin_set_config(MICROPY_HW_LED_MSC, &pin_conf);
+ port_pin_set_output_level(MICROPY_HW_LED_MSC, false);
+ #endif
}
}
@@ -158,6 +169,9 @@ bool internal_flash_write_block(const uint8_t *src, uint32_t block) {
return true;
} else {
+ #ifdef MICROPY_HW_LED_MSC
+ port_pin_set_output_level(MICROPY_HW_LED_MSC, true);
+ #endif
// non-MBR block, copy to cache
volatile uint32_t dest = convert_block_to_flash_addr(block);
if (dest == -1) {
@@ -195,6 +209,9 @@ bool internal_flash_write_block(const uint8_t *src, uint32_t block) {
return false;
}
}
+ #ifdef MICROPY_HW_LED_MSC
+ port_pin_set_output_level(MICROPY_HW_LED_MSC, false);
+ #endif
return true;
}
}