Fork with some minor changes

Dependencies:   Motordriver

Fork of Camera_LS_Y201 by Shinichiro Nakamura

Committer:
reinaldo422
Date:
Wed Dec 10 03:00:30 2014 +0000
Revision:
2:c05fd2c98a29
Parent:
0:f71232252dcf
- Small changes to have camera communicate through RN-42 Bluetooth module.

Who changed what in which revision?

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