发表于:2007-01-04 22:25:00
楼主
typedef struct{
unsigned char Len;
unsigned char Buff[10];
}CMD_BUFFER;
CMD_BUFFER Cmd;
bool SendCommand(void)
{
unsigned char CmdHeader[4] = {0x55, 0x41, 0x52, 0x54}; //"UART"
UART_SendData(CmdHeader,4);
UART_SendData(Cmd.Buff,Cmd.Len);
UART_RdReady();
return true;
}
void ClrCmdBuff(void)
{
int i;
for(i=0;i<7;i++) Cmd.Buff[i]=0x0;
}
//停止更新Frame buffer
void CmdStopFBuf(void)
{
ClrCmdBuff();
Cmd.Buff[0] = 0xcA;
Cmd.Len = 7;
SendCommand();
}
//启动更新Frame buffer
void CmdResumeFBuf(void)
{
ClrCmdBuff();
Cmd.Buff[0] = 0xCB;
Cmd.Len = 7;
SendCommand();
//获取Frame buffer大小
long CmdGetFBufLen(void)
{
long dwFrameLen;
ClrCmdBuff();
Cmd.Buff[0] = 0xc9;
Cmd.Len = 7;
SendCommand();
if(UART_GetData(RecBuff,3))
{
dwFrameLen = ( ((DWORD)(RecBuff[0]) & 0xFF) << 16 ) +
( ((DWORD)(RecBuff[1]) & 0xFF) << 8 ) +
( ((DWORD)(RecBuff[2]) & 0xFF) );
return dwFrameLen;
}
else
return false;
}
//读取Frame buffer指定偏移量开始的指定大小,如果您的系统RAM足够大,也可以一次读取完。
bool CmdReadFBuf(long offset, unsigned int rd_len)
{
Cmd.Buff[0] = 0xc7;
Cmd.Buff[1] = (BYTE)( offset >> 16 );
Cmd.Buff[2] = (BYTE)( offset >> 8 );
Cmd.Buff[3] = (BYTE)( offset );
Cmd.Buff[4] = (BYTE)0x00;
Cmd.Buff[5] = (BYTE)( rd_len >> 8 );
Cmd.Buff[6] = (BYTE)( rd_len );
Cmd.Len = 7;
SendCommand();
if(UART_GetData(RecBuff,rd_len)==0)
return false;
return true;
}
功能介绍:
1. CMOS SENSOR,分辨率:VGA 640X480
2. 图像压缩格式:JPG, 通过串口数据通讯读取
3. 3种工作模式:实时图像模式、运动图像监测模式和省电模式
4. 通讯方式:RS232, RS488;最高波特率:115200
5. 视频复合(CVBS)信号输出
ezcamera@tom.com