Scs #3

Merged
cala-br merged 32 commits from scs into master 2022-02-23 21:08:47 +01:00
2 changed files with 0 additions and 57 deletions
Showing only changes of commit f6d5dca5ee - Show all commits
-27
View File
@@ -1,27 +0,0 @@
#ifndef INC_MMR_CAN_SCS_H_
#define INC_MMR_CAN_SCS_H_
#ifndef MMR_CAN_SCS_DICTIONARY_SIZE
#define MMR_CAN_SCS_DICTIONARY_SIZE 5
#endif
#include <stdint.h>
#include "mmr_can.h"
typedef struct {
uint32_t key;
uint32_t delayStart;
} MmrCanScsDictEntry;
typedef MmrCanScsDictEntry MmrCanScsDictionary[MMR_CAN_SCS_DICTIONARY_SIZE];
typedef void(*MmrCanScsDictAction)(MmrCanScsDictEntry *entry);
void MMR_CAN_ScsDictPut(MmrCanScsDictEntry entry);
void MMR_CAN_ScsDictRemove(uint32_t key);
void MMR_CAN_ScsDictForeach(MmrCanScsDictAction action);
uint32_t MMR_CAN_ScsGetKey(MmrCanMessage *message);
#endif // !INC_MMR_CAN_SCS_H_
-30
View File
@@ -1,30 +0,0 @@
#include "mmr_can_scs_dict.h"
static MmrCanScsDictionary _dictionary;
void MMR_CAN_ScsDictPut(MmrCanScsDictEntry entry) {
_dictionary[entry.key % MMR_CAN_SCS_DICTIONARY_SIZE] = entry;
}
void MMR_CAN_ScsDictRemove(uint32_t key) {
_dictionary[key] = (MmrCanScsDictEntry){};
}
void MMR_CAN_ScsDictForeach(MmrCanScsDictAction action) {
int i = 0;
for (; i < MMR_CAN_SCS_DICTIONARY_SIZE; i++) {
MmrCanScsDictEntry entry = _dictionary[i];
if (entry.key != 0) {
action(&entry);
}
}
}
uint32_t MMR_CAN_ScsMessageAsKey(MmrCanMessage *message) {
uint16_t upperHalf = message->header.messageId;
uint16_t lowerHalf = message->header.messageType;
return (upperHalf << 16) | lowerHalf;
}