HAL  v0.6.1
Hardware Abstraction Layer
Loading...
Searching...
No Matches
TIMER

System timer. More...

Collaboration diagram for TIMER:

Data Structures

struct  timer_attr_t
 
struct  timer_handle_t
 

Typedefs

typedef void(* hal_timer_callback) (const uint8_t channel)
 Timer callback function prototype.
 

Enumerations

enum  timer_result_t {
  TIMER_RESULT_OK ,
  TIMER_RESULT_INVALID ,
  TIMER_RESULT_UNSUPPORTED ,
  TIMER_RESULT_ERR ,
  TOTAL_TIMER_RESULT
}
 
enum  timer_status_t {
  TIMER_STATUS_UNKNOWN ,
  TIMER_STATUS_OK ,
  TIMER_STATUS_BUSY ,
  TIMER_STATUS_STOP ,
  TIMER_STATUS_ERR ,
  TOTAL_TIMER_STATUS
}
 

Functions

timer_result_t hal_timer_init (timer_handle_t *handle, const timer_attr_t attr, const hal_timer_callback callback)
 Initialize timer.
 
timer_result_t hal_timer_start (timer_handle_t *handle)
 Start timer counter with initial configured period.
 
timer_result_t hal_timer_stop (timer_handle_t *handle)
 Stop timer counter.
 

Detailed Description

System timer.

Typedef Documentation

◆ hal_timer_callback

typedef void(* hal_timer_callback) (const uint8_t channel)

#include <timer/public_inc/hal_timer.h>

Timer callback function prototype.

Parameters
[in]channelTimer channel

Enumeration Type Documentation

◆ timer_result_t

#include <timer/public_inc/hal_timer.h>

Enumerator
TIMER_RESULT_OK 

No error.

TIMER_RESULT_INVALID 

Operation invalid.

TIMER_RESULT_UNSUPPORTED 

Operation not supported.

TIMER_RESULT_ERR 

Error occurred.

TOTAL_TIMER_RESULT 

◆ timer_status_t

#include <timer/public_inc/hal_timer.h>

Enumerator
TIMER_STATUS_UNKNOWN 

Timer status unknown.

TIMER_STATUS_OK 

No error.

TIMER_STATUS_BUSY 

Channel busy.

TIMER_STATUS_STOP 

Channel stopped.

TIMER_STATUS_ERR 

Error occurred.

TOTAL_TIMER_STATUS 

Function Documentation

◆ hal_timer_init()

timer_result_t hal_timer_init ( timer_handle_t * handle,
const timer_attr_t attr,
const hal_timer_callback callback )

#include <timer/public_inc/hal_timer.h>

Initialize timer.

void callback( const uint8_t channel );
timer_handle_t handle = { .channel = BSP_TIMER_CHANNEL_1 };
timer_attr_t attr = {
.sec = 0U,
.millis = 500U,
.micros = 0U
};
timer_result_t result = hal_timer_init( &handle, attr, &callback );
timer_result_t
Definition hal_timer.h:44
timer_result_t hal_timer_init(timer_handle_t *handle, const timer_attr_t attr, const hal_timer_callback callback)
Initialize timer.
Definition hal_timer.h:65
uint32_t sec
Definition hal_timer.h:66
Definition hal_timer.h:73
uint8_t channel
timer channel
Definition hal_timer.h:74
Parameters
[in,out]handleTimer handler
[in]attrTimer attribute
[in]callbackCallback timer interrupt
Return values
TIMER_RESULT_OKTimer configured succcessfully
TIMER_RESULT_INVALIDConfiguration attributes invalid
TIMER_RESULT_UNSUPPORTEDTimer attribute unsupported
TIMER_RESULT_ERRFailed to configure timer

◆ hal_timer_start()

timer_result_t hal_timer_start ( timer_handle_t * handle)

#include <timer/public_inc/hal_timer.h>

Start timer counter with initial configured period.

timer_result_t result = hal_timer_start( &handle );
timer_result_t hal_timer_start(timer_handle_t *handle)
Start timer counter with initial configured period.
Parameters
[in,out]handleTimer handler
Return values
TIMER_RESULT_OKSuccessfully start the timer
TIMER_RESULT_ERRFailed to start the timer

◆ hal_timer_stop()

timer_result_t hal_timer_stop ( timer_handle_t * handle)

#include <timer/public_inc/hal_timer.h>

Stop timer counter.

timer_result_t result = hal_timer_stop( &handle );
timer_result_t hal_timer_stop(timer_handle_t *handle)
Stop timer counter.
Parameters
[in,out]handleTimer handler
Return values
TIMER_RESULT_OKSuccessfully stop the timer
TIMER_RESULT_ERRFailed to stop the timer