aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2011-04-08 15:56:14 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2011-04-08 18:58:58 -0400
commitfe8fb8a931306a9701a7f7fa96e1880e1c3123bc (patch)
tree1c9e81ea41c3f217ef00def2da0335eb73fae004
parent5329ec3089b4fb6b3023d7f6a44eabcc30e3c9dd (diff)
downloadlibrambutan-fe8fb8a931306a9701a7f7fa96e1880e1c3123bc.tar.gz
librambutan-fe8fb8a931306a9701a7f7fa96e1880e1c3123bc.zip
Adding CLOCK_SPEED_MHZ and CLOCK_SPEED_HZ as derived board-specific values.
-rw-r--r--docs/source/lang/api/board-values.rst6
-rw-r--r--wirish/boards.h17
2 files changed, 21 insertions, 2 deletions
diff --git a/docs/source/lang/api/board-values.rst b/docs/source/lang/api/board-values.rst
index 367adbb..d6d78f6 100644
--- a/docs/source/lang/api/board-values.rst
+++ b/docs/source/lang/api/board-values.rst
@@ -18,6 +18,12 @@ boards. Some example usages are given :ref:`below
Constants
---------
+- ``CLOCK_SPEED_MHZ``: Clock speed of your board, in megahertz
+ (MHz). This is the same as ``CYCLES_PER_MICROSECOND``.
+
+- ``CLOCK_SPEED_HZ``: Clock speed of your board, in hertz (Hz). This
+ is the same as ``CLOCK_SPEED_MHZ * 1000000``.
+
- ``CYCLES_PER_MICROSECOND``: Number of CPU cycles per microsecond on
your board.
diff --git a/wirish/boards.h b/wirish/boards.h
index 8df7028..2515c00 100644
--- a/wirish/boards.h
+++ b/wirish/boards.h
@@ -119,8 +119,7 @@ bool boardUsesPin(uint8 pin);
/* Include the appropriate private header from boards/: */
-/* FIXME put boards/ before these paths once you stick make into the
- * IDE; current situation is a hack. */
+/* FIXME HACK put boards/ before these paths once IDE uses make. */
#ifdef BOARD_maple
#include "maple.h"
@@ -136,7 +135,21 @@ bool boardUsesPin(uint8 pin);
*/
#include "maple_RET6.h"
#else
+/*
+ * TODO turn this into a warning so people can:
+ *
+ * #include "my_board_config.h"
+ * #include "wirish.h"
+ *
+ * This will enable third-party board support without requiring that
+ * anybody hack around in libmaple itself.
+ */
#error "Board type has not been selected correctly."
#endif
+/* Set derived definitions */
+
+#define CLOCK_SPEED_MHZ CYCLES_PER_MICROSECOND
+#define CLOCK_SPEED_HZ (CLOCK_SPEED_MHZ * 1000000UL)
+
#endif