Merge branch 'scs' of https://github.com/mmr-driverless/mmr_can into scs
This commit is contained in:
@@ -22,7 +22,7 @@ typedef enum {
|
||||
MMR_CAN_MESSAGE_ACK = B_(0001),
|
||||
MMR_CAN_MESSAGE_TYPE_MULTI_FRAME = B_(0010),
|
||||
MMR_CAN_MESSAGE_TYPE_MULTI_FRAME_END = B_(0011),
|
||||
MMR_CAN_MESSAGE_TYPE_NORMAL = B_(1000),
|
||||
MMR_CAN_MESSAGE_TYPE_NORMAL = B_(0100),
|
||||
} MmrCanMessageType;
|
||||
|
||||
|
||||
@@ -40,9 +40,10 @@ typedef enum {
|
||||
*/
|
||||
typedef struct {
|
||||
MmrCanMessagePriority priority : 3;
|
||||
MmrCanMessageId messageId : 10;
|
||||
uint32_t senderId : 12;
|
||||
MmrCanMessageType messageType : 4;
|
||||
uint16_t messageId : 10;
|
||||
uint16_t senderId : 10;
|
||||
uint8_t seqNumber : 3;
|
||||
MmrCanMessageType messageType : 3;
|
||||
} MmrCanHeader;
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef INC_MMR_CAN_MESSAGE_ID_H_
|
||||
#define INC_MMR_CAN_MESSAGE_ID_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "mmr_can_binary_literals.h"
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#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_
|
||||
@@ -5,11 +5,6 @@ You can add this library to your project by either cloning it or adding it as a
|
||||
---
|
||||
|
||||
### Add as a submodule (recommended)
|
||||
You can add the library to an existing STM32 project if you've already initialized it with a git repository
|
||||
|
||||
To create a git repository, simply run `git init` inside the main project folder<br>
|
||||
You will then be able to link it to a remote repository (like github) by running `git remote add origin repo_url`
|
||||
|
||||
To **add mmr_can as a submodule**, go into your project folder and run
|
||||
```
|
||||
git submodule add https://github.com/mmr-driverless/mmr_can.git Drivers/MMR_CAN
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user