mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-01 18:50:34 +03:00
157 lines
3.3 KiB
C
157 lines
3.3 KiB
C
/*
|
|
* SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include "esp_log.h"
|
|
#include "esp_err.h"
|
|
#include "esp_attr.h"
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
/**
|
|
* @brief Check whether a target time has expired relative to a reference time.
|
|
*
|
|
* @note This is wrap-around safe for 32-bit timestamps: it returns true when
|
|
* @p target is at or before @p now within the first half of the counter range.
|
|
*
|
|
* @param[in] target The target time to check.
|
|
* @param[in] now The current/reference time.
|
|
*
|
|
* @return
|
|
* true if @p target has expired (is at or before @p now).
|
|
* false otherwise.
|
|
*
|
|
*/
|
|
FORCE_INLINE_ATTR bool is_target_time_expired(uint32_t target, uint32_t now)
|
|
{
|
|
return (((now - target) & (1 << 31)) == 0);
|
|
}
|
|
|
|
/**
|
|
* @brief Start the IEEE802154 MAC internal timer0.
|
|
*
|
|
*/
|
|
void ieee802154_timer0_start(void);
|
|
|
|
/**
|
|
* @brief Stop the IEEE802154 MAC internal timer0.
|
|
*
|
|
*/
|
|
void ieee802154_timer0_stop(void);
|
|
|
|
/**
|
|
* @brief Set the overflow threshold to the IEEE802154 MAC internal timer0.
|
|
*
|
|
* @param[in] value The threshold.
|
|
*
|
|
* @return
|
|
* ESP_OK if the threshold is valid.
|
|
* ESP_ERR_INVALID_ARG if the threshold is invalid.
|
|
*
|
|
*/
|
|
esp_err_t ieee802154_timer0_set_threshold(uint32_t value);
|
|
|
|
/**
|
|
* @brief Get the current IEEE802154 MAC internal timer0 count.
|
|
*
|
|
* @return
|
|
* The timer0 count.
|
|
*
|
|
*/
|
|
uint32_t ieee802154_timer0_get_value(void);
|
|
|
|
/**
|
|
* @brief Start the IEEE802154 MAC internal timer1.
|
|
*
|
|
*/
|
|
void ieee802154_timer1_start(void);
|
|
|
|
/**
|
|
* @brief Stop the IEEE802154 MAC internal timer1.
|
|
*
|
|
*/
|
|
void ieee802154_timer1_stop(void);
|
|
|
|
/**
|
|
* @brief Set the overflow threshold to the IEEE802154 MAC internal timer1.
|
|
*
|
|
* @param[in] value The threshold.
|
|
*
|
|
* @return
|
|
* ESP_OK if the threshold is valid.
|
|
* ESP_ERR_INVALID_ARG if the threshold is invalid.
|
|
*
|
|
*/
|
|
esp_err_t ieee802154_timer1_set_threshold(uint32_t value);
|
|
|
|
/**
|
|
* @brief Get the current IEEE802154 MAC internal timer1 count.
|
|
*
|
|
* @return
|
|
* The timer1 count.
|
|
*
|
|
*/
|
|
uint32_t ieee802154_timer1_get_value(void);
|
|
|
|
/**
|
|
* @brief Set timer0 to fire at specific time.
|
|
*
|
|
*/
|
|
void ieee802154_timer0_fire_at(uint32_t fire_time);
|
|
|
|
/**
|
|
* @brief Set timer1 to fire at specific time.
|
|
*
|
|
*/
|
|
void ieee802154_timer1_fire_at(uint32_t fire_time);
|
|
|
|
typedef void (*timer_callback_t)(void* ctx);
|
|
|
|
/**
|
|
* @brief Set timer0 callback.
|
|
*
|
|
*/
|
|
void ieee802154_timer0_set_callback(timer_callback_t timer0_cb, void *timer0_ctx);
|
|
|
|
/**
|
|
* @brief Set timer1 callback.
|
|
*
|
|
*/
|
|
void ieee802154_timer1_set_callback(timer_callback_t timer1_cb, void *timer1_ctx);
|
|
|
|
/**
|
|
* @brief Set timer0 to fire at specific time with callback.
|
|
*
|
|
*/
|
|
void ieee802154_timer0_fire_at_with_callback(uint32_t fire_time, timer_callback_t timer0_callback, void *timer0_ctx);
|
|
|
|
/**
|
|
* @brief Set timer1 to fire at specific time with callback.
|
|
*
|
|
*/
|
|
void ieee802154_timer1_fire_at_with_callback(uint32_t fire_time, timer_callback_t timer1_callback, void *timer1_ctx);
|
|
|
|
/**
|
|
* @brief ISR handle for timer0.
|
|
*
|
|
*/
|
|
void isr_handle_timer0_done(void);
|
|
|
|
/**
|
|
* @brief ISR handle for timer1.
|
|
*
|
|
*/
|
|
void isr_handle_timer1_done(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|