This repository has been archived on 2026-02-22. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
can/Src/mmr_can.c
T
Stefano Calabretti ed2a26fbc9 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>
2021-12-20 15:12:57 +01:00

47 lines
1.0 KiB
C

#include "mmr_can.h"
#include "mmr_can_util.h"
/**
* @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) |
HAL_CAN_Start(hcan)
;
}
HalStatus MMR_CAN_FilterConfig(CanHandle *hcan, MmrCanFilterSettings settings) {
CanFilter filter = {
.FilterActivation = settings.enabled
? CAN_FILTER_ENABLE
: CAN_FILTER_DISABLE,
.FilterIdHigh = settings.idMask,
.FilterMaskIdHigh = settings.idMask,
.FilterFIFOAssignment = settings.fifo,
.FilterBank = settings.bank,
.SlaveStartFilterBank = settings.slaveBankStart,
.FilterMode = CAN_FILTERMODE_IDMASK,
.FilterScale = CAN_FILTERSCALE_32BIT,
};
return HAL_CAN_ConfigFilter(hcan, &filter);
}
MmrCanFilterSettings MMR_CAN_GetDefaultFilterSettings() {
return (MmrCanFilterSettings) {
.enabled = true,
.fifo = MMR_CAN_FILTER_FIFO,
.idMask = 0,
.bank = 0,
.slaveBankStart = 14,
};
}