Compare commits
3 Commits
eb74553f89
...
add-F3-mac
| Author | SHA1 | Date | |
|---|---|---|---|
| 5832f00cbc | |||
| 66983c30d3 | |||
| b2929ad664 |
17
can-halal.c
17
can-halal.c
@ -32,14 +32,14 @@ HAL_StatusTypeDef ftcan_add_filter(uint16_t id, uint16_t mask) {
|
||||
static uint32_t next_filter_no = 0;
|
||||
static CAN_FilterTypeDef filter;
|
||||
if (next_filter_no % 2 == 0) {
|
||||
filter.FilterIdHigh = id;
|
||||
filter.FilterMaskIdHigh = mask;
|
||||
filter.FilterIdLow = 0;
|
||||
filter.FilterMaskIdLow = 0xFFFF;
|
||||
filter.FilterIdHigh = id << 5;
|
||||
filter.FilterMaskIdHigh = mask << 5;
|
||||
filter.FilterIdLow = id << 5;
|
||||
filter.FilterMaskIdLow = mask << 5;
|
||||
} else {
|
||||
// Leave high filter untouched from the last configuration
|
||||
filter.FilterIdLow = id;
|
||||
filter.FilterMaskIdLow = mask;
|
||||
filter.FilterIdLow = id << 5;
|
||||
filter.FilterMaskIdLow = mask << 5;
|
||||
}
|
||||
filter.FilterFIFOAssignment = CAN_FILTER_FIFO0;
|
||||
filter.FilterBank = next_filter_no / 2;
|
||||
@ -141,7 +141,10 @@ HAL_StatusTypeDef ftcan_transmit(uint16_t id, const uint8_t *data,
|
||||
header.FDFormat = FDCAN_CLASSIC_CAN;
|
||||
header.TxEventFifoControl = FDCAN_NO_TX_EVENTS;
|
||||
|
||||
return HAL_FDCAN_AddMessageToTxFifoQ(hcan, &header, data);
|
||||
// HAL_FDCAN_AddMessageToTxFifoQ doesn't modify the data, but it's not marked
|
||||
// as const for some reason.
|
||||
uint8_t *data_nonconst = (uint8_t *)data;
|
||||
return HAL_FDCAN_AddMessageToTxFifoQ(hcan, &header, data_nonconst);
|
||||
}
|
||||
|
||||
HAL_StatusTypeDef ftcan_add_filter(uint16_t id, uint16_t mask) {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#ifndef CAN_HALAL_H
|
||||
#define CAN_HALAL_H
|
||||
|
||||
#if defined(STM32F3)
|
||||
#if defined(STM32F302x8) || defined(STM32F302xB) || defined(STM32F302xC) || defined(STM32F3)
|
||||
#include "stm32f3xx_hal.h"
|
||||
#define FTCAN_IS_BXCAN
|
||||
#define FTCAN_NUM_FILTERS 13
|
||||
|
||||
Reference in New Issue
Block a user