Completed getPendingRxFifos

This commit is contained in:
@CarlWachter 2024-01-04 16:54:53 +01:00 committed by CarlWachter
parent 22dd70cb70
commit e8f7261030
2 changed files with 15 additions and 6 deletions

View File

@ -80,7 +80,7 @@ namespace sta
void disableFilter(uint8_t idx) override;
void clearFilters() override;
// TODO
// Return pending RX FIFOs as iterable container
CanPendingRxFifos getPendingRxFifos() override;
// Const getters

View File

@ -170,13 +170,22 @@ namespace sta
}
CanPendingRxFifos STM32CanController::getPendingRxFifos(){
CanPendingRxFifos pendingFifos(42, 3);
// Example implementation:
//pendingFifos.fifo0Pending = HAL_CAN_GetRxFifoFillLevel(handle_, CAN_RX_FIFO0) != 0;
//pendingFifos.fifo1Pending = HAL_CAN_GetRxFifoFillLevel(handle_, CAN_RX_FIFO1) != 0;
return pendingFifos;
uint32_t rxFlags = 0;
// Conditions to set the least significant bits
if (HAL_CAN_GetRxFifoFillLevel(handle_, CAN_RX_FIFO0) != 0) {
// Set the first least significant bit
rxFlags |= 0x01; // 0x01 is 00000001 in binary (LSB set, others cleared)
}
if (HAL_CAN_GetRxFifoFillLevel(handle_, CAN_RX_FIFO1) != 0) {
// Set the second least significant bit
rxFlags |= 0x02; // 0x02 is 00000010 in binary (2nd LSB set, others cleared)
}
return CanPendingRxFifos(rxFlags, MAX_FIFO_COUNT);;
}
uint8_t STM32CanController::maxFilterCount() const{