STM32Cube Expansion Pack CAN Stack
|
driver class to work with the STM32 bxCAN controller module More...
#include <CanDrv_bxCAN.h>
Public Member Functions | |
CanDrv_bxCAN () | |
standard constructor for a bxCAN controller object | |
virtual | ~CanDrv_bxCAN () |
standard destructor for a bxCAN controller object | |
void | TxTask (void) |
task function to push the tx message from software buffer to tx mailbox More... | |
Std_ReturnType | Init (const CanConfigType *ptr2Config=NULL_PTR, const ComIf *ptr2ComIfObject=NULL_PTR) |
Init function for the bxCAN. More... | |
Std_ReturnType | SetControllerMode (ECU_CanController Controller, CanControllerStates Transition) |
The API to set a controller mode. More... | |
Std_ReturnType | Write (ECU_CanController Controller, const ComStack_CanMessageType *ptr2PduInfo) |
The API to write a message to tx FIFO. More... | |
Std_ReturnType | SetFilterByBitmask (ECU_CanController Controller, ComStack_CanIdType FilterId, ComStack_CanIdType FilterMask) |
configure a free hardware filter using bit masking More... | |
Std_ReturnType | SetFilterByCanId (ECU_CanController Controller, ComStack_CanIdType FilterId) |
configure a free hardware filter using single CAN Id filtering More... | |
![]() | |
Can () | |
Standard Constructor. | |
virtual | ~Can () |
basic destructor | |
CanDrvStates | GetDrvState (void) |
To get the the software module state. | |
void | SetDrvStateReady (void) |
Switch driver state to ready. | |
void | SetDrvStateUninit (void) |
Switch driver state to uninit. | |
virtual void | Deinit (void) |
The API function for Deinit. More... | |
virtual Std_ReturnType | SetBaudrate (ECU_CanController Controller, CanControllerBaudRateConfigID BaudrateId) |
The API to set baudrate on a controller. More... | |
virtual void | DisableControllerInterrupts (ECU_CanController Controller) |
The API to disable all interrupts of a controller. More... | |
virtual void | EnableControllerInterrupts (ECU_CanController Controller) |
The API to enable all interrupts of a controller. More... | |
virtual Std_ReturnType | CheckWakeup (ECU_CanController Controller) |
The API checks the controller for wakeup events. More... | |
virtual Std_ReturnType | GetControllerErrorState (ECU_CanController Controller, uint8_t *ErrorStatePtr) |
The API returns the error state of the CAN controller. More... | |
virtual Std_ReturnType | GetControllerMode (ECU_CanController Controller, CanControllerStates *ControllerModePtr) |
The API returns the error state of the CAN controller. More... | |
Private Member Functions | |
Std_ReturnType | FindFreeFilter (const uint8_t *ptr2FilterBankNumber, const uint8_t *ptr2FilterNumber, const uint8_t *ptr2FilterMode) |
to find a free CAN hardware filter More... | |
uint32_t | CanIdToStmRegisterFormat (ComStack_CanIdType CanId) |
change the 32bit format to use with STM Registers More... | |
Private Attributes | |
CAN_HandleTypeDef | bxCanHdl [2] |
we need a handle to hold the information for the bxCAN controller | |
bxCan_TxMessageType | canTxBuffer [CAN_TX_SW_BUFFER_SIZE] |
we want a Tx software buffer More... | |
driver class to work with the STM32 bxCAN controller module
Definition at line 183 of file CanDrv_bxCAN.h.
|
private |
change the 32bit format to use with STM Registers
[in] | CanId | should be a CanIf formated CanId |
Definition at line 432 of file CanDrv_bxCAN.cpp.
References bxCan_IdSelectType::common, bxCan_StdCanIdType::Id11bit, bxCan_ExtCanIdType::Id29bit, bxCan_ExtCanIdType::IDE, bxCan_StdCanIdType::RTR, bxCan_ExtCanIdType::RTR, bxCan_IdSelectType::stm_ExtId, bxCan_IdSelectType::stm_StdId, and TRUE.
Referenced by SetFilterByBitmask(), and SetFilterByCanId().
|
private |
to find a free CAN hardware filter
STM hasn't a function like this in the HAL.
We find a free hardware filter and returns the filter bank to use the filter.
We returns the filter number to use it on fast selection in IRQ routine.
The filter mode is used to search for mask or identifier filter. If searching for identifier filter we returns also if there is a FR2 is empty
[out] | ptr2FilterBankNumber | returns the number of the first free filter bank |
[out] | ptr2FilterNumber | returns the filter number according to the previous filter configuration |
[in,out] | ptr2FilterMode | selects the search for Mask filter (aka deactivated filter) or Identifier Filter. on Identifier Filter search it returns if the FR1 register is already in use |
Definition at line 281 of file CanDrv_bxCAN.cpp.
References AUTOMATIC, bxCanHdl, E_NOT_OK, E_OK, FALSE, P2VAR, and TRUE.
Referenced by SetFilterByBitmask(), and SetFilterByCanId().
|
virtual |
Init function for the bxCAN.
Implements Can.
Definition at line 65 of file CanDrv_bxCAN.cpp.
References AUTOMATIC, bxCanHdl, CAN_DET_REPORTERROR, CAN_INIT_ID, E_INIT_FAILED, E_NOT_OK, E_TRANSITION, Can::GetDrvState(), NULL_PTR, P2CONST, ptr2ComIf, and Uninit.
|
virtual |
The API to set a controller mode.
[in] | Controller | selects the controller |
[in] | Transition | selects the transition per name/id |
Implements Can.
Definition at line 145 of file CanDrv_bxCAN.cpp.
References bxCanHdl, CAN_DET_REPORTERROR, CAN_SET_CONTROLLER_MODE_ID, CS_Started, E_NOT_OK, E_OK, and E_TRANSITION.
|
virtual |
configure a free hardware filter using bit masking
set hardware filter
[in] | Controller | select the controller where the filter should be applied |
[in] | FilterId | the selected filter bits |
[in] | FilterMask | the filter mask to select valid filter bits |
Reimplemented from Can.
Definition at line 339 of file CanDrv_bxCAN.cpp.
References bxCanHdl, CanIdToStmRegisterFormat(), E_NOT_OK, E_OK, and FindFreeFilter().
|
virtual |
configure a free hardware filter using single CAN Id filtering
set hardware filter
[in] | Controller | select the controller where the filter should be applied |
[in] | FilterId | the selected filter bits |
Reimplemented from Can.
Definition at line 383 of file CanDrv_bxCAN.cpp.
References bxCanHdl, CanIdToStmRegisterFormat(), E_NOT_OK, E_OK, and FindFreeFilter().
|
virtual |
task function to push the tx message from software buffer to tx mailbox
Reimplemented from Can.
Definition at line 233 of file CanDrv_bxCAN.cpp.
References bxCanHdl, canTxBuffer, Can::GetDrvState(), bxCan_TxMessageType::Header, bxCan_TxMessageType::Mailbox, Ready, bxCan_TxMessageType::State, TxMessage_free, TxMessage_rdy2tx, TxMessage_transmit, TxMessage_txerr, and TxMessage_txok.
|
virtual |
The API to write a message to tx FIFO.
[in] | Controller | select the controller for tx |
[in] | PduInfo | the CAN message to send |
Reimplemented from Can.
Definition at line 186 of file CanDrv_bxCAN.cpp.
References CAN_DET_REPORTERROR, CAN_WRITE_ID, canTxBuffer, bxCan_TxMessageType::Controller, bxCan_TxMessageType::Data, E_NOT_OK, E_OK, E_UNINIT, Can::GetDrvState(), bxCan_TxMessageType::Header, Ready, bxCan_TxMessageType::State, TRUE, TxMessage_free, TxMessage_rdy2tx, and TxMessage_write.
|
private |
we want a Tx software buffer
we start with a fix size. Later it would be go to the IDE
Definition at line 276 of file CanDrv_bxCAN.h.