aboutsummaryrefslogtreecommitdiffstats
path: root/wirish/io.h
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@mit.edu>2010-12-14 15:41:17 -0500
committerMarti Bolivar <mbolivar@mit.edu>2010-12-14 15:41:17 -0500
commit74c8937446e1be4e0d21f69a8c098e2caf7814d5 (patch)
tree1c7b8e4d93a9512ee54cdd6c5bb7ede064f96b3e /wirish/io.h
parent5ceac644e90c929e77f05d357d1d35d45e673fac (diff)
parentb67d281d85bd59a9738a9a43c4db1027f81d9208 (diff)
downloadlibrambutan-74c8937446e1be4e0d21f69a8c098e2caf7814d5.tar.gz
librambutan-74c8937446e1be4e0d21f69a8c098e2caf7814d5.zip
Merge branch 'master' into newdoc
Diffstat (limited to 'wirish/io.h')
-rw-r--r--wirish/io.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/wirish/io.h b/wirish/io.h
index 24f2611..547dc8e 100644
--- a/wirish/io.h
+++ b/wirish/io.h
@@ -33,6 +33,7 @@
#include "gpio.h"
#include "adc.h"
+#include "time.h"
#ifdef __cplusplus
extern "C"{
@@ -162,6 +163,63 @@ uint32 digitalRead(uint8);
*/
uint32 analogRead(uint8 pin);
+/**
+ * Toggles the digital value at the given pin.
+ *
+ * The pin must have its mode set to OUTPUT.
+ *
+ * @param pin the pin to toggle. If the pin is HIGH, set it LOW. If
+ * it is LOW, set it HIGH.
+ *
+ * @see pinMode()
+ */
+void togglePin(uint8 pin);
+
+/**
+ * Toggle the LED.
+ *
+ * If the LED is on, turn it off. If it is off, turn it on.
+ *
+ * The LED must its mode set to OUTPUT. This can be accomplished
+ * portably over all LeafLabs boards by calling pinMode(BOARD_LED_PIN,
+ * OUTPUT) before calling this function.
+ *
+ * @see pinMode()
+ */
+static inline void toggleLED() {
+ togglePin(BOARD_LED_PIN);
+}
+
+/**
+ * If the button is currently pressed, waits until the button is no
+ * longer being pressed, and returns true. Otherwise, returns false.
+ *
+ * The button pin must have its mode set to INPUT. This can be
+ * accomplished portably over all LeafLabs boards by calling
+ * pinMode(BOARD_BUTTON_PIN, INPUT).
+ *
+ * @see pinMode()
+ */
+uint8 isButtonPressed();
+
+/**
+ * Wait until the button is pressed and released, timing out if no
+ * press occurs.
+ *
+ * The button pin must have its mode set to INPUT. This can be
+ * accomplished portably over all LeafLabs boards by calling
+ * pinMode(BOARD_BUTTON_PIN, INPUT).
+ *
+ * @param timeout_millis Number of milliseconds to wait until the
+ * button is pressed. If timeout_millis is 0, wait forever.
+ *
+ * @return true, if the button was pressed; false, if the timeout was
+ * reached.
+ *
+ * @see pinMode()
+ */
+uint8 waitForButtonPress(uint32 timeout_millis);
+
#ifdef __cplusplus
} // extern "C"
#endif