* Add send scs

* Create scs dict

* Fix compilation errors

* Fix compile error

* Change default include

* Add Timer SCS manager

* Remove unused files

* Fix bugs

* Add documentation

* Add SCS manager

bozza

* Refactor

* Use same naming convention

* Add tick provider

* Update header

* Fix header bit translation

* Test HandleNext OK

* Remove linting

* Remove indents

* Add documentation

* Improve docs

* Remove pointer

* Remove mailbox

* Remove useless comment

* Add newline

* Fix compile errors

* Separate scs entries from manager

* Refactor

* Fix include guards

Co-authored-by: nicolagutierrez <nicolagutierrez.ng@gmail.com>
This commit was merged in pull request #3.
This commit is contained in:
Stefano Calabretti
2022-02-23 21:08:47 +01:00
committed by GitHub
parent 7aa61ed9ad
commit 4d5c1934a4
20 changed files with 717 additions and 313 deletions
+60
View File
@@ -0,0 +1,60 @@
#include "mmr_can_scs.h"
#define EMPTY_HEADER ((MmrCanHeader){})
#define EMPTY_ENTRY ((MmrCanScsEntry){})
static MmrCanScsEntry __scsEntries[MMR_CAN_SCS_ENTRIES_COUNT];
MmrCanScsEntry* MMR_CAN_GetNextScsEntry() {
static int counter = 0;
MmrCanScsEntry *entry = __scsEntries + counter;
counter++;
counter %= MMR_CAN_SCS_ENTRIES_COUNT;
return entry;
}
MmrCanScsEntry* MMR_CAN_PutScsEntry(MmrCanHeader header) {
MmrCanScsEntry *entry = MMR_CAN_FindScsEntry(EMPTY_HEADER);
if (entry == NULL) {
return NULL;
}
*entry = (MmrCanScsEntry){
.header = header,
.counter = MMR_CAN_GetCurrentTick(),
};
return entry;
}
MmrCanScsEntry* MMR_CAN_ClearScsEntry(MmrCanHeader header) {
MmrCanScsEntry *entry = MMR_CAN_FindScsEntry(header);
if (entry == NULL) {
return NULL;
}
*entry = EMPTY_ENTRY;
return entry;
}
MmrCanScsEntry* MMR_CAN_FindScsEntry(MmrCanHeader header) {
uint32_t target = MMR_CAN_HeaderToBits(header);
uint32_t i = 0;
for (; i < MMR_CAN_SCS_ENTRIES_COUNT; i++) {
MmrCanScsEntry *entry = __scsEntries + i;
uint32_t curr = MMR_CAN_HeaderToBits(entry->header);
if (curr == target) {
return entry;
}
}
return NULL;
}