Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 0:de199215b4c0
- Child:
- 1:de94ad0f7925
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Apr 03 14:05:40 2014 +0000
@@ -0,0 +1,41 @@
+#include "mbed.h"
+
+DigitalOut myled(LED1);
+Serial pc(USBTX, USBRX);
+
+// (GS1011MxxS / pin)
+SPI gs(p5, p6, p7); // mosi(DIN/5), miso(DOUT/8), sck(CLK/7)
+DigitalOut cs(p8); // cs(CS/6)
+DigitalIn hw(p9); // host wakeup(GPIO28/2)
+
+int main() {
+ char c;
+
+ pc.baud(115200);
+ gs.format(8, 0);
+ gs.frequency(3000000);
+ hw.mode(PullDown);
+ myled = 1;
+ cs = 1;
+
+ for (;;) {
+ if (pc.readable()) {
+ cs = 0;
+ c = gs.write(pc.getc());
+ if (c != 0xf5)
+ pc.printf("%02x_", c);
+ cs = 1;
+ }
+ if (hw == 1) {
+ cs = 0;
+ c = gs.write(0xf5);
+ cs = 1;
+ if ((c >= 0x20 && c < 0x7f) || c == 0x0d || c == 0x0a) {
+ pc.printf("%c", c);
+ } else
+ if (c != 0xf5) {
+ pc.printf("%02x ", c);
+ }
+ }
+ }
+}