LCOV - code coverage report
Current view: top level - configuration - configuration.c (source / functions) Hit Total Coverage
Test: test-37de7e7-dirty-coverage.info Lines: 0 22 0.0 %
Date: 2019-04-16 Functions: 0 6 0.0 %

          Line data    Source code
       1             : /**
       2             :  * @ingroup configuration
       3             :  *
       4             :  * @file configuration.c
       5             :  *
       6             :  * @{
       7             :  */
       8             : 
       9             : #include "../firmware.h"
      10             : 
      11             : static void Configuration_save_to_eeprom(void);
      12             : static bool Configuration_load_from_eeprom(void);
      13             : static void Configuration_load_defaults(void);
      14             : static void Configuration_update_checksum(void);
      15             : 
      16           0 : void Configuration_Init(void)
      17             : {
      18           0 :   if(Configuration_load_from_eeprom() == false)
      19             :   {
      20             :     /* Load defaults and save EEPROM copy */
      21           0 :     Configuration_load_defaults();
      22           0 :     Configuration_save_to_eeprom();
      23             :   }
      24             : 
      25             : 
      26             : 
      27           0 : }
      28             : 
      29           0 : static void Configuration_save_to_eeprom(void)
      30             : {
      31           0 :   EEPROM_write(EEPROM_CONFIGURATION_DATA_ADDRESS, (uint32_t*)(&spacecraft_configuration), sizeof(configuration_t));
      32           0 : }
      33             : 
      34           0 : static bool Configuration_load_from_eeprom(void)
      35             : {
      36           0 :   if(EEPROM_selfTest() == false)
      37           0 :     return false;
      38             : 
      39           0 :   EEPROM_read(EEPROM_CONFIGURATION_DATA_ADDRESS, (uint32_t*)(&spacecraft_configuration), sizeof(configuration_t));
      40             : 
      41           0 :   return Configuration_verify_checksum();
      42             : }
      43             : 
      44           0 : bool Configuration_verify_checksum(void)
      45             : {
      46             :   uint16_t checksum;
      47             : 
      48           0 :   checksum = Util_crc16((uint8_t *)(&(spacecraft_configuration.data)), sizeof(configuration_data_t));
      49             : 
      50           0 :   return (checksum == spacecraft_configuration.checksum);
      51             : }
      52             : 
      53           0 : static void Configuration_load_defaults(void)
      54             : {
      55             :   /* Set defaults.. */
      56             : 
      57             : 
      58           0 :   Configuration_update_checksum();
      59           0 : }
      60             : 
      61           0 : static void Configuration_update_checksum(void)
      62             : {
      63           0 :   spacecraft_configuration.checksum = Util_crc16((uint8_t *)(&(spacecraft_configuration.data)), sizeof(configuration_data_t));
      64           0 : }
      65             : 
      66             : /**
      67             :  * @}
      68             :  */

Generated by: LCOV version 1.10