From 37a47f494853fcb7365d9d8d0fe078250fd26a60 Mon Sep 17 00:00:00 2001
From: Stefano Calabretti <45517710+cala-br@users.noreply.github.com>
Date: Sat, 29 Jan 2022 20:01:33 +0100
Subject: [PATCH 1/4] Create README.md
---
README.md | 5 -----
1 file changed, 5 deletions(-)
diff --git a/README.md b/README.md
index 7162571..0f18a8b 100644
--- a/README.md
+++ b/README.md
@@ -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
-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
From f7b5c0315eeba7300b96071cb556c4846cacbeae Mon Sep 17 00:00:00 2001
From: Stefano Calabretti
Date: Thu, 3 Feb 2022 18:55:52 +0100
Subject: [PATCH 2/4] Create scs dict
---
Inc/mmr_can_scs_dict.h | 27 +++++++++++++++++++++++++++
Src/mmr_can_scs_dict.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 57 insertions(+)
create mode 100644 Inc/mmr_can_scs_dict.h
create mode 100644 Src/mmr_can_scs_dict.c
diff --git a/Inc/mmr_can_scs_dict.h b/Inc/mmr_can_scs_dict.h
new file mode 100644
index 0000000..c9fde57
--- /dev/null
+++ b/Inc/mmr_can_scs_dict.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
+#include "mmr_can.h"
+
+
+typedef struct {
+ uint32_t key;
+ uint32_t delayStart;
+} MmrCanScsDictEntry;
+
+typedef MmrCanScsDictEntry MmrCanScsDictionary[MMR_SCS_DICTIONARY_SIZE];
+typedef void(*MmrCanScsDictAction)(MmrCanScsDictEntry *entry);
+
+
+uint32_t 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_
diff --git a/Src/mmr_can_scs_dict.c b/Src/mmr_can_scs_dict.c
new file mode 100644
index 0000000..e40ad36
--- /dev/null
+++ b/Src/mmr_can_scs_dict.c
@@ -0,0 +1,30 @@
+#include "mmr_can_scs.h"
+
+static MmrCanScsDictionary _dictionary;
+
+
+uint32_t MMR_CAN_ScsDictPut(MmrCanScsDictEntry entry) {
+ _dictionary[entry.key % MMR_CAN_SCS_DICTIONARY_SIZE] = entry.delayStart;
+}
+
+void MMR_CAN_ScsDictRemove(uint32_t key) {
+ _dictionary[key] = {};
+}
+
+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;
+}
\ No newline at end of file
From e4a0988111db0573e8cf921341b436211148ff81 Mon Sep 17 00:00:00 2001
From: Stefano Calabretti
Date: Thu, 3 Feb 2022 19:29:58 +0100
Subject: [PATCH 3/4] Fix compilation errors
---
Inc/mmr_can_header.h | 9 +++++----
Inc/mmr_can_message_id.h | 1 +
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/Inc/mmr_can_header.h b/Inc/mmr_can_header.h
index 7a5cf88..7e22dcf 100644
--- a/Inc/mmr_can_header.h
+++ b/Inc/mmr_can_header.h
@@ -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;
diff --git a/Inc/mmr_can_message_id.h b/Inc/mmr_can_message_id.h
index 68d1082..e41740d 100644
--- a/Inc/mmr_can_message_id.h
+++ b/Inc/mmr_can_message_id.h
@@ -1,6 +1,7 @@
#ifndef INC_MMR_CAN_MESSAGE_ID_H_
#define INC_MMR_CAN_MESSAGE_ID_H_
+#include
#include
#include "mmr_can_binary_literals.h"
From 92b6ca84953749669e0b7a9745a1c721b733d86a Mon Sep 17 00:00:00 2001
From: Stefano Calabretti
Date: Thu, 3 Feb 2022 19:35:39 +0100
Subject: [PATCH 4/4] Fix compile error
---
Inc/mmr_can_scs_dict.h | 4 ++--
Src/mmr_can_scs_dict.c | 10 +++++-----
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/Inc/mmr_can_scs_dict.h b/Inc/mmr_can_scs_dict.h
index c9fde57..9999226 100644
--- a/Inc/mmr_can_scs_dict.h
+++ b/Inc/mmr_can_scs_dict.h
@@ -14,11 +14,11 @@ typedef struct {
uint32_t delayStart;
} MmrCanScsDictEntry;
-typedef MmrCanScsDictEntry MmrCanScsDictionary[MMR_SCS_DICTIONARY_SIZE];
+typedef MmrCanScsDictEntry MmrCanScsDictionary[MMR_CAN_SCS_DICTIONARY_SIZE];
typedef void(*MmrCanScsDictAction)(MmrCanScsDictEntry *entry);
-uint32_t MMR_CAN_ScsDictPut(MmrCanScsDictEntry entry);
+void MMR_CAN_ScsDictPut(MmrCanScsDictEntry entry);
void MMR_CAN_ScsDictRemove(uint32_t key);
void MMR_CAN_ScsDictForeach(MmrCanScsDictAction action);
diff --git a/Src/mmr_can_scs_dict.c b/Src/mmr_can_scs_dict.c
index e40ad36..e22a605 100644
--- a/Src/mmr_can_scs_dict.c
+++ b/Src/mmr_can_scs_dict.c
@@ -1,14 +1,14 @@
-#include "mmr_can_scs.h"
+#include "mmr_can_scs_dict.h"
static MmrCanScsDictionary _dictionary;
-uint32_t MMR_CAN_ScsDictPut(MmrCanScsDictEntry entry) {
- _dictionary[entry.key % MMR_CAN_SCS_DICTIONARY_SIZE] = entry.delayStart;
+void MMR_CAN_ScsDictPut(MmrCanScsDictEntry entry) {
+ _dictionary[entry.key % MMR_CAN_SCS_DICTIONARY_SIZE] = entry;
}
void MMR_CAN_ScsDictRemove(uint32_t key) {
- _dictionary[key] = {};
+ _dictionary[key] = (MmrCanScsDictEntry){};
}
void MMR_CAN_ScsDictForeach(MmrCanScsDictAction action) {
@@ -27,4 +27,4 @@ uint32_t MMR_CAN_ScsMessageAsKey(MmrCanMessage *message) {
uint16_t lowerHalf = message->header.messageType;
return (upperHalf << 16) | lowerHalf;
-}
\ No newline at end of file
+}