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

Committer:
fyazgan
Date:
Wed Mar 02 05:43:09 2011 +0000
Revision:
0:92b7ae8bc9f5

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
fyazgan 0:92b7ae8bc9f5 1 /**
fyazgan 0:92b7ae8bc9f5 2 * =============================================================================
fyazgan 0:92b7ae8bc9f5 3 * LS-Y201 device driver class (Version 0.0.1)
fyazgan 0:92b7ae8bc9f5 4 * Reference documents: LinkSprite JPEG Color Camera Serial UART Interface
fyazgan 0:92b7ae8bc9f5 5 * January 2010
fyazgan 0:92b7ae8bc9f5 6 * =============================================================================
fyazgan 0:92b7ae8bc9f5 7 * Copyright (c) 2010 Shinichiro Nakamura (CuBeatSystems)
fyazgan 0:92b7ae8bc9f5 8 *
fyazgan 0:92b7ae8bc9f5 9 * Permission is hereby granted, free of charge, to any person obtaining a copy
fyazgan 0:92b7ae8bc9f5 10 * of this software and associated documentation files (the "Software"), to deal
fyazgan 0:92b7ae8bc9f5 11 * in the Software without restriction, including without limitation the rights
fyazgan 0:92b7ae8bc9f5 12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
fyazgan 0:92b7ae8bc9f5 13 * copies of the Software, and to permit persons to whom the Software is
fyazgan 0:92b7ae8bc9f5 14 * furnished to do so, subject to the following conditions:
fyazgan 0:92b7ae8bc9f5 15 *
fyazgan 0:92b7ae8bc9f5 16 * The above copyright notice and this permission notice shall be included in
fyazgan 0:92b7ae8bc9f5 17 * all copies or substantial portions of the Software.
fyazgan 0:92b7ae8bc9f5 18 *
fyazgan 0:92b7ae8bc9f5 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
fyazgan 0:92b7ae8bc9f5 20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
fyazgan 0:92b7ae8bc9f5 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
fyazgan 0:92b7ae8bc9f5 22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
fyazgan 0:92b7ae8bc9f5 23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
fyazgan 0:92b7ae8bc9f5 24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
fyazgan 0:92b7ae8bc9f5 25 * THE SOFTWARE.
fyazgan 0:92b7ae8bc9f5 26 * =============================================================================
fyazgan 0:92b7ae8bc9f5 27 */
fyazgan 0:92b7ae8bc9f5 28
fyazgan 0:92b7ae8bc9f5 29 #ifndef _SERIAL_BUFFERED_H_
fyazgan 0:92b7ae8bc9f5 30 #define _SERIAL_BUFFERED_H_
fyazgan 0:92b7ae8bc9f5 31
fyazgan 0:92b7ae8bc9f5 32 /**
fyazgan 0:92b7ae8bc9f5 33 * Buffered serial class.
fyazgan 0:92b7ae8bc9f5 34 */
fyazgan 0:92b7ae8bc9f5 35 class SerialBuffered : public Serial {
fyazgan 0:92b7ae8bc9f5 36 public:
fyazgan 0:92b7ae8bc9f5 37 /**
fyazgan 0:92b7ae8bc9f5 38 * Create a buffered serial class.
fyazgan 0:92b7ae8bc9f5 39 *
fyazgan 0:92b7ae8bc9f5 40 * @param tx A pin for transmit.
fyazgan 0:92b7ae8bc9f5 41 * @param rx A pin for receive.
fyazgan 0:92b7ae8bc9f5 42 */
fyazgan 0:92b7ae8bc9f5 43 SerialBuffered(PinName tx, PinName rx);
fyazgan 0:92b7ae8bc9f5 44
fyazgan 0:92b7ae8bc9f5 45 /**
fyazgan 0:92b7ae8bc9f5 46 * Destroy.
fyazgan 0:92b7ae8bc9f5 47 */
fyazgan 0:92b7ae8bc9f5 48 virtual ~SerialBuffered();
fyazgan 0:92b7ae8bc9f5 49
fyazgan 0:92b7ae8bc9f5 50 /**
fyazgan 0:92b7ae8bc9f5 51 * Get a character.
fyazgan 0:92b7ae8bc9f5 52 *
fyazgan 0:92b7ae8bc9f5 53 * @return A character. (-1:timeout)
fyazgan 0:92b7ae8bc9f5 54 */
fyazgan 0:92b7ae8bc9f5 55 int getc();
fyazgan 0:92b7ae8bc9f5 56
fyazgan 0:92b7ae8bc9f5 57 /**
fyazgan 0:92b7ae8bc9f5 58 * Returns 1 if there is a character available to read, 0 otherwise.
fyazgan 0:92b7ae8bc9f5 59 */
fyazgan 0:92b7ae8bc9f5 60 int readable();
fyazgan 0:92b7ae8bc9f5 61
fyazgan 0:92b7ae8bc9f5 62 /**
fyazgan 0:92b7ae8bc9f5 63 * Set timeout for getc().
fyazgan 0:92b7ae8bc9f5 64 *
fyazgan 0:92b7ae8bc9f5 65 * @param ms milliseconds. (-1:Disable timeout)
fyazgan 0:92b7ae8bc9f5 66 */
fyazgan 0:92b7ae8bc9f5 67 void setTimeout(int ms);
fyazgan 0:92b7ae8bc9f5 68
fyazgan 0:92b7ae8bc9f5 69 /**
fyazgan 0:92b7ae8bc9f5 70 * Read requested bytes.
fyazgan 0:92b7ae8bc9f5 71 *
fyazgan 0:92b7ae8bc9f5 72 * @param bytes A pointer to a buffer.
fyazgan 0:92b7ae8bc9f5 73 * @param requested Length.
fyazgan 0:92b7ae8bc9f5 74 *
fyazgan 0:92b7ae8bc9f5 75 * @return Readed byte length.
fyazgan 0:92b7ae8bc9f5 76 */
fyazgan 0:92b7ae8bc9f5 77 size_t readBytes(uint8_t *bytes, size_t requested);
fyazgan 0:92b7ae8bc9f5 78
fyazgan 0:92b7ae8bc9f5 79 private:
fyazgan 0:92b7ae8bc9f5 80 void handleInterrupt();
fyazgan 0:92b7ae8bc9f5 81 static const int BUFFERSIZE = 4096;
fyazgan 0:92b7ae8bc9f5 82 uint8_t buffer[BUFFERSIZE]; // points at a circular buffer, containing data from m_contentStart, for m_contentSize bytes, wrapping when you get to the end
fyazgan 0:92b7ae8bc9f5 83 uint16_t indexContentStart; // index of first bytes of content
fyazgan 0:92b7ae8bc9f5 84 uint16_t indexContentEnd; // index of bytes after last byte of content
fyazgan 0:92b7ae8bc9f5 85 int timeout;
fyazgan 0:92b7ae8bc9f5 86 Timer timer;
fyazgan 0:92b7ae8bc9f5 87 };
fyazgan 0:92b7ae8bc9f5 88
fyazgan 0:92b7ae8bc9f5 89 #endif