Test arduino code
Fork of ArduinoHAL by
Revision 5:52ed7aa62e95, committed 2015-02-12
- Comitter:
- fblanc
- Date:
- Thu Feb 12 10:19:00 2015 +0000
- Parent:
- 4:40396527a068
- Commit message:
- ArduinoHAL->ArduinoFB; delay(); px->Dx;
Changed in this revision
--- a/Arduino.c Sat Jun 04 20:16:04 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-#include "Arduino.h"
-#include "mbed.h"
-
-
-
-static DigitalInOut allpins[] = {LED1, LED2, LED3, LED4, NC, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27, p28, p29, p30};
-
-void digitalWrite(int pin, int value)
-{
- //allpins[pin].output();
- allpins[pin].write(value);
-}
-
-void pinMode(int pin, int mode)
-{
- if(mode == INPUT)
- {
- allpins[pin].input();
- }
- if(mode == OUTPUT)
- {
- allpins[pin].output();
- }
-
-}
-
-int digitalRead(int pin)
-{
- //allpins[pin].input();
- return allpins[pin].read();
-}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Arduino.cpp Thu Feb 12 10:19:00 2015 +0000
@@ -0,0 +1,31 @@
+#include "Arduino.h"
+#include "mbed.h"
+
+
+
+static DigitalInOut allpins[] = {D0,D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15};
+
+void digitalWrite(int pin, int value)
+{
+ //allpins[pin].output();
+ allpins[pin].write(value);
+}
+
+void pinMode(int pin, int mode)
+{
+ if(mode == INPUT)
+ {
+ allpins[pin].input();
+ }
+ if(mode == OUTPUT)
+ {
+ allpins[pin].output();
+ }
+
+}
+
+int digitalRead(int pin)
+{
+ //allpins[pin].input();
+ return allpins[pin].read();
+}
\ No newline at end of file
--- a/wiring.h Sat Jun 04 20:16:04 2011 +0000 +++ b/wiring.h Thu Feb 12 10:19:00 2015 +0000 @@ -89,7 +89,11 @@ #define bit(b) (1UL << (b)) - +/** Macro for delay() + * + * @param void + */ +#define delay(x) (wait_ms(x)) void init(void);
--- a/wiring_pulse.c Sat Jun 04 20:16:04 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
- wiring_pulse.c - pulseIn() 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 "wiring_private.h"
-
-/* Measures the length (in microseconds) of a pulse on the pin; state is HIGH
- * or LOW, the type of pulse to measure. Works on pulses from 2-3 microseconds
- * to 3 minutes in length, but must be called at least a few dozen microseconds
- * before the start of the pulse. */
-unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout)
-{
- //not implemented
- return 0;
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/wiring_pulse.cpp Thu Feb 12 10:19:00 2015 +0000
@@ -0,0 +1,35 @@
+/*
+ wiring_pulse.c - pulseIn() 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 "wiring_private.h"
+
+/* Measures the length (in microseconds) of a pulse on the pin; state is HIGH
+ * or LOW, the type of pulse to measure. Works on pulses from 2-3 microseconds
+ * to 3 minutes in length, but must be called at least a few dozen microseconds
+ * before the start of the pulse. */
+unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout)
+{
+ //not implemented
+ return 0;
+}
--- a/wiring_shift.c Sat Jun 04 20:16:04 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
- 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 "wiring_private.h"
-
-uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder) {
- uint8_t value = 0;
- uint8_t i;
-
- for (i = 0; i < 8; ++i) {
- digitalWrite(clockPin, HIGH);
- if (bitOrder == LSBFIRST)
- value |= digitalRead(dataPin) << i;
- else
- value |= digitalRead(dataPin) << (7 - i);
- digitalWrite(clockPin, LOW);
- }
- return value;
-}
-
-void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val)
-{
- uint8_t 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);
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/wiring_shift.cpp Thu Feb 12 10:19:00 2015 +0000
@@ -0,0 +1,55 @@
+/*
+ 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 "wiring_private.h"
+
+uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder) {
+ uint8_t value = 0;
+ uint8_t i;
+
+ for (i = 0; i < 8; ++i) {
+ digitalWrite(clockPin, HIGH);
+ if (bitOrder == LSBFIRST)
+ value |= digitalRead(dataPin) << i;
+ else
+ value |= digitalRead(dataPin) << (7 - i);
+ digitalWrite(clockPin, LOW);
+ }
+ return value;
+}
+
+void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val)
+{
+ uint8_t 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);
+ }
+}
frederic blanc
