thanks to Zoltan Hudak publish the way to use stm32f103c8t6 on mbed. now you can use it with Wii IRcam

Dependencies:   mbed-STM32F103C8T6 mbed

Fork of Wii_IRCam_Test by Michael Shimniok

Files at this revision

API Documentation at this revision

Comitter:
Zeran
Date:
Tue May 23 17:30:11 2017 +0000
Parent:
1:150525e9c21f
Commit message:
stm32f103c8t6 wii ircam

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-STM32F103C8T6.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 150525e9c21f -r 43bff54a5f67 main.cpp
--- a/main.cpp	Fri Dec 31 09:33:30 2010 +0000
+++ b/main.cpp	Tue May 23 17:30:11 2017 +0000
@@ -1,3 +1,4 @@
+#include "stm32f103c8t6.h"
 #include "mbed.h"
 
 // Adapted from kako's source code: http://www.kako.com/neta/2008-009/2008-009.html
@@ -12,9 +13,10 @@
 //
 
 DigitalOut myled(LED1);
-PwmOut servo(p21);
-Serial pc(USBTX, USBRX); // tx, rx
-I2C i2c(p9, p10);        // sda, scl
+//PwmOut servo(PA_0);
+
+//I2C i2c(PB_7, PB_6);        // sda, scl
+I2C i2c(PB_9, PB_8);        // sda, scl
 const int addr = 0xB0;   // define the I2C Address of camera
 
 void i2c_write2(int addr, char a, char b)
@@ -27,17 +29,6 @@
     wait(0.07); // delay 70ms    
 }
 
-void clock_init()
-{
-    // set up ~20-25MHz clock on p21
-    LPC_PWM1->TCR = (1 << 1);               // Reset counter, disable PWM
-    LPC_SC->PCLKSEL0 &= ~(0x3 << 12);  
-    LPC_SC->PCLKSEL0 |= (1 << 12);          // Set peripheral clock divider to /1, i.e. system clock
-    LPC_PWM1->MR0 = 4;                     // Match Register 0 is shared period counter for all PWM1
-    LPC_PWM1->MR6 = 2;                      // Pin 21 is PWM output 6, so Match Register 6
-    LPC_PWM1->LER |= 1;                     // Start updating at next period start
-    LPC_PWM1->TCR = (1 << 0) || (1 << 3);   // Enable counter and PWM
-}
 
 void cam_init()
 {
@@ -52,13 +43,15 @@
 }
 
 int main() {
+    Serial      pc(PA_2, PA_3);
+    confSysClock();
     char cmd[8];
     char buf[16];
     int Ix1,Iy1,Ix2,Iy2;
     int Ix3,Iy3,Ix4,Iy4;
     int s;
 
-    clock_init();
+
     
     // PC serial output    
     pc.baud(115200);
@@ -105,7 +98,21 @@
         // print the coordinate data
         //pc.printf("Ix1: %4d, Iy1: %4d\n", Ix1, Iy1 );
         //pc.printf("Ix2: %4d, Iy2: %4d\n", Ix2, Iy2 );
-        pc.printf("%d,%d,%d,%d,%d,%d,%d,%d\r\n", Ix1, Iy1, Ix2, Iy2, Ix3, Iy3, Ix4, Iy4);
+        //pc.printf("%d,%d,%d,%d,%d,%d,%d,%d\r\n", Ix1, Iy1, Ix2, Iy2, Ix3, Iy3, Ix4, Iy4);
+        if (Ix1 <1023 && Iy1<1023) {
+            //pc.printf("%d\r\n",Ix1);
+            if (Ix1 > 512) {
+                pc.printf("a");
+            } else {
+                pc.printf("d");
+            }
+            if (Iy1 > 512) {
+                pc.printf("w");
+            } else {
+                pc.printf("s");
+            }
+        }
+        
         
         wait(0.050);
     }
diff -r 150525e9c21f -r 43bff54a5f67 mbed-STM32F103C8T6.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-STM32F103C8T6.lib	Tue May 23 17:30:11 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/hudakz/code/mbed-STM32F103C8T6/#09d8c2eacb4d
diff -r 150525e9c21f -r 43bff54a5f67 mbed.bld
--- a/mbed.bld	Fri Dec 31 09:33:30 2010 +0000
+++ b/mbed.bld	Tue May 23 17:30:11 2017 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e
+http://mbed.org/users/mbed_official/code/mbed/builds/176b8275d35d
\ No newline at end of file