Better parameter handling (#6)

* Add rx event handlers

* Fix compile errors and add constness

* Pass sender id

* Change api interface

* Revert changes

* Add filter fifo

* Add default setup

* Add receive function

* Remove interrupt activation

* Activate RX interrupts

* Merge remote changes

* Add event list constructor

* Fix compilation bug

* Send and receive multiple frames

* Refactor

* Refactor

* Fix compile error

* Use known syntax

* Refactor

* Provide storage

* Add frame end

* Add some documentation

* Turn macros into functions

* Refactor

* Refactor

* Fix compile error

* Use ExtendedIds

* Fix reception bug (fixes #4)

* Add packet headers

* Refactor

Co-authored-by: Riccardo998 <riccardo.storchi98@gmail.com>
This commit is contained in:
Stefano Calabretti
2021-12-20 15:12:57 +01:00
committed by GitHub
parent c0cc853cf8
commit ed2a26fbc9
8 changed files with 147 additions and 73 deletions
+6 -21
View File
@@ -1,9 +1,13 @@
#include "mmr_can.h"
#include "mmr_can_util.h"
static uint8_t maskIdLower5Bits(CanRxHeader *header);
/**
* @brief
* Initializes the filter using the values
* from MMR_CAN_GetDefaultFilterSettings, and then
* starts the CAN
*/
HalStatus MMR_CAN_BasicSetupAndStart(CanHandle *hcan) {
return
MMR_CAN_FilterConfigDefault(hcan) |
@@ -31,12 +35,6 @@ HalStatus MMR_CAN_FilterConfig(CanHandle *hcan, MmrCanFilterSettings settings) {
}
CanFilterMask MMR_CAN_AlignStandardMask(CanFilterMask baseMask) {
static const uint8_t extendedMaskSurplusBytes = 5;
return baseMask << extendedMaskSurplusBytes;
}
MmrCanFilterSettings MMR_CAN_GetDefaultFilterSettings() {
return (MmrCanFilterSettings) {
.enabled = true,
@@ -46,16 +44,3 @@ MmrCanFilterSettings MMR_CAN_GetDefaultFilterSettings() {
.slaveBankStart = 14,
};
}
bool MMR_CAN_IsMultiFrame(CanRxHeader *header) {
return maskIdLower5Bits(header) == MMR_CAN_MESSAGE_TYPE_MULTI_FRAME;
}
bool MMR_CAN_IsMultiFrameEnd(CanRxHeader *header) {
return maskIdLower5Bits(header) == MMR_CAN_MESSAGE_TYPE_MULTI_FRAME_END;
}
static always_inline uint8_t maskIdLower5Bits(CanRxHeader *header) {
return mask(header->ExtId, B8_(0001, 1111));
}