sonic works too

This commit is contained in:
yul 2022-05-24 15:43:24 +02:00
parent 41414634b6
commit ae3e68c12b
1 changed files with 30 additions and 4 deletions

View File

@ -12,7 +12,31 @@ void digit_to_str(char* str, uint32_t number){
int addr_to_sector(int addr){ int addr_to_sector(int addr){
int tmp = addr & 0xfffff; int tmp = addr & 0xfffff;
tmp = tmp >> 12; tmp = tmp >> 12;
return tmp; if(tmp <= 15) return tmp;
else{
if(tmp >= 0x10 && tmp <=0x17)
return 16;
else if(tmp >= 0x18 && tmp <= 0x1f)
return 17;
else if(tmp >= 0x20 && tmp <= 0x27)
return 18;
else if(tmp >= 0x28 && tmp <= 0x2f)
return 19;
else if(tmp >= 0x30 && tmp <= 0x37)
return 20;
else if(tmp >= 0x38 && tmp <= 0x3f)
return 21;
else if(tmp >= 0x40 && tmp <= 0x47)
return 22;
else if(tmp >= 0x48 && tmp <= 0x4f)
return 23;
else if(tmp >= 0x50 && tmp <= 0x57) return 24;
else if(tmp >= 0x58 && tmp <= 0x3f) return 25;
else if(tmp >= 0x60 && tmp <= 0x67) return 26;
else if(tmp >= 0x68 && tmp <= 0x6f) return 27;
else if(tmp >= 0x70 && tmp <= 0x77) return 28;
else if(tmp >= 0x78 && tmp <= 0x7f) return 29;
}
} }
void uart_commands_getid(error_code* status){ void uart_commands_getid(error_code* status){
@ -43,20 +67,22 @@ void uart_commands_getserial(error_code* status){
crc_t uart_commands_prog(error_code* status, int size){ crc_t uart_commands_prog(error_code* status, int size){
//iap_prepare_sectors(status, APP_OFFSET, APP_OFFSET+size/4095+5); //iap_prepare_sectors(status, APP_OFFSET, APP_OFFSET+size/4095+5);
iap_prepare_sectors(status, addr_to_sector(APP_OFFSET), addr_to_sector(APP_OFFSET+size)+1); int start = addr_to_sector(APP_OFFSET);
int end = addr_to_sector(APP_OFFSET+size);
iap_prepare_sectors(status, addr_to_sector(APP_OFFSET), addr_to_sector(APP_OFFSET+size));
char digit; char digit;
if(*status != ok){ if(*status != ok){
uart_send_err(); uart_send_err();
itoa(*status, &digit, 10); itoa(*status, &digit, 10);
uart_send(digit, 1); uart_send(digit, 1);
} }
iap_erase_sectors(status, addr_to_sector(APP_OFFSET), addr_to_sector(APP_OFFSET+size)+1); iap_erase_sectors(status, addr_to_sector(APP_OFFSET), addr_to_sector(APP_OFFSET+size));
if(*status != ok){ if(*status != ok){
uart_send_err(); uart_send_err();
itoa(*status, &digit, 10); itoa(*status, &digit, 10);
uart_send(digit, 1); uart_send(digit, 1);
} }
iap_prepare_sectors(status, addr_to_sector(APP_OFFSET), addr_to_sector(APP_OFFSET+size)+1); iap_prepare_sectors(status, addr_to_sector(APP_OFFSET), addr_to_sector(APP_OFFSET+size));
if(*status != ok){ if(*status != ok){
uart_send_err(); uart_send_err();
itoa(*status, &digit, 10); itoa(*status, &digit, 10);