diff --git a/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h b/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h index e6029a4b9e..f820ce4a51 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 08a3ab0b33..a5b3ef0634 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 444c174da6..68a3100c50 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; } }