Sensor Fusion Library 0.6.1
Orientation sensing for Espressif (ESP32, ESP8266) processors
Loading...
Searching...
No Matches
hal_timer.c
1#include <Arduino.h>
2#include <stdint.h>
3
4#include "hal_timer.h"
5
6#define CORE_SYSTICK_HZ 1000000 //use the 1us resolution timer available on ESP processors
7#define MICROSECS_IN_SEC 1000000
8
9void SystickStartCount(int32_t *pstart) {
10 // cast the unsigned value from micros() to signed, to avoid having to
11 // change prototype in fusion files. Cast it back to unsigned when using.
12 *pstart = (int32_t)micros();
13} // end SystickStartCount()
14
15int32_t SystickElapsedMicros(int32_t start_ticks) {
16 // Cast start_ticks back to unsigned before using (which it was
17 // when it was originally obtained from micros()).
18 // Return value is cast to signed int as expected by fusion routines.
19 // Note that if changing CORE_SYSTICK_HZ, it may be good to check if
20 // the conversion to microsecs should be using floats as intermediates.
21 return (int32_t)(((micros() - (uint32_t)start_ticks)) /
22 (CORE_SYSTICK_HZ / MICROSECS_IN_SEC));
23} // end SystickElapsedMicros()
24
25void SystickDelayMillis(uint32_t delay_ms) {
26 delay(delay_ms);
27} // end SystickDelayMillis()
Wrapper for Hardware Abstraction Layer (HAL) Contains replacements for hardware-specific functions Cu...