![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Test Code for OV7670 Camera module. The images are sent over ethernet link.
Dependencies: EthernetInterface mbed-rtos mbed ov7670
You can find more information in this page: https://mbed.org/users/edodm85/notebook/ov7670-camera-and-ethernet-stream/
main.h@2:d6b38a4512eb, 2014-02-15 (annotated)
- Committer:
- edodm85
- Date:
- Sat Feb 15 15:17:08 2014 +0000
- Revision:
- 2:d6b38a4512eb
- Parent:
- 0:2208b72b1ba1
- Child:
- 3:df8de18d7fa9
Updated
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
edodm85 | 0:2208b72b1ba1 | 1 | #pragma once |
edodm85 | 0:2208b72b1ba1 | 2 | #include "mbed.h" |
edodm85 | 0:2208b72b1ba1 | 3 | #include "ov7670.h" |
edodm85 | 0:2208b72b1ba1 | 4 | #include "EthernetInterface.h" |
edodm85 | 0:2208b72b1ba1 | 5 | |
edodm85 | 0:2208b72b1ba1 | 6 | |
edodm85 | 0:2208b72b1ba1 | 7 | #define ECHO_SERVER_PORT 2000 |
edodm85 | 0:2208b72b1ba1 | 8 | |
edodm85 | 0:2208b72b1ba1 | 9 | |
edodm85 | 0:2208b72b1ba1 | 10 | Timer t; |
edodm85 | 0:2208b72b1ba1 | 11 | bool new_send = false; |
edodm85 | 0:2208b72b1ba1 | 12 | |
edodm85 | 0:2208b72b1ba1 | 13 | DigitalOut led1(LED1); |
edodm85 | 0:2208b72b1ba1 | 14 | DigitalOut led2(LED2); |
edodm85 | 0:2208b72b1ba1 | 15 | DigitalOut led3(LED3); |
edodm85 | 0:2208b72b1ba1 | 16 | DigitalOut led4(LED4); |
edodm85 | 0:2208b72b1ba1 | 17 | |
edodm85 | 0:2208b72b1ba1 | 18 | //Camera |
edodm85 | 0:2208b72b1ba1 | 19 | OV7670 camera |
edodm85 | 0:2208b72b1ba1 | 20 | ( |
edodm85 | 0:2208b72b1ba1 | 21 | p28,p27, // SDA,SCL(I2C / SCCB) |
edodm85 | 0:2208b72b1ba1 | 22 | p23,p24,p25, // VSYNC,HREF,WEN(FIFO) |
edodm85 | 0:2208b72b1ba1 | 23 | Port0,0x07878000, // PortIn data p18(P0.26),p17(P0.25),p16(P0.24),p15(P0.23),p11(P0.18),p12(P0.17),p14(P0.16),p13(P0.15) |
edodm85 | 0:2208b72b1ba1 | 24 | p26,p29,p30 // RRST,OE,RCLK |
edodm85 | 0:2208b72b1ba1 | 25 | ); |
edodm85 | 0:2208b72b1ba1 | 26 | |
edodm85 | 0:2208b72b1ba1 | 27 | //ETHERNET |
edodm85 | 0:2208b72b1ba1 | 28 | char* ip = "192.168.153.153"; // ip |
edodm85 | 0:2208b72b1ba1 | 29 | char* mask = "255.255.255.0"; // mask |
edodm85 | 2:d6b38a4512eb | 30 | char* gateway = "192.168.153.130"; // gateway |
edodm85 | 0:2208b72b1ba1 | 31 | EthernetInterface eth; |
edodm85 | 0:2208b72b1ba1 | 32 | TCPSocketConnection client; |
edodm85 | 0:2208b72b1ba1 | 33 | TCPSocketServer server; |
edodm85 | 0:2208b72b1ba1 | 34 | |
edodm85 | 0:2208b72b1ba1 | 35 | //ETHERNET BUFFER |
edodm85 | 0:2208b72b1ba1 | 36 | char bufferRX[20]; |
edodm85 | 2:d6b38a4512eb | 37 | char bufferTX[4800]; |
edodm85 | 0:2208b72b1ba1 | 38 | |
edodm85 | 0:2208b72b1ba1 | 39 | //RESET |
edodm85 | 0:2208b72b1ba1 | 40 | extern "C" void mbed_reset(); |
edodm85 | 0:2208b72b1ba1 | 41 | |
edodm85 | 0:2208b72b1ba1 | 42 | //TIMER |
edodm85 | 0:2208b72b1ba1 | 43 | int t1 = 0; |
edodm85 | 0:2208b72b1ba1 | 44 | int t2 = 0; |
edodm85 | 0:2208b72b1ba1 | 45 | |
edodm85 | 0:2208b72b1ba1 | 46 | //THREAD |
edodm85 | 0:2208b72b1ba1 | 47 | void net_thread(void const *argument); |
edodm85 | 0:2208b72b1ba1 | 48 | osThreadDef(net_thread, osPriorityNormal, DEFAULT_STACK_SIZE); |
edodm85 | 0:2208b72b1ba1 | 49 | |
edodm85 | 0:2208b72b1ba1 | 50 | //FUNCTION |
edodm85 | 0:2208b72b1ba1 | 51 | void Send(); |
edodm85 | 0:2208b72b1ba1 | 52 | void parse_cmd(); |
edodm85 | 0:2208b72b1ba1 | 53 | void CameraSnap(); |