aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple/delay.h
diff options
context:
space:
mode:
authorPerry Hung <iperry@gmail.com>2011-03-21 02:45:58 -0400
committerPerry Hung <iperry@gmail.com>2011-03-21 02:47:53 -0400
commit7241820179bb729d14900676fbff943f7f44cb97 (patch)
treed60a38f908eda00b934b6d3452f6a777c4277be6 /libmaple/delay.h
parent1591fc9e3f851327c16bbcb88e6abee1706f9cfc (diff)
parentc73306508820705eef4f2cb9f8542acdba599cd8 (diff)
downloadlibrambutan-7241820179bb729d14900676fbff943f7f44cb97.tar.gz
librambutan-7241820179bb729d14900676fbff943f7f44cb97.zip
Merge branch 'i2c-wip' into refactor
Conflicts: examples/test-fsmc.cpp libmaple/rules.mk wirish/boards.h
Diffstat (limited to 'libmaple/delay.h')
-rw-r--r--libmaple/delay.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/libmaple/delay.h b/libmaple/delay.h
new file mode 100644
index 0000000..10839c9
--- /dev/null
+++ b/libmaple/delay.h
@@ -0,0 +1,22 @@
+/**
+ * @brief
+ */
+
+#ifndef _DELAY_H_
+#define _DELAY_H_
+
+static inline void delay_us(uint32 us) {
+ /* So (2^32)/12 micros max, or less than 6 minutes */
+ us *= 12;
+
+ /* fudge for function call overhead */
+ us--;
+ asm volatile(" mov r0, %[us] \n\t"
+ "1: subs r0, #1 \n\t"
+ " bhi 1b \n\t"
+ :
+ : [us] "r" (us)
+ : "r0");
+}
+#endif
+