VSF Documented
Data Structures | Enumerations | Functions
driver_gptimer_port.c File Reference
#include "../vsf_espidf_cfg.h"
#include "driver/gptimer.h"
#include "../vsf_espidf.h"
#include "kernel/vsf_kernel.h"
#include "hal/driver/driver.h"
#include <string.h>

Data Structures

struct  gptimer_t
 

Enumerations

enum  gptimer_fsm_t {
  GPTIMER_FSM_INIT = 0 ,
  GPTIMER_FSM_ENABLE = 1 ,
  GPTIMER_FSM_RUN = 2
}
 

Functions

void vsf_espidf_gptimer_init (const vsf_espidf_gptimer_cfg_t *cfg)
 
esp_err_t gptimer_new_timer (const gptimer_config_t *config, gptimer_handle_t *ret_timer)
 Allocate a new gptimer handle drawn from the injected VSF pool.
 
esp_err_t gptimer_del_timer (gptimer_handle_t timer)
 Release a gptimer handle, stopping the underlying timer first.
 
esp_err_t gptimer_register_event_callbacks (gptimer_handle_t timer, const gptimer_event_callbacks_t *cbs, void *user_data)
 Register the alarm callback (and future per-event callbacks).
 
esp_err_t gptimer_set_alarm_action (gptimer_handle_t timer, const gptimer_alarm_config_t *config)
 Configure the alarm action applied at the next alarm event.
 
esp_err_t gptimer_enable (gptimer_handle_t timer)
 Transition the timer into the "enabled" state.
 
esp_err_t gptimer_disable (gptimer_handle_t timer)
 Transition the timer out of the "enabled" state.
 
esp_err_t gptimer_start (gptimer_handle_t timer)
 Start the counter. The timer must already be enabled.
 
esp_err_t gptimer_stop (gptimer_handle_t timer)
 Stop the counter. The counter value is retained.
 
esp_err_t gptimer_set_raw_count (gptimer_handle_t timer, uint64_t value)
 Set the raw counter value.
 
esp_err_t gptimer_get_raw_count (gptimer_handle_t timer, uint64_t *value)
 Read the raw counter value.
 
esp_err_t gptimer_get_resolution (gptimer_handle_t timer, uint32_t *out_resolution)
 Query the actual resolution chosen by the underlying hardware.
 
esp_err_t gptimer_get_captured_count (gptimer_handle_t timer, uint64_t *value)
 Return the number of alarms that have fired since enable.
 

Enumeration Type Documentation

◆ gptimer_fsm_t

Enumerator
GPTIMER_FSM_INIT 

allocated, not yet enabled

GPTIMER_FSM_ENABLE 

enabled, counter not running

GPTIMER_FSM_RUN 

counter running

Function Documentation

◆ vsf_espidf_gptimer_init()

void vsf_espidf_gptimer_init ( const vsf_espidf_gptimer_cfg_t cfg)
extern

◆ gptimer_new_timer()

esp_err_t gptimer_new_timer ( const gptimer_config_t config,
gptimer_handle_t ret_timer 
)

Allocate a new gptimer handle drawn from the injected VSF pool.

Return values
ESP_OKsuccess
ESP_ERR_INVALID_ARGconfig / ret_timer is NULL, direction != UP
ESP_ERR_INVALID_STATEshim not initialised or pool exhausted
ESP_ERR_NO_MEMheap exhausted for handle metadata

◆ gptimer_del_timer()

esp_err_t gptimer_del_timer ( gptimer_handle_t  timer)

Release a gptimer handle, stopping the underlying timer first.

Return values
ESP_OKsuccess
ESP_ERR_INVALID_ARGtimer is NULL
ESP_ERR_INVALID_STATEtimer is still in the enabled state

◆ gptimer_register_event_callbacks()

esp_err_t gptimer_register_event_callbacks ( gptimer_handle_t  timer,
const gptimer_event_callbacks_t cbs,
void *  user_data 
)

Register the alarm callback (and future per-event callbacks).

Must be called while the timer is in the disabled state – mirroring the ESP-IDF contract that forbids hot-patching callbacks.

◆ gptimer_set_alarm_action()

esp_err_t gptimer_set_alarm_action ( gptimer_handle_t  timer,
const gptimer_alarm_config_t config 
)

Configure the alarm action applied at the next alarm event.

Passing config == NULL disables alarm generation. Otherwise the shim programs the underlying vsf_timer so that an overflow IRQ fires every alarm_count ticks; reload_count is honoured only when the implemented backend exposes a way to pre-load the counter (currently: only auto_reload_on_alarm is supported by mapping to a continuous timer, other combinations fall back to continuous semantics too).

◆ gptimer_enable()

esp_err_t gptimer_enable ( gptimer_handle_t  timer)

Transition the timer into the "enabled" state.

The counter is not yet running; call gptimer_start() to start counting.

◆ gptimer_disable()

esp_err_t gptimer_disable ( gptimer_handle_t  timer)

Transition the timer out of the "enabled" state.

◆ gptimer_start()

esp_err_t gptimer_start ( gptimer_handle_t  timer)

Start the counter. The timer must already be enabled.

◆ gptimer_stop()

esp_err_t gptimer_stop ( gptimer_handle_t  timer)

Stop the counter. The counter value is retained.

◆ gptimer_set_raw_count()

esp_err_t gptimer_set_raw_count ( gptimer_handle_t  timer,
uint64_t  value 
)

Set the raw counter value.

Return values
ESP_ERR_NOT_SUPPORTEDthe VSF backend does not expose this

◆ gptimer_get_raw_count()

esp_err_t gptimer_get_raw_count ( gptimer_handle_t  timer,
uint64_t value 
)

Read the raw counter value.

Return values
ESP_ERR_NOT_SUPPORTEDthe VSF backend does not expose this

◆ gptimer_get_resolution()

esp_err_t gptimer_get_resolution ( gptimer_handle_t  timer,
uint32_t out_resolution 
)

Query the actual resolution chosen by the underlying hardware.

May differ from the requested resolution_hz when the clock divider is discrete. The shim returns the value programmed by the backend when available, otherwise the originally requested value.

◆ gptimer_get_captured_count()

esp_err_t gptimer_get_captured_count ( gptimer_handle_t  timer,
uint64_t value 
)

Return the number of alarms that have fired since enable.

Return values
ESP_ERR_NOT_SUPPORTEDthe VSF backend does not track this

Variable Documentation

◆ is_inited

bool is_inited

◆ pool

vsf_timer_t* const* pool

◆ pool_count

uint16_t pool_count

◆ pool_busy

uint32_t pool_busy

1 bit per entry, LSB = idx 0

Generated from commit: vsfteam/vsf@015f4d1