bootloader/iap.h

44 lines
1.4 KiB
C
Raw Normal View History

2022-05-19 08:57:38 -04:00
#include <cr_section_macros.h>
#include <stdio.h>
#define IAP_LOCATION 0x1FFF1FF1
#define IAP_CMD_SUCCESS 0
#define IAP_INVALID_COMMAND 1
#define IAP_SRC_ADDR_ERROR 2
#define IAP_DST_ADDR_ERROR 3
#define IAP_SRC_ADDR_NOT_MAPPED 4
#define IAP_DST_ADDR_NOT_MAPPED 5
#define IAP_COUNT_ERROR 6
#define IAP_INVALID_SECTOR 7
#define IAP_SECTOR_NOT_BLANK 8
#define IAP_SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION 9
#define IAP_COMPARE_ERROR 10
#define IAP_BUSY 11
#define IAP_CLOCK_100M 100000
typedef enum _error_code {
ok, general_error, invalid_command, global_checksum,
local_checksum, erase_error, write_error, invalid_size,
invalid_offset, invalid_arguments
} error_code;
typedef void (*IAP)(unsigned int[], unsigned int[]);
2022-05-28 13:30:55 -04:00
/*This command must be executed before executing "Copy RAM to Flash" or
"Erase Sector(s)" command. Successful execution of the "Copy RAM to Flash" or
"Erase Sector(s)" command causes relevant sectors to be protected again. To
prepare a single sector use the same "Start" and "End" sector numbers.*/
2022-05-19 08:57:38 -04:00
void iap_prepare_sectors(error_code* status, int start, int end);
void iap_erase_sectors(error_code* status, int start, int end);
2022-05-30 13:57:15 -04:00
void iap_copy_to_flash(error_code* status, long unsigned int * dst_flash, uint8_t* src_ram, int num_bytes);
2022-05-19 08:57:38 -04:00
uint32_t iap_read_part_id(error_code* status);
void iap_read_serial(error_code* status, uint32_t* res);
2022-05-30 13:57:15 -04:00
int addr_to_sector(unsigned long int addr);