fix buffer index calculation
they take a bit field as an argument, and then immediately use a clz instruction to convert it back to an index for some reason
This commit is contained in:
@ -230,12 +230,14 @@ HAL_StatusTypeDef ftcan_get_tx_queue_length(uint32_t *length) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if FTCAN_NUM_TX_BUFFERS
|
#if FTCAN_NUM_TX_BUFFERS
|
||||||
|
static_assert(FDCAN_TX_BUFFER11 == 1 << 11 && FDCAN_TX_BUFFER21 == 1 << 21, "Your HAL version has a different definition for the transmit buffer indices. Please update your HAL version or change the code below.");
|
||||||
|
|
||||||
HAL_StatusTypeDef ftcan_transmit_buffer(uint16_t id, const uint8_t *data, size_t datalen, uint32_t buffer_index) {
|
HAL_StatusTypeDef ftcan_transmit_buffer(uint16_t id, const uint8_t *data, size_t datalen, uint32_t buffer_index) {
|
||||||
static FDCAN_TxHeaderTypeDef header;
|
static FDCAN_TxHeaderTypeDef header;
|
||||||
if (buffer_index >= FTCAN_NUM_TX_BUFFERS) {
|
if (buffer_index >= FTCAN_NUM_TX_BUFFERS) {
|
||||||
return HAL_ERROR;
|
return HAL_ERROR;
|
||||||
}
|
}
|
||||||
return HAL_FDCAN_AddMessageToTxBuffer(hcan, fdcan_initialize_tx_header(&header, id, datalen), data, buffer_index);
|
return HAL_FDCAN_AddMessageToTxBuffer(hcan, fdcan_initialize_tx_header(&header, id, datalen), data, 1 << buffer_index);
|
||||||
}
|
}
|
||||||
#endif // FTCAN_NUM_TX_BUFFERS
|
#endif // FTCAN_NUM_TX_BUFFERS
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user