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.
main.cpp
- Committer:
- RAMIRORUBIO
- Date:
- 2016-04-18
- Revision:
- 0:63fef0f8da41
- Child:
- 1:9855b1065eae
File content as of revision 0:63fef0f8da41:
#include "mbed.h"
Serial pc(USBTX, USBRX); // tx, rx
Serial cam(PTC4,PTC3);
unsigned char reset[]={0x56,0x00,0x26,0x00};
unsigned char init_end[]="Init end";
unsigned char take_pic[]={0x56,0x00,0x36,0x01,0x00};
unsigned char taking_pic[]={0x76,0x00,0x36,0x00,0x00};
unsigned char read_size[]={0x56,0x00,0x34,0x01,0x00};
unsigned char return_size[]={0x76,0x00,0x34,0x00,0x04,0x00,0x00};
unsigned char read_pic[]={0x56,0x00,0x32,0x0C,0x00,0x0A,0x00,0x00,0x00,0x00,0x00,0x00};
unsigned char wait_time[]={0x00,0x0A};
unsigned char stop_pic[]={0x56,0x00,0x36,0x01,0x03};
unsigned char size[2];
unsigned char data_ready;
unsigned char buff[13000];
unsigned int i;
unsigned int j;
int main() {
i=0;
cam.baud(38400);
do
{
cam.printf("%c",reset[i++]);
}while(i<4);
i=0;
// pc.printf("reset\n");
do
{
if(cam.getc()==init_end[i])
{
i++;
};
}while(init_end[i]);
// pc.printf("START\n");
i=0;
do
{
cam.printf("%c",take_pic[i++]);
}while(i<5);
i=0;
do
{
if(cam.getc()==taking_pic[i])
{
i++;
};
}while(i<5);
i=0;
// pc.printf("pic taken\n");
wait(1);
do
{
cam.printf("%c",read_size[i++]);
}while(i<5);
i=0;
do
{
if(cam.getc()==return_size[i])
{
i++;
};
}while(i<7);
i=0;
size[0]=cam.getc();
size[1]=cam.getc();
/*
do
{
size[i++]=cam.getc();
}while(i<2);
*/
i=0;
// pc.printf("got size\n");
do
{
cam.printf("%c",read_pic[i++]);
}while(i<12);
i=0;
do
{
cam.printf("%c",size[i++]);
}while(i<2);
i=0;
do
{
cam.printf("%c",wait_time[i++]);
}while(i<2);
i=0;
do
{
buff[i]=cam.getc();
if(buff[i]==0xFF & !data_ready)
{
data_ready++;
}
else if(buff[i]==0xD9 & data_ready)
{
data_ready++;
}
else
{
data_ready=0;
}
i++;
}while(data_ready<2);
do
{
pc.printf("%c",buff[j++]);
}while(j<i);
}