CameraC328
Dependents: CameraC328_TestProgram CameraC328_Thresholding Camera_TestProgram_2015 Camera_TestProgram_2015 ... more
Diff: CameraC328.h
- Revision:
- 3:6d3150d4396a
- Parent:
- 2:6a72fcad5c0a
- Child:
- 4:ad06342d4b84
diff -r 6a72fcad5c0a -r 6d3150d4396a CameraC328.h --- a/CameraC328.h Mon Jun 28 13:57:15 2010 +0000 +++ b/CameraC328.h Tue Jun 29 11:45:53 2010 +0000 @@ -1,12 +1,19 @@ +/** + * C328-7640 device driver class + * Reference documents: C328-7640 User Manual v3.0 2004.8.19 + * + * Version 0.0.1 + * + * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems) + * shinta.main.jp@gmail.com + * http://shinta.main.jp/ + */ + #include "mbed.h" class CameraC328 { public: - CameraC328(PinName tx, PinName rx); - - ~CameraC328(); - enum ColorType { GrayScale2bit = 0x01, // 2bit for Y only GrayScale4bit = 0x02, // 4bit for Y only @@ -51,11 +58,6 @@ SendPictureError = 0xf5, SendCommandError = 0xff }; - - enum SnapshotType { - CompressedPicture = 0x00, - UncompressedPicture = 0x01 - }; enum PictureType { SnapshotPicture = 0x01, @@ -63,55 +65,61 @@ JpegPreviewPicture = 0x05 }; + enum SnapshotType { + CompressedPicture = 0x00, + UncompressedPicture = 0x01 + }; + + enum Baud { + Baud7200 = 7200, + Baud9600 = 9600, + Baud14400 = 14400, + Baud19200 = 19200, // Default. + Baud28800 = 28800, + Baud38400 = 38400, + Baud57600 = 57600, + Baud115200 = 115200 + }; + + enum ResetType { + ResetWholeSystem = 0x00, + ResetStateMachines = 0x01 + }; + + enum DataType { + DataTypeSnapshotPicture = 0x01, + DataTypePreviewPicture = 0x02, + DataTypeJpegPreviewPicture = 0x05 + }; + + CameraC328(PinName tx, PinName rx, Baud baud = Baud19200); + + ~CameraC328(); + ErrorNumber sync(); ErrorNumber init(ColorType ct, RawResolution rr, JpegResolution jr); - ErrorNumber getJpegSnapshotPicture(void(*func)(size_t done, size_t total, char c)); + ErrorNumber getUncompressedSnapshotPicture(void(*func)(size_t done, size_t total, char c)); + ErrorNumber getUncompressedPreviewPicture(void(*func)(size_t done, size_t total, char c)); private: Serial serial; - bool syncdone; static const int COMMAND_LENGTH = 6; - static const int TIMEOUT_US = 1200; - static const int BAUD = 57600; static const int SYNCMAX = 60; - /** - * Send bytes to camera module. - * - * @param buf Pointer to the data buffer. - * @param len Length of the data buffer. - * - * @return True if the data sended. - */ - bool sendBytes(char *buf, size_t len); - - /** - * Receive bytes from camera module. - * - * @param buf Pointer to the data buffer. - * @param len Length of the data buffer. - * - * @return True if the data received. - */ - bool recvBytes(char *buf, size_t len); + ErrorNumber sendInitial(ColorType ct, RawResolution rr, JpegResolution jr); + ErrorNumber sendGetPicture(PictureType pt); + ErrorNumber sendSnapshot(SnapshotType st, uint16_t skipFrames); + ErrorNumber sendSetPackageSize(uint16_t packageSize); + ErrorNumber sendSetBaudrate(Baud baud); + ErrorNumber sendReset(ResetType rt, bool specialReset); + ErrorNumber sendPowerOff(); + ErrorNumber recvData(DataType *dt, uint32_t *length); + ErrorNumber sendSync(); + ErrorNumber recvSync(); + ErrorNumber sendAck(uint8_t commandId, uint16_t packageId); + ErrorNumber recvAckOrNck(); - /** - * Send bytes to camera module. - * - * @param buf Pointer to the data buffer. - * @param len Length of the data buffer. - * - * @return True if the data sended. - */ - bool sendBytesWithDebugOutput(char *buf, size_t len); - - /** - * Receive bytes from camera module. - * - * @param buf Pointer to the data buffer. - * @param len Length of the data buffer. - * - * @return True if the data received. - */ - bool recvBytesWithDebugOutput(char *buf, size_t len); + bool sendBytes(char *buf, size_t len, int timeout_us = 5000); + bool recvBytes(char *buf, size_t len, int timeout_us = 5000); + bool waitRecv(); };