read from arduino with 320*240 data flow 2Mbit
Dependencies: mbed
main.cpp@0:e191453b86ba, 2018-12-15 (annotated)
- Committer:
- xkzy
- Date:
- Sat Dec 15 04:18:06 2018 +0000
- Revision:
- 0:e191453b86ba
done with exp1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
xkzy | 0:e191453b86ba | 1 | #include "mbed.h" |
xkzy | 0:e191453b86ba | 2 | RawSerial pc(SERIAL_TX, SERIAL_RX); //has to use rawserial ,serial too slow and has byte loss. |
xkzy | 0:e191453b86ba | 3 | RawSerial cam(PA_11, PA_12); |
xkzy | 0:e191453b86ba | 4 | DigitalOut read_state(LED1); |
xkzy | 0:e191453b86ba | 5 | InterruptIn frame_start(PC_5); |
xkzy | 0:e191453b86ba | 6 | uint8_t image[76800]; |
xkzy | 0:e191453b86ba | 7 | uint32_t pix_count; |
xkzy | 0:e191453b86ba | 8 | bool reading; |
xkzy | 0:e191453b86ba | 9 | void count_reset(){ |
xkzy | 0:e191453b86ba | 10 | pix_count = 0; |
xkzy | 0:e191453b86ba | 11 | reading=!reading; |
xkzy | 0:e191453b86ba | 12 | } |
xkzy | 0:e191453b86ba | 13 | int main() { |
xkzy | 0:e191453b86ba | 14 | |
xkzy | 0:e191453b86ba | 15 | pc.baud(2000000); |
xkzy | 0:e191453b86ba | 16 | cam.baud(2000000); |
xkzy | 0:e191453b86ba | 17 | frame_start.fall(&count_reset); |
xkzy | 0:e191453b86ba | 18 | while(1) { |
xkzy | 0:e191453b86ba | 19 | pix_count=0; |
xkzy | 0:e191453b86ba | 20 | while(pix_count<76800){ |
xkzy | 0:e191453b86ba | 21 | if(cam.readable()) { |
xkzy | 0:e191453b86ba | 22 | image[pix_count++]=cam.getc(); |
xkzy | 0:e191453b86ba | 23 | } |
xkzy | 0:e191453b86ba | 24 | } |
xkzy | 0:e191453b86ba | 25 | for(int u=0;u<76800;u++){ |
xkzy | 0:e191453b86ba | 26 | pc.putc(image[u]); |
xkzy | 0:e191453b86ba | 27 | } |
xkzy | 0:e191453b86ba | 28 | } |
xkzy | 0:e191453b86ba | 29 | } |