![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
thanks to Zoltan Hudak publish the way to use stm32f103c8t6 on mbed. now you can use it with MPC4725 DAC
Dependencies: mbed-STM32F103C8T6 mbed
Fork of Wii_IRCam_Test by
main.cpp
- Committer:
- Zeran
- Date:
- 2017-05-23
- Revision:
- 2:2b68d1d14aca
- Parent:
- 1:150525e9c21f
- Child:
- 3:37fb1e2aacf3
File content as of revision 2:2b68d1d14aca:
#include "stm32f103c8t6.h" #include "mbed.h" #include "mcp4725.h" // Adapted from kako's source code: http://www.kako.com/neta/2008-009/2008-009.html // i2c protocol details from - http://blog.makezine.com/archive/2008/11/hacking_the_wiimote_ir_ca.html // wiring from - http://translate.google.com/translate?u=http://www.kako.com/neta/2007-001/2007-001.html&hl=en&ie=UTF-8&sl=ja&tl=en // obviously mbed is 3.3v so no level translation is needed // using built in i2c on pins 9/10 // // PC GUI client here: http://code.google.com/p/wii-cam-blobtrack/ // // Interfacing details here: http://www.bot-thoughts.com/2010/12/connecting-mbed-to-wiimote-ir-camera.html // MCP4725 mcp4725_interface(PB_9, PB_8, MCP4725::Standard100kHz, 0);//sda,scl,bus_frequency,device_address_bit // modes : Standard100kHz Fast400kHz HighSpeed3_4Mhz DigitalOut F_R(PC_14); //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 //int c = 0; int main() { Serial pc(PA_2, PA_3); confSysClock(); // PC serial output pc.baud(115200); //pc.printf("Initializing camera..."); int dac_value = (int) (0xFFF * (0/3.3) ); mcp4725_interface.write(MCP4725::Normal, dac_value, false); //modes: Normal PowerDown1k PowerDown100k PowerDown500k // read I2C stuff while(1) { if(pc.readable()) { char c = pc.getc();//-128; //c = c*3; //pc.putc(c); if (c>=0x80) { F_R = 1; c = c - 127; //pc.putc(c); mcp4725_interface.write(MCP4725::Normal,uint16_t(c*20),false); } else { F_R = 0; c = 127 - c; //pc.putc(c); mcp4725_interface.write(MCP4725::Normal,uint16_t(c*20),false); } } /*for(int i = 0; i<0xFFF; i++){ mcp4725_interface.write(MCP4725::Normal, i, false); wait(0.01); }*/ } }