PER Firmware
Loading...
Searching...
No Matches
sd_card.c File Reference

Logging of received bus messages onto an SD card. More...

#include "sd_card.h"
#include <stdio.h>
#include "common/rtos/rtos.h"
#include "common/phal_F4/gpio/gpio.h"
#include "common/phal_F4/rtc/rtc.h"
#include "common/sdio/sdio.h"
#include "external/fatfs/ff.h"
#include "main.h"
#include "spmc.h"
Include dependency graph for sd_card.c:

Functions

static void get_next_filename (char *buffer, size_t buffer_size)
 
static void release_resources ()
 
void sd_power_loss_callback (void)
 
void sd_card_periodic (void)
 

Variables

static constexpr uint32_t SD_NEW_FILE_PERIOD_MS = 1 * 60 * 1000
 
static sd_state_t sd_state = SD_STATE_DISABLED
 
static sd_state_t next_sd_state = SD_STATE_DISABLED
 
static FATFS fat_fs
 
static FIL file_object
 
static bool is_file_open = false
 
static bool is_fs_mounted = false
 
static int recovery_attempts = 0
 
static uint32_t last_open_time_ms = 0
 

Detailed Description

Logging of received bus messages onto an SD card.

Author
Irving Wang (irvin.nosp@m.gw@p.nosp@m.urdue.nosp@m..edu)

Function Documentation

◆ get_next_filename()

static void get_next_filename ( char * buffer,
size_t buffer_size )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ release_resources()

static void release_resources ( )
static
Here is the caller graph for this function:

◆ sd_card_periodic()

void sd_card_periodic ( void )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sd_power_loss_callback()

void sd_power_loss_callback ( void )
Here is the call graph for this function:

Variable Documentation

◆ fat_fs

FATFS fat_fs
static

◆ file_object

FIL file_object
static

◆ is_file_open

bool is_file_open = false
static

◆ is_fs_mounted

bool is_fs_mounted = false
static

◆ last_open_time_ms

uint32_t last_open_time_ms = 0
static

◆ next_sd_state

sd_state_t next_sd_state = SD_STATE_DISABLED
static

◆ recovery_attempts

int recovery_attempts = 0
static

◆ SD_NEW_FILE_PERIOD_MS

uint32_t SD_NEW_FILE_PERIOD_MS = 1 * 60 * 1000
staticconstexpr

◆ sd_state

sd_state_t sd_state = SD_STATE_DISABLED
static