move uf2 led blink fast to ghostfat
This commit is contained in:
		
							
								
								
									
										14
									
								
								src/flash.c
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								src/flash.c
									
									
									
									
									
								
							| @@ -46,23 +46,11 @@ | ||||
|  | ||||
| static uint32_t _fl_addr = FLASH_CACHE_INVALID_ADDR; | ||||
| static uint8_t _fl_buf[FLASH_PAGE_SIZE] __attribute__((aligned(4))); | ||||
| static bool _first_flush = true; | ||||
|  | ||||
|  | ||||
| void flash_flush(void) | ||||
| { | ||||
|   if ( _fl_addr == FLASH_CACHE_INVALID_ADDR ) return; | ||||
|  | ||||
|   if ( _first_flush ) | ||||
|   { | ||||
|     _first_flush = false; | ||||
|  | ||||
|     // disable softdevice | ||||
|     sd_softdevice_disable(); | ||||
|  | ||||
|     led_blink_fast(true); | ||||
|   } | ||||
|  | ||||
|   if ( memcmp(_fl_buf, (void *) _fl_addr, FLASH_PAGE_SIZE) != 0 ) | ||||
|   { | ||||
|     nrf_nvmc_page_erase(_fl_addr); | ||||
| @@ -72,7 +60,7 @@ void flash_flush(void) | ||||
|   _fl_addr = FLASH_CACHE_INVALID_ADDR; | ||||
| } | ||||
|  | ||||
| void flash_write (uint32_t dst, const void *src, int len) | ||||
| void flash_write (uint32_t dst, void const *src, int len) | ||||
| { | ||||
|   uint32_t newAddr = dst & ~(FLASH_PAGE_SIZE - 1); | ||||
|  | ||||
|   | ||||
| @@ -280,6 +280,13 @@ int write_block(uint32_t block_no, uint8_t *data, bool quiet/*, WriteState *stat | ||||
|     } else { | ||||
|         // logval("write block at", bl->targetAddr); | ||||
|         NRF_LOG_DEBUG("Write block at %x", bl->targetAddr); | ||||
|  | ||||
|         static bool first_write = true; | ||||
|         if ( first_write ) { | ||||
|           first_write = false; | ||||
|           led_blink_fast(true); | ||||
|         } | ||||
|      | ||||
|         flash_write(bl->targetAddr, bl->data, bl->payloadSize); | ||||
|     } | ||||
|  | ||||
| @@ -299,13 +306,7 @@ int write_block(uint32_t block_no, uint8_t *data, bool quiet/*, WriteState *stat | ||||
|                 state->numWritten++; | ||||
|             } | ||||
|             if (state->numWritten >= state->numBlocks) { | ||||
|                 // wait a little bit before resetting, to avoid Windows transmit error | ||||
|                 // https://github.com/Microsoft/uf2-samd21/issues/11 | ||||
|                 if (!quiet) { | ||||
|  | ||||
|                 } | ||||
|  | ||||
|                 // flush last blocks if needed | ||||
|                 // flush last blocks | ||||
|                 flash_flush(); | ||||
|  | ||||
|                 uf2_write_complete(state->numBlocks); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user