rec to sd card
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
#ifdef HAL_IMPL
|
||||
#include "uart_fifos.h"
|
||||
#include "param_pre.h"
|
||||
#include "fatfs.h"
|
||||
#endif
|
||||
/* %%%-SFUNWIZ_wrapper_includes_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
#define y_width 1
|
||||
@@ -23,53 +22,25 @@
|
||||
*
|
||||
*/
|
||||
/* %%%-SFUNWIZ_wrapper_externs_Changes_BEGIN --- EDIT HERE TO _END */
|
||||
int is_fat_rec_init = 0;
|
||||
FIL *rec_pf;
|
||||
#define REC_ZONE_LEN (2000)
|
||||
extern uint8_t rec_zone[2][REC_ZONE_LEN];
|
||||
extern int rec_sel;
|
||||
extern int rec_head[2];
|
||||
|
||||
static int FAT_REC_write(uint8_t *buff, const uint16_t len)
|
||||
{
|
||||
int rslt;
|
||||
FRESULT res;
|
||||
if (is_fat_rec_init == 1)
|
||||
if (rec_head[rec_sel] < REC_ZONE_LEN)
|
||||
{
|
||||
UINT bw;
|
||||
res = f_write(rec_pf, buff, len, &bw);
|
||||
f_sync(rec_pf);
|
||||
if (res != FR_OK)
|
||||
for (int i=0u;i<len;++i)
|
||||
{
|
||||
rslt = -1;
|
||||
}
|
||||
else
|
||||
rec_zone[rec_sel][rec_head[rec_sel]++] = buff[i];
|
||||
if (rec_head[rec_sel] >= REC_ZONE_LEN)
|
||||
{
|
||||
rslt = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (is_fat_rec_init == 0 && ap_U.sens.gps_fixtype >= ENUM_GPS_FIXTYPE_FIX_2D)
|
||||
{
|
||||
res = f_mount(&SDFatFS, SDPath, 1);
|
||||
if (res != FR_OK)
|
||||
{
|
||||
is_fat_rec_init = -1;
|
||||
rslt = -1;
|
||||
}
|
||||
rec_pf = &SDFile;
|
||||
long path_len;
|
||||
char path[80];
|
||||
strncpy(path, SDPath, 3);
|
||||
sprintf(&path[3], "R%d.dat", (ap_U.sens.TOW / 1000));
|
||||
res = f_open(rec_pf, path, FA_OPEN_ALWAYS | FA_WRITE);
|
||||
if (res == FR_OK)
|
||||
{
|
||||
is_fat_rec_init = 1;
|
||||
rslt = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
is_fat_rec_init = -1;
|
||||
rslt = -1;
|
||||
}
|
||||
}
|
||||
return rslt;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */
|
||||
|
||||
Reference in New Issue
Block a user