I made Digital Camera using Arducam & WIZwiki-W7500
Dependencies: Arduino Arducam_OV5642 SDFileSystem Arducam_UTFT_SPI WIZnetInterface_Ricky mbed
main.cpp
- Committer:
- justinkim
- Date:
- 2015-10-29
- Revision:
- 2:3a12c5e8b030
- Parent:
- 1:3a14a4c84db2
- Child:
- 3:23d439c8526b
File content as of revision 2:3a12c5e8b030:
#include "mbed.h" #include "UTFT_SPI.h" #include "OV5642.h" #include "OV5642_regs.h" #include "Arduino.h" void setup(); void loop(); ArduCAM myCAM(D11, D12, D13, D10, D14, D15); ArduLCD myGLCD(D11, D12, D13, D10); Serial pc(USBTX, USBRX); int main() { *(volatile uint32_t *)(0x41001014) = 0x0060100; //clock 48MHz setup(); while(1) { loop(); } } void setup() { uint8_t vid,pid; uint8_t temp; pc.baud(115200); pc.printf("ArduCAM Start!\r\n"); uint8_t temp1,temp2; myCAM.write_reg(ARDUCHIP_TEST1, 0x55); //Write to test1 register by 0x55 myCAM.write_reg(ARDUCHIP_TEST2, 0xAA); //Write to test1 register by 0xaa wait_ms(1000); temp1 = myCAM.read_reg(ARDUCHIP_TEST1); //Read from test1 register temp2 = myCAM.read_reg(ARDUCHIP_TEST2); //Read from test1 register pc.printf("temp1 : %d\r\n",temp1); pc.printf("temp2 : %d\r\n",temp2); wait_ms(1000); myCAM.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM.read_reg(ARDUCHIP_TEST1); if(temp != 0x55) { pc.printf("SPI interface Error!\r\n"); while(1); } //Change MCU mode myCAM.set_mode(MCU2LCD_MODE); //Initialize the LCD Module myGLCD.InitLCD(); //Check if the camera module type is OV5642 myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); if((vid != 0x56) || (pid != 0x42)) pc.printf("Can't find OV5642 module!\r\n"); else pc.printf("OV5642 detected\r\n"); myCAM.InitCAM(); } void loop() { myCAM.set_mode(CAM2LCD_MODE); //Switch to CAM while(1) { if(!myCAM.get_bit(ARDUCHIP_TRIG,VSYNC_MASK)) //New Frame is coming { myCAM.set_mode(MCU2LCD_MODE); //Switch to MCU myGLCD.resetXY(); myCAM.set_mode(CAM2LCD_MODE); //Switch to CAM while(!myCAM.get_bit(ARDUCHIP_TRIG,VSYNC_MASK)); //Wait for VSYNC is gone } } }