main/task_sdcard.h

Sat, 20 Oct 2018 17:09:48 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 20 Oct 2018 17:09:48 +0200
changeset 1
ad2c8b13eb88
parent 0
b74b0e4902c3
child 4
6d1f512cd074
permissions
-rw-r--r--

Updated lots of doxygen comments

#ifndef	_TASK_SDCARD_H
#define	_TASK_SDCARD_H

/**
 * @file task_sdcard.h
 * @brief The interface to the FreeRTOS SD/MMC card task.
 */


/**
 * @brief Annotation types for the log graph.
 */
typedef enum
{
    ANNOTATION_STAGE = 0,		///< Annotate stage event
    ANNOTATION_EVENT,			///< Annotate an event
    ANNOTATION_SYSTEM,			///< Annotate a system event.
} ANNOTATION_TYPES;

/**
 * @brief Structure containing the information of the SD cards task.
 */
typedef struct {
    bool	host_ok;		///< SPI host is Ok.
    bool	card_present;		///< If card is present in the slot.
    char	logfile[32];		///< Current logfile name.
} SDCARD_State;

/**
 * @brief JSON log data
 */
typedef struct {
    char	time[9];		///< Time in the brew.
    float	mlt_sp;			///< MLT setpoint.
    float	mlt_pv;			///< MLT temperature.
    int		mlt_power;		///< MLT power in %
    int		mlt_tempreached;	///< MLT temperature reached (0 or 1).
    int		pump_run;		///< Pump run (0 or 1).
    float	hlt_sp;			///< HLT setpoint.
    float	hlt_pv;			///< HLT temperature.
    int		hlt_power;		///< HLT power in %.
    char	event[64];		///< Event message.
} JSON_log;

/**
 * @brief Begin a new logfile. The logfile is created and written to on
 *        the spiffs filesystem.
 * @param t The time in seconds since the Epoch, to create the filename.
 */
void log_begin(time_t t);

/**
 * @brief Close an open logfile. The logfile is moved to the SD card if
 *        the card is present and mounted. Then, the temporary logfile
 *        is removed.
 */
void log_close(void);

/**
 * @brief Clean logfile directory /spiffs/log/
 */
void log_clean(void);

/**
 * @brief Log to JSON logfile.
 */
void log_json(void);

/**
 * @brief Log annotations for the chart. These are stored in a temporary 
 *        file and later when the logfile is closed they are merged in 
 *        the main json logfile.
 * @param annotation_type The type of annotation, stage/event/system.
 * @param label The label text that will be seen in the chart.
 */
void log_annotation(int annotation_type, char *label);

/**
 * @brief Copy one file.
 * @param ff The from filename
 * @param tf The to filename
 * @return 0 if success.
 */
int FileCopy(char *ff, char *tf);

/**
 * @brief FreeRTOS sd card task. 
 */
void task_sdcard(void *);

#endif

mercurial