Implement ERASE command
This commit is contained in:
parent
1f668b6032
commit
d898f6e518
3 changed files with 59 additions and 2 deletions
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <util/delay.h>
|
||||
|
||||
|
|
@ -219,8 +220,30 @@ void commandWrite(char* arg) {
|
|||
uartPutLine("OK END");
|
||||
}
|
||||
|
||||
void commandErase() {
|
||||
uartPutLine("ERROR not implemented");
|
||||
void commandErase(char* arg) {
|
||||
if (arg == NULL) {
|
||||
uartPutLine("ERROR ERASE needs a start address");
|
||||
return;
|
||||
}
|
||||
|
||||
// Parse address(es)
|
||||
AddressRange range = parseAddressRange(arg);
|
||||
if (!range.isValid || range.to < range.from) {
|
||||
uartPutLine("ERROR invalid address format");
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t bytesErased = eepromEraseBlock(range);
|
||||
|
||||
if (bytesErased == 0) {
|
||||
uartPutLine("ERROR 0 bytes erased");
|
||||
} else {
|
||||
char outBuffer[16];
|
||||
snprintf(outBuffer, 16, "%lu", bytesErased);
|
||||
uartPutString("OK erased ");
|
||||
uartPutString(outBuffer);
|
||||
uartPutLine(" bytes");
|
||||
}
|
||||
}
|
||||
|
||||
// TESTREAD command: for testing purposes, reads a few bytes and returns them in a human readable format.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue