ENTS-tock
Environmental NeTworked Sensor firmware on Tock OS
Loading...
Searching...
No Matches
user_config.c File Reference
#include "user_config.h"
#include <stdio.h>
#include "./proto/transcoder.h"
#include "./storage/fram.h"

Go to the source code of this file.

Functions

UserConfigStatus UserConfig_WriteToFRAM (uint16_t addr, uint8_t *data, uint16_t length)
 Writes user configuration data to FRAM.
 
UserConfigStatus UserConfig_ReadFromFRAM (uint16_t addr, uint16_t length, uint8_t *data)
 Reads user configuration data from FRAM.
 
UserConfigStatus UserConfigBytes (uint8_t *buffer, uint16_t *length)
 Gets encoded bytes from userconfig.
 
UserConfigStatus UserConfigLoadBytes (uint8_t *buffer, uint16_t length)
 Load user config from bytes.
 
UserConfigStatus UserConfigLoad (void)
 Loads user configuration data from FRAM to RAM.
 
const UserConfiguration * UserConfigGet (void)
 Gets a reference to the loaded user configuration data in RAM.
 
UserConfigStatus UserConfigSave (const UserConfiguration *config)
 Saves the configuration to FRAM.
 
void UserConfigPrintAny (const UserConfiguration *config)
 Prints arbitrary user config over serial.
 
void UserConfigPrint (void)
 Prints the current user configuration over serial.
 
UserConfigStatus UserConfigClear (void)
 Clears the user configuration stored in FRAM.
 

Function Documentation

◆ UserConfig_ReadFromFRAM()

UserConfigStatus UserConfig_ReadFromFRAM ( uint16_t  addr,
uint16_t  length,
uint8_t *  data 
)

Reads user configuration data from FRAM.

This function reads a specified amount of user configuration data from the FRAM memory starting at a specified address.

Parameters
addrStarting address in FRAM to read data from.
lengthLength of the data to be read.
dataPointer to the buffer to store the read data.
Returns
USERCONFIG_OK if successful, error code otherwise.

Definition at line 69 of file user_config.c.

References data, FRAM_OK, fram_read(), USERCONFIG_FRAM_ERROR, and USERCONFIG_OK.

Referenced by UserConfigBytes().

◆ UserConfig_WriteToFRAM()

UserConfigStatus UserConfig_WriteToFRAM ( uint16_t  addr,
uint8_t *  data,
uint16_t  length 
)

Writes user configuration data to FRAM.

This function writes a specified amount of user configuration data to the FRAM memory starting at a specified address.

Parameters
addrStarting address in FRAM to write data.
dataPointer to the data to be written.
lengthLength of the data to be written.
Returns
USERCONFIG_OK if successful, error code otherwise.

Definition at line 59 of file user_config.c.

References data, FRAM_OK, fram_write(), USERCONFIG_FRAM_ERROR, and USERCONFIG_OK.

Referenced by UserConfigSave().