semf
semf::Stm32Timer Class Reference

Timer implementation for STM32 as peripheral timer. More...

#include <stm32timer.h>

Inheritance diagram for semf::Stm32Timer:
Inheritance graph
Collaboration diagram for semf::Stm32Timer:
Collaboration graph

Public Types

enum class  ErrorCode : uint8_t {
  Start_HalError = 0 , Start_HalBusy , Start_HalTimeout , Stop_HalError ,
  Stop_HalBusy , Stop_HalTimeout
}
 

Public Member Functions

 Stm32Timer (TIM_HandleTypeDef &hwHandle)
 Constructor. More...
 
 Stm32Timer (const Stm32Timer &other)=delete
 
virtual ~Stm32Timer ()=default
 
void start () override
 
void stop () override
 
void reset () override
 
void isr (TIM_HandleTypeDef &hwHandle)
 Interrupt service routine for adc conversion finished. More...
 
- Public Member Functions inherited from semf::app::Timer
virtual ~Timer ()=default
 
virtual void start ()=0
 
virtual void stop ()=0
 
virtual void reset ()=0
 
- 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< Stm32Timer > * queue ()
 Get the list with all timers. More...
 
static void systemIsr (TIM_HandleTypeDef &hwHandle)
 System-wide interrupt service routine for adc conversion finished. More...
 

Additional Inherited Members

- Public Attributes inherited from semf::app::Timer
Signal timeout
 
Signal< Errorerror
 

Detailed Description

Timer implementation for STM32 as peripheral timer.

Note
This class implements HAL_TIM_PeriodElapsedCallback . In some cases STM32CubeIDE implements this function on its own which results in a multiple definitions linking error. In that case define SEMF_TIMER_USE_CUSTOM_CALLBACK and extend STM32CubeIDE's implementation accordingly.

Definition at line 26 of file stm32timer.h.

Member Enumeration Documentation

◆ ErrorCode

enum class semf::Stm32Timer::ErrorCode : uint8_t
strong

Error codes for this class. Error ID identify a unique error() / onError call (excluding transferring).

Enumerator
Start_HalError 
Start_HalBusy 
Start_HalTimeout 
Stop_HalError 
Stop_HalBusy 
Stop_HalTimeout 

Definition at line 30 of file stm32timer.h.

Constructor & Destructor Documentation

◆ Stm32Timer() [1/2]

semf::Stm32Timer::Stm32Timer ( TIM_HandleTypeDef &  hwHandle)
explicit

Constructor.

Parameters
hwHandleHardware handler.

Definition at line 24 of file stm32timer.cpp.

Here is the call graph for this function:

◆ Stm32Timer() [2/2]

semf::Stm32Timer::Stm32Timer ( const Stm32Timer other)
explicitdelete

◆ ~Stm32Timer()

virtual semf::Stm32Timer::~Stm32Timer ( )
virtualdefault

Member Function Documentation

◆ isr()

void semf::Stm32Timer::isr ( TIM_HandleTypeDef &  hwHandle)

Interrupt service routine for adc conversion finished.

Parameters
hwHandleHardware handler.

Definition at line 95 of file stm32timer.cpp.

◆ queue()

LinkedQueue< Stm32Timer > * semf::Stm32Timer::queue ( )
static

Get the list with all timers.

Returns
The list with all timers.

Definition at line 83 of file stm32timer.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset()

void semf::Stm32Timer::reset ( )
overridevirtual

Resets the timer.

Implements semf::app::Timer.

Definition at line 78 of file stm32timer.cpp.

◆ start()

void semf::Stm32Timer::start ( )
overridevirtual

Starts the timer.

Exceptions
Start_HalErrorIf HAL_TIM_Base_Start_IT() returns HAL_ERROR.
Start_HalBusyIf HAL_TIM_Base_Start_IT() returns HAL_BUSY.
Start_HalTimeoutIf HAL_TIM_Base_Start_IT() returns HAL_TIMEOUT.

Implements semf::app::Timer.

Definition at line 30 of file stm32timer.cpp.

◆ stop()

void semf::Stm32Timer::stop ( )
overridevirtual

Stops the timer.

Exceptions
Stop_HalErrorIf HAL_TIM_Base_Stop_IT() returns HAL_ERROR.
Stop_HalBusyIf HAL_TIM_Base_Stop_IT() returns HAL_BUSY.
Stop_HalTimeoutIf HAL_TIM_Base_Stop_IT() returns HAL_TIMEOUT.

Implements semf::app::Timer.

Definition at line 54 of file stm32timer.cpp.

◆ systemIsr()

void semf::Stm32Timer::systemIsr ( TIM_HandleTypeDef &  hwHandle)
static

System-wide interrupt service routine for adc conversion finished.

Parameters
hwHandleHardware handler.

Definition at line 89 of file stm32timer.cpp.

Here is the call graph for this function:
Here is the caller graph for this function: