Compare commits

...

3 Commits

2 changed files with 16 additions and 2 deletions

View File

@ -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) {
@ -257,7 +260,7 @@ uint8_t *ftcan_marshal_unsigned(uint8_t *data, uint64_t val, size_t num_bytes) {
num_bytes = 8;
}
for (size_t i = num_bytes - 1; i >= 0; i++) {
for (int i = num_bytes - 1; i >= 0; i--) {
data[i] = val & 0xFF;
val >>= 8;
}

View File

@ -1,6 +1,17 @@
#ifndef CAN_HALAL_H
#define CAN_HALAL_H
// Define family macros if none are defined and we recognize a chip macro
#if !defined(STM32F3) && !defined(STM32H7)
#if defined(STM32F302x6) || defined(STM32F302x8) || defined(STM32F302xB) || \
defined(STM32F302xC)
#define STM32F3
#endif
#if defined(STM32H7A3xx)
#define STM32H7
#endif
#endif
#if defined(STM32F3)
#include "stm32f3xx_hal.h"
#define FTCAN_IS_BXCAN