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.
CameraC1098.h
00001 /** 00002 * C1098-SS device driver class (Version 1.0) 00003 * Reference documents: C1098-SS User Manual v1.0 2012.5.6 00004 * 00005 * CameraC328Library 00006 * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems) 00007 * http://shinta.main.jp/ 00008 * 00009 * CameraC1098-SS Library 00010 * Copyright (C) 2012 Tadao Iida 00011 */ 00012 00013 #include "mbed.h" 00014 #include "SerialBuffered.h" 00015 00016 #ifndef _CAMERA_C1098_H_ 00017 #define _CAMERA_C1098_H_ 00018 00019 /* 00020 * Class: CameraC1098 00021 */ 00022 00023 class CameraC1098 { 00024 public: 00025 00026 /** 00027 * @enum JPEG resolution. 00028 */ 00029 enum JpegResolution { 00030 JpegResolution80x64 = 0x01, // unofficial 00031 JpegResolution160x128 = 0x03, // unofficial 00032 JpegResolution320x240 = 0x05, // QVGA 00033 JpegResolution640x480 = 0x07 // VGA 00034 }; 00035 00036 /** 00037 * @enum Error number. 00038 */ 00039 enum ErrorNumber { 00040 NoError = 0x00, 00041 UnexpectedReply = 0x04, 00042 ParameterError = 0x0b, 00043 SendRegisterTimeout = 0x0c, 00044 CommandIdError = 0x0d, 00045 CommandHeaderError = 0xf0, 00046 SetTransferPackageSizeWrong = 0x11 00047 }; 00048 00049 /** 00050 * @enum Baud rate. 00051 */ 00052 enum Baud { 00053 Baud460800 = 0x02, 00054 Baud230400 = 0x03, 00055 Baud115200 = 0x04, 00056 Baud57600 = 0x05, 00057 Baud28800 = 0x06, 00058 Baud14400 = 0x07 // Default. 00059 }; 00060 00061 /** 00062 * @enum Reset type. 00063 */ 00064 enum ResetType { 00065 Nomal = 0x00, 00066 High = 0xff 00067 }; 00068 00069 /** Constructor. 00070 * 00071 * @param tx A pin for transmit. 00072 * @param rx A pin for receive. 00073 * @param baud Baud rate. (Default is 14400.) 00074 */ 00075 CameraC1098(PinName tx, PinName rx, int baud = 14400); 00076 00077 /** Destructor. 00078 * 00079 */ 00080 ~CameraC1098(); 00081 00082 /** sync 00083 * Make a sync. for baud rate. 00084 */ 00085 ErrorNumber sync(); 00086 00087 /** Initialize. 00088 * 00089 * 00090 * @param baud Camera Interface Speed. 00091 * @param jr JPEG resolution. 00092 */ 00093 ErrorNumber init(Baud baud, JpegResolution jr); 00094 00095 /** getJpegSnapshotPicture 00096 * Get JPEG snapshot picture. 00097 * 00098 * @param func A pointer to a callback function. 00099 * You can block this function until saving the image datas. 00100 * @return Status of the error. 00101 */ 00102 ErrorNumber getJpegSnapshotPicture(void(*func)(char *buf, size_t siz)); 00103 00104 /** setmbedBaud 00105 * mbed Interface Speed. 00106 * 00107 * @param baud mbed Interface Speed. 00108 */ 00109 void setmbedBaud(Baud baud); 00110 00111 private: 00112 SerialBuffered serial; 00113 static const int COMMAND_LENGTH = 6; 00114 static const int SYNCMAX = 60; 00115 static const int packageSize = 256; 00116 00117 ErrorNumber sendInitial(Baud band, JpegResolution jr); 00118 ErrorNumber sendGetPicture(void); 00119 ErrorNumber sendSnapshot(void); 00120 ErrorNumber sendSetPackageSize(uint16_t packageSize); 00121 ErrorNumber sendReset(ResetType specialReset); 00122 ErrorNumber recvData(uint32_t *length); 00123 ErrorNumber sendSync(); 00124 ErrorNumber recvSync(); 00125 ErrorNumber sendAck(uint8_t commandId, uint16_t packageId); 00126 ErrorNumber recvAckOrNck(); 00127 00128 bool sendBytes(char *buf, size_t len, int timeout_us = 20000); 00129 bool recvBytes(char *buf, size_t len, int timeout_us = 20000); 00130 bool waitRecv(); 00131 bool waitIdle(); 00132 }; 00133 00134 #endif
Generated on Mon Jul 18 2022 14:52:58 by
1.7.2