[FL-2818] FuriHal: add FuriHalCortexTimer, use it for i2c bus timeouts (#1900)

* FuriHal: add FuriHalCortexTimer, use it for i2c bus timeouts
* Furi: cleanup FuriHalCortexTimer sources and headers
This commit is contained in:
あく
2022-10-21 02:14:46 +09:00
committed by GitHub
parent f56c94922d
commit 33892ebfb7
4 changed files with 67 additions and 17 deletions

View File

@@ -6,11 +6,18 @@
#pragma once
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
/** Cortex timer provides high precision low level expiring timer */
typedef struct {
uint32_t start;
uint32_t value;
} FuriHalCortexTimer;
/** Early init stage for cortex
*/
void furi_hal_cortex_init_early();
@@ -27,6 +34,28 @@ void furi_hal_cortex_delay_us(uint32_t microseconds);
*/
uint32_t furi_hal_cortex_instructions_per_microsecond();
/** Get Timer
*
* @param[in] timeout_us The expire timeout in us
*
* @return The FuriHalCortexTimer
*/
FuriHalCortexTimer furi_hal_cortex_timer_get(uint32_t timeout_us);
/** Check if timer expired
*
* @param[in] cortex_timer The FuriHalCortexTimer
*
* @return true if expired
*/
bool furi_hal_cortex_timer_is_expired(FuriHalCortexTimer cortex_timer);
/** Wait for timer expire
*
* @param[in] cortex_timer The FuriHalCortexTimer
*/
void furi_hal_cortex_timer_wait(FuriHalCortexTimer cortex_timer);
#ifdef __cplusplus
}
#endif