MODIFIED BY FEVZI YAZGAN BOUDRATE AND IMAGESIZE FUNCTION ADDED ALSO IT SENDS THE IMAGE AT ONE TIME TO THE MBED. SO IT IS FASTER TO SEND IMAGE AT A ONE TIME:)
Dependents: 10_Camera_LS_Y201_TestProgram
Camera_LS_Y201.h
00001 /** 00002 * ============================================================================= 00003 * LS-Y201 device driver class (Version 0.0.1) 00004 * Reference documents: LinkSprite JPEG Color Camera Serial UART Interface 00005 * January 2010 00006 * ============================================================================= 00007 * Copyright (c) 2010 Shinichiro Nakamura (CuBeatSystems) 00008 * 00009 * Permission is hereby granted, free of charge, to any person obtaining a copy 00010 * of this software and associated documentation files (the "Software"), to deal 00011 * in the Software without restriction, including without limitation the rights 00012 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00013 * copies of the Software, and to permit persons to whom the Software is 00014 * furnished to do so, subject to the following conditions: 00015 * 00016 * The above copyright notice and this permission notice shall be included in 00017 * all copies or substantial portions of the Software. 00018 * 00019 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00020 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00021 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00022 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00023 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00024 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00025 * THE SOFTWARE. 00026 * ============================================================================= 00027 */ 00028 00029 #ifndef LS_Y201_H 00030 #define LS_Y201_H 00031 00032 #include "mbed.h" 00033 #include "SerialBuffered.h" 00034 00035 /** 00036 * Camera 00037 */ 00038 class Camera_LS_Y201 { 00039 public: 00040 00041 /** 00042 * Image size. 00043 */ 00044 enum Bauds { 00045 Default, 00046 Bauds57600, 00047 Bauds115200, 00048 Bauds1228800 00049 }; 00050 00051 /** 00052 * Create. 00053 * 00054 * @param tx Transmitter. 00055 * @param rx Receiver. 00056 */ 00057 Camera_LS_Y201(PinName tx, PinName rx, Bauds bs); 00058 00059 /** 00060 * Dispose. 00061 */ 00062 ~Camera_LS_Y201(); 00063 00064 /** 00065 * Error code. 00066 */ 00067 enum ErrorCode { 00068 NoError = 0, 00069 UnexpectedReply, 00070 Timeout, 00071 SendError, 00072 RecvError, 00073 InvalidArguments 00074 }; 00075 00076 /** 00077 * Image size. 00078 */ 00079 enum ImageSize { 00080 ImageSize160x120, /**< 160x120. */ 00081 ImageSize320x280, /**< 320x280. */ 00082 ImageSize640x480 /**< 640x480. */ 00083 }; 00084 00085 /** 00086 * Reset module. 00087 * 00088 * @return Error code. 00089 */ 00090 ErrorCode reset(); 00091 00092 /** 00093 * Set image size. 00094 * 00095 * @param is Image size. 00096 * @return Error code. 00097 */ 00098 ErrorCode setImageSize(ImageSize is); 00099 00100 /** 00101 * Take picture. 00102 * 00103 * @return Error code. 00104 */ 00105 ErrorCode takePicture(); 00106 00107 /** 00108 * Read jpeg file size. 00109 * 00110 * @param fileSize File size. 00111 * @return Error code. 00112 */ 00113 ErrorCode readJpegFileSize(int *fileSize); 00114 00115 /** 00116 * Read jpeg file content. 00117 * 00118 * @param func A pointer to a call back function. 00119 * @return Error code. 00120 */ 00121 ErrorCode readJpegFileContent(void (*func)(int total, uint8_t *buf, size_t siz)); 00122 00123 /** 00124 * Stop taking pictures. 00125 * 00126 * @return Error code. 00127 */ 00128 ErrorCode stopTakingPictures(); 00129 00130 /** 00131 * Baudrate 00132 */ 00133 enum Baudrate { 00134 Baud57600, 00135 Baud115200, 00136 Baud1228800 00137 }; 00138 00139 /** 00140 * @return Error code. 00141 */ 00142 ErrorCode setBaudrate(Baudrate bt); 00143 00144 private: 00145 SerialBuffered serial; 00146 00147 /** 00148 * Wait init end codes. 00149 * 00150 * @return Error code. 00151 */ 00152 ErrorCode waitInitEnd(); 00153 00154 /** 00155 * Send bytes to camera module. 00156 * 00157 * @param buf Pointer to the data buffer. 00158 * @param len Length of the data buffer. 00159 * 00160 * @return True if the data sended. 00161 */ 00162 bool sendBytes(uint8_t *buf, size_t len, int timeout_us); 00163 00164 /** 00165 * Receive bytes from camera module. 00166 * 00167 * @param buf Pointer to the data buffer. 00168 * @param len Length of the data buffer. 00169 * 00170 * @return True if the data received. 00171 */ 00172 bool recvBytes(uint8_t *buf, size_t len, int timeout_us); 00173 00174 /** 00175 * Wait received. 00176 * 00177 * @return True if the data received. 00178 */ 00179 bool waitRecv(); 00180 00181 /** 00182 * Wait idle state. 00183 * 00184 * @return True if it succeed. 00185 */ 00186 bool waitIdle(); 00187 00188 }; 00189 00190 #endif
Generated on Fri Jul 15 2022 08:42:25 by 1.7.2