aboutsummaryrefslogtreecommitdiffstats
path: root/wirish/wirish_shift.cpp
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2011-03-07 13:11:54 -0500
committerMarti Bolivar <mbolivar@leaflabs.com>2011-03-11 16:24:44 -0500
commitc8da1c3b7b6eb450138a00af9bbbee607f596837 (patch)
tree207777355d41dc8947d94665ef9a8bae8982805a /wirish/wirish_shift.cpp
parent5b07707cdaa6268e1a984727bb907a7b10e8ada7 (diff)
downloadlibrambutan-c8da1c3b7b6eb450138a00af9bbbee607f596837.tar.gz
librambutan-c8da1c3b7b6eb450138a00af9bbbee607f596837.zip
[WIP] GPIO refactor: seems ok, ready for review
Diffstat (limited to 'wirish/wirish_shift.cpp')
-rw-r--r--wirish/wirish_shift.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/wirish/wirish_shift.cpp b/wirish/wirish_shift.cpp
new file mode 100644
index 0000000..f67364d
--- /dev/null
+++ b/wirish/wirish_shift.cpp
@@ -0,0 +1,40 @@
+/*
+ * wiring_shift.c - shiftOut() function
+ * Part of Arduino - http://www.arduino.cc/
+ *
+ * Copyright (c) 2005-2006 David A. Mellis
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ *
+ * $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
+ */
+
+#include "wirish.h"
+
+void shiftOut(uint8 dataPin, uint8 clockPin, uint8 bitOrder, uint8 val) {
+ int i;
+
+ for (i = 0; i < 8; i++) {
+ if (bitOrder == LSBFIRST) {
+ digitalWrite(dataPin, !!(val & (1 << i)));
+ } else {
+ digitalWrite(dataPin, !!(val & (1 << (7 - i))));
+ }
+
+ digitalWrite(clockPin, HIGH);
+ digitalWrite(clockPin, LOW);
+ }
+}