Skip to content

Commit 5a2af3d

Browse files
authored
Merge pull request #11 from facchinm/time_macros
core: add time related macros
2 parents 0c78c6b + f2801f1 commit 5a2af3d

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

cores/arduino/Arduino.h

+1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ int digitalPinToInterrupt(pin_size_t pin);
113113
#include <zephyrSerial.h>
114114
#include <strings.h>
115115
#include <api/itoa.h>
116+
#include <time_macros.h>
116117

117118
// Allow namespace-less operations if Arduino.h is included
118119
using namespace arduino;

cores/arduino/time_macros.h

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#pragma once
2+
3+
#include <zephyr/sys/time_units.h>
4+
5+
#define clockCyclesPerMicrosecond() (1000000 / k_cyc_to_ns_near64(1000))
6+
#define clockCyclesToMicroseconds(a) (a / clockCyclesPerMicrosecond())
7+
#define microsecondsToClockCycles(a) (a * clockCyclesPerMicrosecond())

0 commit comments

Comments
 (0)