Bank Account Security System

Dependencies:   FatFileSystemSD mbed

Committer:
Dhruv_Varun
Date:
Thu Oct 11 20:49:25 2012 +0000
Revision:
0:7e4786a3584b
Code For Bank Account Security System

Who changed what in which revision?

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