little cleanup

This commit is contained in:
Polprzewodnikowy 2022-08-03 14:05:54 +02:00
parent 568a343b2e
commit 9dd8fc7445
4 changed files with 25 additions and 16 deletions

View File

@ -8,6 +8,7 @@ SRC_FILES = \
fpga.c \
hw.c \
lcmxo2.c \
loader_main.c
loader_main.c \
update.c
include common.mk

View File

@ -1,12 +1,10 @@
#include <stdint.h>
#include "fpga.h"
#include "hw.h"
#include "vendor.h"
#include "update.h"
void loader_main (void) {
uint32_t parameters[5];
uint64_t buffer;
hw_loader_get_parameters(parameters);
@ -16,18 +14,7 @@ void loader_main (void) {
hw_gpio_set(GPIO_ID_LED);
if (parameters[2] != 0) {
hw_flash_erase();
for (int i = 0; i < parameters[2]; i += sizeof(buffer)) {
fpga_mem_read(parameters[1] + i, sizeof(buffer), (uint8_t *) (&buffer));
hw_flash_program(HW_FLASH_ADDRESS + i, buffer);
}
}
if (parameters[4] != 0) {
vendor_update(parameters[3], parameters[4]);
vendor_reconfigure();
}
update_perform(parameters);
hw_gpio_reset(GPIO_ID_LED);

View File

@ -1,7 +1,9 @@
#include <stdint.h>
#include "fpga.h"
#include "hw.h"
#include "update.h"
#include "usb.h"
#include "vendor.h"
static uint32_t update_mcu_address;
@ -35,6 +37,24 @@ void update_start (void) {
hw_loader_reset(parameters);
}
void update_perform (uint32_t *parameters) {
uint64_t buffer;
if (parameters[2] != 0) {
hw_flash_erase();
for (int i = 0; i < parameters[2]; i += sizeof(buffer)) {
fpga_mem_read(parameters[1] + i, sizeof(buffer), (uint8_t *) (&buffer));
hw_flash_program(HW_FLASH_ADDRESS + i, buffer);
}
}
if (parameters[4] != 0) {
vendor_update(parameters[3], parameters[4]);
}
vendor_reconfigure();
}
void update_notify_done (void) {
uint32_t parameters[5];
usb_tx_info_t packet;

View File

@ -15,6 +15,7 @@ typedef enum {
uint32_t update_backup (uint32_t address);
update_error_t update_prepare (uint32_t address, uint32_t length);
void update_start (void);
void update_perform (uint32_t *parameters);
void update_notify_done (void);