Skip to content

Commit d05299f

Browse files
committed
atmel-samd: Add D13 led as mass storage write indicator.
1 parent 3a5aad5 commit d05299f

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// LEDs
2-
#define MICROPY_HW_LED1 PIN_PA17 // red
2+
#define MICROPY_HW_LED_MSC PIN_PA17 // red
33
// #define UART_REPL
44
#define USB_REPL
55

atmel-samd/boards/feather_m0_basic/mpconfigboard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// LEDs
2-
#define MICROPY_HW_LED1 PIN_PA17 // red
2+
#define MICROPY_HW_LED_MSC PIN_PA17 // red
33
// #define UART_REPL
44
#define USB_REPL
55

atmel-samd/internal_flash.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
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

Comments
 (0)