semf
|
Class for using CAN with Stm32. More...
#include <stm32can.h>
Public Member Functions | |
Stm32Can (CAN_HandleTypeDef &hwHandle) | |
Constructor. More... | |
Stm32Can (const Stm32Can &other)=delete | |
virtual | ~Stm32Can ()=default |
void | init () override |
void | deinit () override |
void | setReadBuffer (uint8_t buffer[], size_t bufferSize) override |
Sets the read buffer for having the possibility to handle the received data. More... | |
void | stopWrite () override |
void | stopRead () override |
void | start () |
Hardware driver will be started. More... | |
void | stop () |
Hardware driver will be stopped. More... | |
bool | isStarted () const |
Get the state of the start of the CAN driver. More... | |
uint32_t | messageId () const override |
Returns the message ID for reading data. Use this function after reading the data via read-function. More... | |
void | setMessageId (uint32_t id) override |
Sets the message ID for writing data. Use this function before writing the data via write-function. More... | |
void | setFrequency (uint32_t hz) override |
Sets the speed. More... | |
void | setFilter (uint32_t filterBank, uint32_t messageId, uint32_t messageIdMask) override |
Sets a message hardware receive filter. More... | |
void | enterDeepPowerDownMode () |
Go to deep power down mode. More... | |
void | releaseDeepPowerDownMode () |
Go to active mode. More... | |
void | isrRead (CAN_HandleTypeDef &can, uint8_t fifoId) |
Saves a received message and sends a readyRead or readyRequested signal. More... | |
void | isrWritten (CAN_HandleTypeDef &can, uint8_t mailboxId) |
Sending a readyWritten signal. More... | |
void | isrError (CAN_HandleTypeDef &can) |
Sending a error signal. More... | |
Public Member Functions inherited from semf::CanHardware | |
virtual | ~CanHardware ()=default |
void | write (const uint8_t data[], size_t dataSize) override |
For writing data, dataWritten signal will be emitted after successful write. More... | |
void | read (uint8_t buffer[], size_t bufferSize) override |
For setting the read buffer. This has be done for getting a dataAvailable signal for handling the data. More... | |
bool | isBusyReading () const override |
Communication hardware is busy reading at the moment. More... | |
bool | isBusyWriting () const override |
Communication hardware is busy writing at the moment. More... | |
void | request () override |
Public Member Functions inherited from semf::Can | |
virtual | ~Can ()=default |
virtual void | request ()=0 |
virtual uint32_t | messageId () const =0 |
Returns the message ID for reading data. Use this function after reading the data via read-function. More... | |
virtual void | setMessageId (uint32_t id)=0 |
Sets the message ID for writing data. Use this function before writing the data via write-function. More... | |
virtual void | setFrequency (uint32_t hz)=0 |
Sets the speed. More... | |
virtual void | setFilter (uint32_t filterBank, uint32_t messageId, uint32_t messageIdMask)=0 |
Sets a message hardware receive filter. More... | |
Public Member Functions inherited from semf::CommunicationHardwareAsynchronous | |
virtual | ~CommunicationHardwareAsynchronous ()=default |
Type | type () const override |
Returns the hardware type. More... | |
void | setFrame (Frame frame) final |
Sets the selected usage of start and stop condition. More... | |
Public Member Functions inherited from semf::CommunicationHardware | |
virtual | ~CommunicationHardware ()=default |
virtual void | init ()=0 |
virtual void | deinit ()=0 |
virtual Type | type () const =0 |
Returns the hardware type. More... | |
virtual void | setFrame (Frame frame)=0 |
Sets the selected usage of start and stop condition. More... | |
Public Member Functions inherited from semf::app::Communication | |
virtual | ~Communication ()=default |
virtual void | write (const uint8_t data[], size_t dataSize)=0 |
For writing data, dataWritten signal will be emitted after successful write. More... | |
virtual void | read (uint8_t buffer[], size_t bufferSize)=0 |
For reading data, dataAvailable signal will be emitted after successful read. More... | |
virtual void | stopRead ()=0 |
virtual void | stopWrite ()=0 |
virtual bool | isBusyReading () const =0 |
Communication hardware is busy reading at the moment. More... | |
virtual bool | isBusyWriting () const =0 |
Communication hardware is busy writing at the moment. More... | |
Public Member Functions inherited from semf::LinkedQueue< T >::Node | |
virtual | ~Node ()=default |
T * | next () const |
Returns a pointer to the next element in a queue. More... | |
void | setNext (T *next) |
Sets a pointer to the next element in a list. More... | |
bool | isInQueue (LinkedQueue &queue) |
Returns if a node is part of this LinkedQueue . More... | |
Static Public Member Functions | |
static LinkedQueue< Stm32Can > * | queue () |
Get the list with all cans. More... | |
static void | systemIsrRead (CAN_HandleTypeDef &can, uint8_t fifoId) |
System-wide interrupt service routine for can receive. More... | |
static void | systemIsrWritten (CAN_HandleTypeDef &can, uint8_t mailboxId) |
System-wide interrupt service routine for can transmit. More... | |
static void | systemIsrError (CAN_HandleTypeDef &can) |
System-wide interrupt service routine for can error. More... | |
Protected Member Functions | |
void | writeHardware (const uint8_t data[], size_t dataSize) override |
Hardware will write data. More... | |
void | requestHardware () override |
Protected Member Functions inherited from semf::CanHardware | |
void | setBusyWriting (bool isBusy) |
Sets the busy flag for writing. More... | |
virtual void | setReadBuffer (uint8_t buffer[], size_t bufferSize)=0 |
Sets the read buffer for having the possibility to handle the received data. More... | |
virtual void | writeHardware (const uint8_t data[], size_t dataSize)=0 |
Hardware will write data. More... | |
virtual void | requestHardware ()=0 |
void | onDataWritten () |
void | onDataAvailable () |
void | onError (Error thrown) |
Is called if an error occurred by hardware read or write access. Will emit error signal. More... | |
void | onDataRequested () |
Additional Inherited Members | |
Public Attributes inherited from semf::Can | |
Signal | dataRequested |
Public Attributes inherited from semf::app::Communication | |
Signal | dataWritten |
Signal | dataAvailable |
Signal | writeStopped |
Signal | readStopped |
Signal< Error > | error |
Class for using CAN with Stm32.
start()
. Definition at line 25 of file stm32can.h.
|
strong |
Error codes for this class. Error ID identify a unique error() / onError call (excluding transferring).
Definition at line 29 of file stm32can.h.
|
explicit |
Constructor.
hwHandle | can hardware interface |
Definition at line 44 of file stm32can.cpp.
|
explicitdelete |
|
virtualdefault |
|
overridevirtual |
Deinitializes the hardware
Deinit_HalError | If the ST-HAL stumbles upon an error. |
Deinit_HalBusy | If the ST-HAL is busy. |
Deinit_HalTimeout | If the ST-HAL times out. |
Implements semf::CommunicationHardware.
Definition at line 75 of file stm32can.cpp.
void semf::Stm32Can::enterDeepPowerDownMode | ( | ) |
Go to deep power down mode.
EnterDeepPowerDownMode_SleepStateReadyListeningHalError | If sleep returns a hal error. |
EnterDeepPowerDownMode_SleepStateReadyListeningHalBusy | If sleep returns a hal busy. |
EnterDeepPowerDownMode_SleepStateReadyListeningHalTimeout | If sleep returns a hal timeout. |
EnterDeepPowerDownMode_InitStateResetSleepPendingHalError | If init returns a hal error. |
Enterdeeppowerdownmode_Initstateresetsleeppendinghalbusy | If init returns a hal busy. |
EnterDeepPowerDownMode_InitStateResetSleepPendingHalTimeout | If init returns a hal timeout. |
EnterDeepPowerDownMode_StartStateResetSleepPendingHalError | If start returns a hal error. |
EnterDeepPowerDownMode_StartStateResetSleepPendingHalBusy | If start returns a hal busy. |
EnterDeepPowerDownMode_StartStateResetSleepPendingHalTimeout | If start returns a hal timeout. |
EnterDeepPowerDownMode_SleepStateResetSleepPendingHalError | If sleep returns a hal error. |
EnterDeepPowerDownMode_SleepStateResetSleepPendingHalBusy | If sleep returns a hal busy. |
EnterDeepPowerDownMode_SleepStateResetSleepPendingHalTimeout | If sleep returns a hal timeout. |
Definition at line 179 of file stm32can.cpp.
|
overridevirtual |
Initializes the hardware.
Init_HalError | If the ST-HAL stumbles upon an error. |
Init_HalBusy | If the ST-HAL is busy. |
Init_HalTimeout | If the ST-HAL times out. |
Implements semf::CommunicationHardware.
Definition at line 50 of file stm32can.cpp.
void semf::Stm32Can::isrError | ( | CAN_HandleTypeDef & | can | ) |
Sending a error
signal.
can | Pointer to CAN hardware handler. |
Definition at line 468 of file stm32can.cpp.
void semf::Stm32Can::isrRead | ( | CAN_HandleTypeDef & | can, |
uint8_t | fifoId | ||
) |
Saves a received message and sends a readyRead
or readyRequested
signal.
can | Pointer to CAN hardware handler. |
fifoId | FIFO ID of the received message. |
IsrRead_NullpointerReadBuffer | Read data is not set. |
IsrRead_FifoIdInvalid | If FIFO-id is invalid. |
IsrRead_HalError | If ST-HAL returns hal error. |
IsrRead_HalBusy | If ST-HAL returns hal busy. |
IsrRead_HalTimeout | If ST-HAL returns hal timeout. |
Definition at line 403 of file stm32can.cpp.
void semf::Stm32Can::isrWritten | ( | CAN_HandleTypeDef & | can, |
uint8_t | mailboxId | ||
) |
Sending a readyWritten
signal.
can | Pointer to CAN hardware handler. |
mailboxId | Id of mailbox where message was written from. |
Definition at line 455 of file stm32can.cpp.
bool semf::Stm32Can::isStarted | ( | ) | const |
Get the state of the start of the CAN driver.
Definition at line 121 of file stm32can.cpp.
|
overridevirtual |
Returns the message ID for reading data. Use this function after reading the data via read-function.
Implements semf::Can.
Definition at line 126 of file stm32can.cpp.
|
static |
Get the list with all cans.
Definition at line 379 of file stm32can.cpp.
void semf::Stm32Can::releaseDeepPowerDownMode | ( | ) |
Go to active mode.
ReleaseDeepPowerDownMode_WakeupStateSleepActiveHalError | If wakeup returns a hal error. |
ReleaseDeepPowerDownMode_WakeupStateSleepActiveHalBusy | If wakeup returns a hal busy. |
ReleaseDeepPowerDownMode_WakeupStateSleepActiveHalTimeout | If wakeup returns a hal timeout. |
ReleaseDeepPowerDownMode_InitStateResetSleepPendingHalError | If init returns a hal error. |
ReleaseDeepPowerDownMode_InitStateResetSleepPendingHalBusy | If init returns a hal busy. |
ReleaseDeepPowerDownMode_InitStateResetSleepPendingHalTimeout | If init returns a hal timeout. |
ReleaseDeepPowerDownMode_StartStateResetSleepPendingHalError | If start returns a hal error. |
ReleaseDeepPowerDownMode_StartStateResetSleepPendingHalBusy | If start returns a hal busy. |
ReleaseDeepPowerDownMode_StartStateResetSleepPendingHalTimeout | If start returns a hal timeout. |
ReleaseDeepPowerDownMode_StartStateError | If illegal state got reached. |
ReleaseDeepPowerDownMode_StartStateInvalid | If illegal state got reached. |
Definition at line 288 of file stm32can.cpp.
|
overrideprotectedvirtual |
Hardware will request data on specific id. Id can be set by calling setMessageId()
.
RequestHardware_InvalidMessageId | If message id is invalid. |
RequestHardware_HalError | If ST-HAL returns HAL error. |
RequestHardware_HalBusy | If ST-HAL returns HAL busy. |
RequestHardware_HalTimeout | If ST-HAL returns HAL timeout. |
RequestHardware_NotStarted | If ST-HAL not started. |
Implements semf::CanHardware.
Definition at line 540 of file stm32can.cpp.
|
overridevirtual |
Sets a message hardware receive filter.
filterBank | Index of filter bank. |
messageId | Message id for allowing to receive. |
messageIdMask | Message id range for allowing to receive. |
SetFilter_IndexOutOfBounds | If index is too high. |
SetFilter_MessageIdInvalid | If message id is invalid. |
SetFilter_MessageIdMaskInvalid | If the mask of the messageID is invalid. |
Implements semf::Can.
Definition at line 145 of file stm32can.cpp.
|
overridevirtual |
Sets the speed.
hz | frequency in hz |
Implements semf::Can.
Definition at line 137 of file stm32can.cpp.
|
overridevirtual |
Sets the message ID for writing data. Use this function before writing the data via write-function.
id | message ID of read data |
Implements semf::Can.
Definition at line 131 of file stm32can.cpp.
|
overridevirtual |
Sets the read buffer for having the possibility to handle the received data.
buffer | Buffer to store received bytes in. |
bufferSize | Size of receive buffer. |
Implements semf::CanHardware.
Definition at line 101 of file stm32can.cpp.
void semf::Stm32Can::start | ( | ) |
Hardware driver will be started.
Start_HalTimeout | If the ST-HAL times out. |
Start_HalNotInitialized | If the ST-HAL is not initialized. |
Definition at line 595 of file stm32can.cpp.
void semf::Stm32Can::stop | ( | ) |
Hardware driver will be stopped.
Stop_HalTimeout | If the ST-HAL times out. |
Definition at line 623 of file stm32can.cpp.
|
overridevirtual |
Stops the read process as fast as possible without destroying anything. The readStopped
Signal gets emitted if the call was successful.
Implements semf::app::Communication.
Definition at line 114 of file stm32can.cpp.
|
overridevirtual |
Stops the write process as fast as possible without destroying anything. The writeStopped
Signal gets emitted if the call was successful.
Implements semf::app::Communication.
Definition at line 107 of file stm32can.cpp.
|
static |
System-wide interrupt service routine for can error.
can | Hardware handler. |
Definition at line 397 of file stm32can.cpp.
|
static |
System-wide interrupt service routine for can receive.
can | Hardware handler. |
fifoId | Id message has read into. |
Definition at line 385 of file stm32can.cpp.
|
static |
System-wide interrupt service routine for can transmit.
can | Hardware handler. |
mailboxId | Id of mailbox where message was written from. |
Definition at line 391 of file stm32can.cpp.
|
overrideprotectedvirtual |
Hardware will write data.
data | data array |
dataSize | data array size |
WriteHardware_InvalidMessageId | If message id is invalid. |
WriteHardware_HalError | If ST-HAL returns HAL error. |
WriteHardware_HalBusy | If ST-HAL returns HAL busy. |
WriteHardware_HalTimeout | If ST-HAL returns HAL timeout. |
WriteHardware_NotStarted | If ST-HAL not started. |
Implements semf::CanHardware.
Definition at line 477 of file stm32can.cpp.