Skip to content

Commit eb62d03

Browse files
committed
atmel-samd: Add flash write activity LED.
1 parent 8b1526e commit eb62d03

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

atmel-samd/boards/metro_m0_flash/mpconfigboard.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#define MICROPY_HW_BOARD_NAME "Adafruit Metro M0 with Flash (Experimental)"
55
#define MICROPY_HW_MCU_NAME "samd21g18"
66

7+
#define MICROPY_HW_LED_MSC PIN_PA17
78
#define MICROPY_HW_LED_TX PIN_PA27
89
#define MICROPY_HW_LED_RX PIN_PB03
910

atmel-samd/spi_flash.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ static bool copy_block(uint32_t src_address, uint32_t dest_address) {
198198

199199
void spi_flash_init(void) {
200200
if (!spi_flash_is_initialised) {
201-
202201
struct spi_config config_spi_master;
203202
spi_get_config_defaults(&config_spi_master);
204203
config_spi_master.mux_setting = SPI_FLASH_MUX_SETTING;
@@ -218,6 +217,12 @@ void spi_flash_init(void) {
218217
port_pin_set_config(SPI_FLASH_CS, &pin_conf);
219218
flash_disable();
220219

220+
// Activity LED for flash writes.
221+
#ifdef MICROPY_HW_LED_MSC
222+
port_pin_set_config(MICROPY_HW_LED_MSC, &pin_conf);
223+
port_pin_set_output_level(MICROPY_HW_LED_MSC, false);
224+
#endif
225+
221226
uint8_t jedec_id_request[4] = {CMD_READ_JEDEC_ID, 0x00, 0x00, 0x00};
222227
uint8_t response[4] = {0x00, 0x00, 0x00, 0x00};
223228
flash_enable();
@@ -377,13 +382,19 @@ static void spi_flash_flush_keep_cache(bool keep_cache) {
377382
if (current_sector == NO_SECTOR_LOADED) {
378383
return;
379384
}
385+
#ifdef MICROPY_HW_LED_MSC
386+
port_pin_set_output_level(MICROPY_HW_LED_MSC, true);
387+
#endif
380388
// If we've cached to the flash itself flush from there.
381389
if (ram_cache == NULL) {
382390
flush_scratch_flash();
383391
} else {
384392
flush_ram_cache(keep_cache);
385393
}
386394
current_sector = NO_SECTOR_LOADED;
395+
#ifdef MICROPY_HW_LED_MSC
396+
port_pin_set_output_level(MICROPY_HW_LED_MSC, false);
397+
#endif
387398
}
388399

389400
// External flash function used. If called externally we assume we won't need

0 commit comments

Comments
 (0)