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.
Dependencies: mbed-STM32F103C8T6 mbed
Fork of Wii_IRCam_Test by
Revision 2:43bff54a5f67, committed 2017-05-23
- Comitter:
- Zeran
- Date:
- Tue May 23 17:30:11 2017 +0000
- Parent:
- 1:150525e9c21f
- Commit message:
- stm32f103c8t6 wii ircam
Changed in this revision
--- 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);
}
--- /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
--- 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
