save writeback led blink

This commit is contained in:
Mateusz Faderewski 2024-01-14 06:55:39 +01:00
parent 54cca66e0e
commit 7d2ebb873e
2 changed files with 15 additions and 3 deletions

View File

@ -7,7 +7,7 @@
#define LED_REFRESH_PERIOD_MS (50) #define LED_REFRESH_PERIOD_MS (50)
#define LED_PULSE_LENGTH_MS (500) #define LED_PULSE_LENGTH_MS (200)
#define ERROR_BLINK_PERIOD_MS (100) #define ERROR_BLINK_PERIOD_MS (100)
#define ERROR_TOTAL_PERIOD_MS (1000) #define ERROR_TOTAL_PERIOD_MS (1000)

View File

@ -1,5 +1,6 @@
#include "cfg.h" #include "cfg.h"
#include "fpga.h" #include "fpga.h"
#include "led.h"
#include "sd.h" #include "sd.h"
#include "timer.h" #include "timer.h"
#include "usb.h" #include "usb.h"
@ -81,9 +82,14 @@ static void writeback_save_to_sd (void) {
return; return;
} }
if(sd_optimize_sectors(address, p.sectors, length / SD_SECTOR_SIZE, sd_write_sectors)) { bool error = sd_optimize_sectors(address, p.sectors, length / SD_SECTOR_SIZE, sd_write_sectors);
if (error) {
writeback_disable(); writeback_disable();
return;
} }
led_activity_pulse();
} }
static bool writeback_save_to_usb (void) { static bool writeback_save_to_usb (void) {
@ -103,7 +109,13 @@ static bool writeback_save_to_usb (void) {
packet_info.data[0] = save; packet_info.data[0] = save;
packet_info.dma_length = length; packet_info.dma_length = length;
packet_info.dma_address = address; packet_info.dma_address = address;
return usb_enqueue_packet(&packet_info); bool enqueued = usb_enqueue_packet(&packet_info);
if (enqueued) {
led_activity_pulse();
}
return enqueued;
} }