Basis for the C2 protocol from Silicon Labs.

Dependencies:   mbed

Revision:
12:49ac91452d77
Parent:
11:2b19d52ea37c
Child:
13:45aaa8847c2b
--- a/main.cpp	Sun May 25 17:43:50 2014 +0000
+++ b/main.cpp	Sun May 25 17:52:29 2014 +0000
@@ -204,6 +204,13 @@
     return -1;
 }
 
+static void c2_enable_pi(void) {
+    c2ck_reset();
+    c2_write_ar(C2_FPCTL);
+    if ((c2_write_dr(0x02)+c2_write_dr(0x04)+c2_write_dr(0x02))<0)
+        fatal("cannot enable PI");
+    wait_us(21);
+}
 
 int main() {
     int i, c, devid, revid;
@@ -213,7 +220,7 @@
 
 //    printf("\033[H\033[J");
     printf("\n\rSiLabs C2 Protocol\n\r\n\r");
-    printf("Connect C2CK (clock) to p5 and C2D (data) to p6\n\r\n\r");
+    printf("Connect C2GND to GND, C2CK (clock) to p5 and C2D (data) to p6\n\r\n\r");
     printf("Press any key to continue\n\r");
 
     getc(stdin);
@@ -240,4 +247,7 @@
     printf("\n\rDevice found: %s (%02X:%02X)", devices[i].name, devid, revid);
     printf("\n\rFPDAT Address: 0x%02X", C2_FPDAT);
     printf("\n\rPage Size: %i\n\r", page_size);
+    
+    printf("\n\rEnabling Programming Interface\n\r");
+    c2_enable_pi();
 }
\ No newline at end of file