14 #define BUFFER_SLOT_SIZE (uint32_t)848
16 #if(FRAM_SIZE == 0x20000)
17 #define BUFFER_SLOTS 1210
18 #elif(FRAM_SIZE == 0x80000)
19 #define BUFFER_SLOTS 4840
21 #error "FRAM Size not coded for."
24 #define BUFFER_FRAM_SIZE_INITIALISED sizeof(bool)
25 #define BUFFER_FRAM_SIZE_LAST_INDEX sizeof(uint16_t)
26 #define BUFFER_FRAM_SIZE_LAST_SLOT sizeof(uint16_t)
27 #define BUFFER_FRAM_SIZE_OCCUPANCY ROUND_UP(BUFFER_SLOTS/8, 1)
28 #define BUFFER_FRAM_SIZE_INDEXES (BUFFER_SLOTS * sizeof(uint16_t))
29 #define BUFFER_FRAM_SIZE_CRC sizeof(uint16_t)
31 #define BUFFER_FRAM_ADDRESS_INITIALISED 0x000000
32 #define BUFFER_FRAM_ADDRESS_LAST_INDEX (BUFFER_FRAM_ADDRESS_INITIALISED + BUFFER_FRAM_SIZE_INITIALISED)
33 #define BUFFER_FRAM_ADDRESS_LAST_SLOT (BUFFER_FRAM_ADDRESS_LAST_INDEX + BUFFER_FRAM_SIZE_LAST_INDEX)
34 #define BUFFER_FRAM_ADDRESS_OCCUPANCY (BUFFER_FRAM_ADDRESS_LAST_SLOT + BUFFER_FRAM_SIZE_LAST_SLOT)
35 #define BUFFER_FRAM_ADDRESS_INDEXES (BUFFER_FRAM_ADDRESS_OCCUPANCY + BUFFER_FRAM_SIZE_OCCUPANCY)
36 #define BUFFER_FRAM_ADDRESS_CRC (BUFFER_FRAM_ADDRESS_INDEXES + BUFFER_FRAM_SIZE_INDEXES)
37 #define BUFFER_FRAM_ADDRESS_SLOTS (BUFFER_FRAM_ADDRESS_CRC + BUFFER_FRAM_SIZE_CRC)
50 uint16_t last_index_stored;
51 uint16_t last_slot_transmitted;
52 uint8_t occupancy[ROUND_UP(BUFFER_SLOTS/8, 1)];
53 uint16_t indexes[BUFFER_SLOTS];
57 void Buffer_init(
void);
58 void Buffer_reset(
void);
59 bool Buffer_verify_cache(
void);
61 void Buffer_store_new_data(uint8_t *data_payload);
62 bool Buffer_get_next_data(uint8_t *data_payload);
63 void Buffer_remove_index(uint16_t index);
64 uint16_t Buffer_count_occupied(
void);
67 bool Buffer_get_next_slot(uint16_t *slot);
68 bool Buffer_find_index(uint16_t index, uint16_t *slot);
69 void Buffer_find_new_slot(uint16_t *slot);
70 void Buffer_find_oldest_slot(uint16_t *slot);
71 bool Buffer_get_occupancy(uint16_t slot);
72 void Buffer_set_occupancy(uint16_t slot,
bool value);
73 void Buffer_set_index(uint16_t slot, uint16_t index);
76 void Buffer_FRAM_read_data(uint16_t slot, uint8_t *data);
79 void Buffer_FRAM_write_last_slot_transmitted(
buffer_cache_t *buffer);
82 void Buffer_FRAM_write_data(uint16_t slot, uint8_t *data);