fixed most warnings

This commit is contained in:
yul 2022-05-30 19:57:15 +02:00
parent b21b8dbf2d
commit e1ffa61060
5 changed files with 13 additions and 28 deletions

View File

@ -105,6 +105,7 @@ void manage_bootloader(){
cmd.argv = (char**)argvs;
int var = 1;
char digit;
set_colour(GREEN);
while(var){
uart_receive_command(buff);
uart_parse_command(buff, &cmd);

22
iap.c
View File

@ -18,7 +18,7 @@ unsigned int command[5];
unsigned int output[5];
IAP iap_entry =(IAP) IAP_LOCATION;
int addr_to_sector(int addr){
int addr_to_sector(unsigned long int addr){
int tmp = addr & 0xfffff;
tmp = tmp >> 12;
if(tmp <= 15) return tmp;
@ -46,6 +46,7 @@ int addr_to_sector(int addr){
else if(tmp >= 0x70 && tmp <= 0x77) return 28;
else if(tmp >= 0x78 && tmp <= 0x7f) return 29;
}
return -1;
}
void iap_entry_wrapped(void){
@ -94,11 +95,11 @@ uint32_t iap_read_part_id(error_code* status){
}
}
void iap_copy_to_flash(error_code* status, long unsigned int * dst_flash, long unsigned int* src_ram, int num_bytes){
iap_prepare_sectors(status, addr_to_sector(dst_flash), addr_to_sector(dst_flash+num_bytes));
void iap_copy_to_flash(error_code* status, long unsigned int* dst_flash, uint8_t* src_ram, int num_bytes){
iap_prepare_sectors(status, addr_to_sector((long unsigned int)dst_flash), addr_to_sector((long unsigned int)dst_flash+num_bytes));
command[0] = 51;
command[1] = dst_flash;
command[2] = src_ram;
command[1] = (unsigned int)dst_flash;
command[2] = (unsigned int)src_ram;
command[3] = num_bytes;
command[4] = IAP_CLOCK_100M;
iap_entry_wrapped();
@ -124,14 +125,3 @@ void iap_read_serial(error_code* status, uint32_t* res){
}
}
// TODO: insert other include files here
// TODO: insert other definitions and declarations here
/*
int main(void) {
LPC_PINCON->PINSEL4 &= ~0xFF; //Configure the PORT2 Pins as GPIO;
LPC_GPIO2->FIODIR = 0xff; //Configure the PORT2 pins as OUTPUT;
iap_read_part_id();
iap_erase_sectors(2, 9);
iap_copy_to_flash(0x8000,(uint8_t*)test, 4);
}*/

4
iap.h
View File

@ -34,10 +34,10 @@ void iap_prepare_sectors(error_code* status, int start, int end);
void iap_erase_sectors(error_code* status, int start, int end);
void iap_copy_to_flash(error_code* status, long unsigned int * dst_flash, long unsigned int* src_ram, int num_bytes);
void iap_copy_to_flash(error_code* status, long unsigned int * dst_flash, uint8_t* src_ram, int num_bytes);
uint32_t iap_read_part_id(error_code* status);
void iap_read_serial(error_code* status, uint32_t* res);
int addr_to_sector(int addr);
int addr_to_sector(unsigned long int addr);

6
uart.c
View File

@ -32,14 +32,12 @@ void uart_init(uint32_t baudrate){
}
void uart_send(char* buff, uint32_t length){
int tmp;
//int tmp;
while (length-- != 0 ){
//LPC_UART0->THR = *buff++;
while(((LPC_UART0->LSR)&(1<<5)) == 0);//stuck in while when U1THR contains valid data
LPC_UART0->THR = *buff++;
tmp = LPC_UART0->RBR;
//LPC_GPIO2->FIOCLR = 0xff;
//LPC_GPIO2->FIOSET = tmp;
//tmp = LPC_UART0->RBR;
}
}

View File

@ -57,8 +57,6 @@ void uart_commands_getserial(error_code* status){
crc_t uart_commands_prog(error_code* status, int size){
char digit;
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));
if(*status != ok){
uart_send_err();
@ -87,16 +85,14 @@ error_code uart_commands_data(error_code* status, int size, crc_t* checksum_glob
crc_t checksum_tmp = crc_init();
checksum_tmp = crc_update(checksum_tmp, data, size);
checksum_tmp = crc_finalize(checksum_tmp);
int offset_counter = offset;
if(checksum_loc == checksum_tmp){
int tmp = size;
iap_prepare_sectors(status, addr_to_sector(offset), addr_to_sector(offset+size)+1);
*checksum_global = crc_update(*checksum_global, data, size);
//verify if size == 4095 if smaller
if(size == 0x0400)
iap_copy_to_flash(status, offset, data, size);
iap_copy_to_flash(status, (long unsigned int *)offset, data, size);
else{
iap_copy_to_flash(status, offset, data, 0x400);
iap_copy_to_flash(status, (long unsigned int *)offset, data, 0x400);
*checksum_global = crc_finalize(*checksum_global);
}
if(*status != ok){