Basis for the C2 protocol from Silicon Labs.

Dependencies:   mbed

Revision:
1:7a82f806fe92
Parent:
0:902f10e5d3e0
Child:
2:9092d0d1558b
--- a/main.cpp	Sat May 24 11:25:49 2014 +0000
+++ b/main.cpp	Sat May 24 11:54:33 2014 +0000
@@ -1,8 +1,68 @@
+/*
+ * SiLabs C2 Protocol on mbed pins p5/p6
+ *
+ * Copyright (c) 2014, Ivo van Poorten <ivopvp@gmail.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+ 
 #include "mbed.h"
 
 DigitalOut c2ck(p5);
 DigitalInOut c2d(p6);
 
+static void c2ck_reset(void) {
+    c2ck = 0;
+    wait_us(25);
+    c2ck = 1;
+    wait_us(1);
+}
+
+static void c2ck_strobe(void) {
+    c2ck = 0;
+    wait_us(1);
+    c2ck = 1;
+    wait_us(1);
+}
+
+// Four basic C2 Instructions
+//
+// 00b  Data Read
+// 01b  Data Write
+// 10b  Address Read
+// 11b  Address Write
+
+
 int main() {
-    printf("SiLabs C2 Protocol\n\r");
+    int c;
+    
+    c2d.input();
+    c2ck = 1;
+
+    printf("SiLabs C2 Protocol\n\r\n\r");
+    printf("Connect C2CK (clock) to p5 and C2D (data) to p6\n\r\n\r");
+    printf("Press any key to continue\n\r");
+    
+    c = getc(stdin);
+    
+    printf("\n\rHello, world\n\r");
 }