Select Git revision
package.json
Forked from
matefun / Frontend
Source project has a limited visibility.
This project manages its dependencies using npm.
Learn more
package.json 1.56 KiB
#ifndef TIMER_H
#define TIMER_H
#include "driver/timer.h"
#include <stdint.h>
#include "esp_err.h"
#define CONFIG_HWTIMER_THREAD_STACK_SIZE 8192
#define CONFIG_HWTIMER_THREAD_PRIORITY 10
#define CPU_LAST_TIMER 3
#define CPU_FIRST_TIMER 0
typedef struct{
int8_t unit;
} tmr_alarm_t;
typedef struct {
uint8_t setup;
void (*callback)(void *);
timer_isr_handle_t isrh;
} tmr_t;
typedef void(*tmr_isr_t)(void *);
/**
* @brief Configures a timer. After timer is configured you must start timer using
* tmr_start function. No sanity checks are done (use only in driver develop).
*
* @param unit Hardware timer, from 0 to 3.
* @param micros Period of timer, in microseconds.
* @param callback Callback function to call every micros period.
* @param deferred If 0, the callback are executed in the isr. If 1, the callback
* is deferred and is called outside the interrupt. Non deferred
* callbacks must reside in IRAM.
*
* @return 0 if success, -1 if error (memory error)
*
*/
int tmr_ll_setup(uint8_t unit, uint32_t micros, void(*callback)(void *));
/**
* @brief Removes a timer and the resources that uses.
* tmr_start function. No sanity checks are done (use only in driver develop).
*
* @param unit Hardware timer, from 0 to 3.
*/
void tmr_ll_unsetup(uint8_t unit);
/**
* @brief Start a previous configured timer. No sanity checks are done (use only in driver develop).
*
* @param unit Hardware timer, from 0 to 3.
*/
void tmr_ll_start(uint8_t unit);
/**
* @brief Stop a previous configured timer. No sanity checks are done (use only in driver develop).
*
* @param unit Hardware timer, from 0 to 3.
*/
void tmr_ll_stop(uint8_t unit);
/**
* @brief Configures a timer. After timer is configured you must start timer using
* tmr_start function.
*
* @param unit Hardware timer, from 0 to 3.
* @param micros Period of timer, in microseconds.