LCOV - code coverage report
Current view: top level - buffer - buffer_fram.c (source / functions) Hit Total Coverage
Test: test-37de7e7-dirty-coverage.info Lines: 30 31 96.8 %
Date: 2019-04-16 Functions: 8 8 100.0 %

          Line data    Source code
       1             : /**
       2             :  * @ingroup buffer
       3             :  *
       4             :  * @file buffer_fram.c
       5             :  *
       6             :  * @{
       7             :  */
       8             : 
       9             : #include "../firmware.h"
      10             : 
      11             : /*** Read ***/
      12             : 
      13           1 : bool Buffer_FRAM_cache_read(buffer_cache_t *buffer)
      14             : {
      15           1 :   FRAM_read(0x00000000, (uint8_t *)buffer, sizeof(buffer_cache_t));
      16             : 
      17           1 :   if(buffer->crc == Util_crc16((uint8_t *)&buffer, sizeof(buffer_cache_t) - sizeof(uint16_t)))
      18             :   {
      19           0 :     return true;
      20             :   }
      21           1 :   return false;
      22             : }
      23             : 
      24           7 : void Buffer_FRAM_read_data(uint16_t slot, uint8_t *data)
      25             : {
      26           7 :   FRAM_read((uint32_t)(BUFFER_FRAM_ADDRESS_SLOTS + (slot * BUFFER_SLOT_SIZE)), data, BUFFER_SLOT_SIZE);
      27           7 : }
      28             : 
      29             : /*** Write ***/
      30             : 
      31        4870 : static inline void Buffer_FRAM_update_crc(buffer_cache_t *buffer)
      32             : {
      33        4870 :   buffer->crc = Util_crc16((uint8_t *)&buffer, sizeof(buffer_cache_t) - sizeof(uint16_t));
      34        4870 :   FRAM_write(BUFFER_FRAM_ADDRESS_CRC, (uint8_t *)&(buffer->crc), BUFFER_FRAM_SIZE_CRC);
      35        4870 : }
      36             : 
      37           5 : void Buffer_FRAM_write_last_index_stored(buffer_cache_t *buffer)
      38             : {
      39           5 :   FRAM_write(BUFFER_FRAM_ADDRESS_LAST_INDEX, (uint8_t *)&(buffer->last_index_stored), sizeof(buffer->last_index_stored));
      40           5 :   Buffer_FRAM_update_crc(buffer);
      41           5 : }
      42             : 
      43           5 : void Buffer_FRAM_write_last_slot_transmitted(buffer_cache_t *buffer)
      44             : {
      45           5 :   FRAM_write(BUFFER_FRAM_ADDRESS_LAST_SLOT, (uint8_t *)&(buffer->last_slot_transmitted), sizeof(buffer->last_slot_transmitted));
      46           5 :   Buffer_FRAM_update_crc(buffer);
      47           5 : }
      48             : 
      49        2431 : void Buffer_FRAM_write_occupancy(buffer_cache_t *buffer)
      50             : {
      51        2431 :   FRAM_write(BUFFER_FRAM_ADDRESS_OCCUPANCY, (uint8_t *)&(buffer->occupancy), sizeof(buffer->occupancy));
      52        2431 :   Buffer_FRAM_update_crc(buffer);
      53        2431 : }
      54             : 
      55        2429 : void Buffer_FRAM_write_indexes(buffer_cache_t *buffer)
      56             : {
      57        2429 :   FRAM_write(BUFFER_FRAM_ADDRESS_INDEXES, (uint8_t *)&(buffer->indexes), sizeof(buffer->indexes));
      58        2429 :   Buffer_FRAM_update_crc(buffer);
      59        2429 : }
      60             : 
      61        2424 : void Buffer_FRAM_write_data(uint16_t slot, uint8_t *data)
      62             : {
      63        2424 :   FRAM_write((uint32_t)(BUFFER_FRAM_ADDRESS_SLOTS + (slot * BUFFER_SLOT_SIZE)), data, BUFFER_SLOT_SIZE);
      64        2424 : }
      65             : 
      66             : /**
      67             :  * @}
      68             :  */

Generated by: LCOV version 1.10