Skip to content

Commit f2801f1

Browse files
committed
core: add time related macros
Fixes compilation error found at https://www.cnx-software.com/2024/12/10/arduino-core-for-zephyr-beta-released/
1 parent 0c78c6b commit f2801f1

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Diff for: 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;

Diff for: 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)