regular backup
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "packet.hpp"
|
||||
#include "usbd_cdc_if.h"
|
||||
#include "fatfs.h"
|
||||
#include "usart.h"
|
||||
#include "usbd_cdc_if.h"
|
||||
#include "packet.hpp"
|
||||
|
||||
extern uint8_t databank1[1024];
|
||||
extern uint8_t databank2[1024];
|
||||
@@ -10,6 +11,8 @@ extern uint16_t pos;
|
||||
|
||||
volatile extern bool usb_ready;
|
||||
volatile extern bool wb1mmc_ready;
|
||||
volatile extern bool sd_ready;
|
||||
extern FIL file;
|
||||
|
||||
// Every time we get a reading add to the active databank if it fits,
|
||||
// if not we switch banks and write out the now unactive databank
|
||||
@@ -29,6 +32,12 @@ void write(packet_type packet) {
|
||||
HAL_UART_Transmit_DMA(&huart1, databank1, sizeof(databank1));
|
||||
wb1mmc_ready = false;
|
||||
}
|
||||
if (sd_ready) {
|
||||
UINT bytes_written;
|
||||
FRESULT res = f_write(&file, databank1, sizeof(databank1), &bytes_written);
|
||||
if (res != FR_OK || bytes_written != sizeof(databank1)) {}
|
||||
}
|
||||
|
||||
memset(databank2, 0, sizeof(databank2));
|
||||
pos = sizeof(databank1);
|
||||
return write(packet);
|
||||
@@ -47,6 +56,11 @@ void write(packet_type packet) {
|
||||
HAL_UART_Transmit_DMA(&huart1, databank2, sizeof(databank2));
|
||||
wb1mmc_ready = false;
|
||||
}
|
||||
if (sd_ready) {
|
||||
UINT bytes_written;
|
||||
FRESULT res = f_write(&file, databank2, sizeof(databank2), &bytes_written);
|
||||
if (res != FR_OK || bytes_written != sizeof(databank2)) {}
|
||||
}
|
||||
memset(databank1, 0, sizeof(databank1));
|
||||
pos = 0;
|
||||
return write(packet);
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
|
||||
void data_description();
|
||||
void data_description(bool to_usb, bool to_file);
|
||||
|
||||
@@ -66,6 +66,8 @@ void SPI1_IRQHandler(void);
|
||||
void USART1_IRQHandler(void);
|
||||
void SDMMC1_IRQHandler(void);
|
||||
void TIM6_DAC_IRQHandler(void);
|
||||
void DMA2_Channel4_IRQHandler(void);
|
||||
void DMA2_Channel5_IRQHandler(void);
|
||||
void USB_IRQHandler(void);
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user