C1098-SS(http://www.silentsystem.jp/c1098.htm) JPEG Cameraのライブラリです。C328-7640のJPEG Cameraとは一部のコマンドで互換性があり、C328-7640のライブラリをベースに開発したものです。このバージョンはテスト用で動作確認のために公開しています。 Terminalでモニターし動作を確認しながら使用してください。ライブラリのsetmbedBaudを一部修正しました。
Dependents: CameraC1098_picture CameraC1098_video Camera-XBee-Wifi
Diff: SerialBuffered.h
- Revision:
- 0:5a6468b4164d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SerialBuffered.h Mon Jul 09 10:23:32 2012 +0000 @@ -0,0 +1,62 @@ +#ifndef _SERIAL_BUFFERED_H_ +#define _SERIAL_BUFFERED_H_ + +/** + * Buffered serial class. + */ +class SerialBuffered : public Serial { +public: + /** + * Create a buffered serial class. + * + * @param tx A pin for transmit. + * @param rx A pin for receive. + */ + SerialBuffered(PinName tx, PinName rx); + + /** + * Destroy. + */ + virtual ~SerialBuffered(); + + /** + * Get a character. + * + * @return A character. (-1:timeout) + */ + int getc(); + + /** + * Returns 1 if there is a character available to read, 0 otherwise. + */ + int readable(); + + /** + * Set timeout for getc(). + * + * @param ms milliseconds. (-1:Disable timeout) + */ + void setTimeout(int ms); + + /** + * Read requested bytes. + * + * @param bytes A pointer to a buffer. + * @param requested Length. + * + * @return Readed byte length. + */ + size_t readBytes(uint8_t *bytes, size_t requested); + + void _baud(int b); +private: + void handleInterrupt(); + static const int BUFFERSIZE = 4096; + 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 + uint16_t indexContentStart; // index of first bytes of content + uint16_t indexContentEnd; // index of bytes after last byte of content + int timeout; + Timer timer; +}; + +#endif