|
@@ -11,6 +11,13 @@ env.Append(CXXFLAGS=[
|
11
|
11
|
#"-Wno-sign-compare"
|
12
|
12
|
])
|
13
|
13
|
|
|
14
|
+#
|
|
15
|
+# Add CPU frequency as a compile time constant instead of a runtime variable
|
|
16
|
+#
|
|
17
|
+def add_cpu_freq():
|
|
18
|
+ if 'BOARD_F_CPU' in env:
|
|
19
|
+ env['BUILD_FLAGS'].append('-DBOARD_F_CPU=' + env['BOARD_F_CPU'])
|
|
20
|
+
|
14
|
21
|
# Useful for JTAG debugging
|
15
|
22
|
#
|
16
|
23
|
# It will separe release and debug build folders.
|
|
@@ -20,3 +27,9 @@ env.Append(CXXFLAGS=[
|
20
|
27
|
#
|
21
|
28
|
if env.GetBuildType() == "debug":
|
22
|
29
|
env['BUILD_DIR'] = '$PROJECT_BUILD_DIR/$PIOENV/debug'
|
|
30
|
+
|
|
31
|
+# On some platform, F_CPU is a runtime variable. Since it's used to convert from ns
|
|
32
|
+# to CPU cycles, this adds overhead preventing small delay (in the order of less than
|
|
33
|
+# 30 cycles) to be generated correctly. By using a compile time constant instead
|
|
34
|
+# the compiler will perform the computation and this overhead will be avoided
|
|
35
|
+add_cpu_freq()
|