3333#include "extmod/fsusermount.h"
3434
3535#include "asf/sam0/drivers/nvm/nvm.h"
36+ #include "asf/sam0/drivers/port/port.h"
3637
3738#include "internal_flash.h"
3839
@@ -51,6 +52,16 @@ void internal_flash_init(void) {
5152 config_nvm .manual_page_write = false;
5253 nvm_set_config (& config_nvm );
5354 internal_flash_is_initialised = true;
55+
56+ // Activity LED for flash writes.
57+ #ifdef MICROPY_HW_LED_MSC
58+ struct port_config pin_conf ;
59+ port_get_config_defaults (& pin_conf );
60+
61+ pin_conf .direction = PORT_PIN_DIR_OUTPUT ;
62+ port_pin_set_config (MICROPY_HW_LED_MSC , & pin_conf );
63+ port_pin_set_output_level (MICROPY_HW_LED_MSC , false);
64+ #endif
5465 }
5566}
5667
@@ -158,6 +169,9 @@ bool internal_flash_write_block(const uint8_t *src, uint32_t block) {
158169 return true;
159170
160171 } else {
172+ #ifdef MICROPY_HW_LED_MSC
173+ port_pin_set_output_level (MICROPY_HW_LED_MSC , true);
174+ #endif
161175 // non-MBR block, copy to cache
162176 volatile uint32_t dest = convert_block_to_flash_addr (block );
163177 if (dest == -1 ) {
@@ -195,6 +209,9 @@ bool internal_flash_write_block(const uint8_t *src, uint32_t block) {
195209 return false;
196210 }
197211 }
212+ #ifdef MICROPY_HW_LED_MSC
213+ port_pin_set_output_level (MICROPY_HW_LED_MSC , false);
214+ #endif
198215 return true;
199216 }
200217}
0 commit comments