Development mbed library for MAX32630FTHR
Dependents: blinky_max32630fthr
drivers/Stream.h@0:5c4d7b2438d3, 2016-11-11 (annotated)
- Committer:
- switches
- Date:
- Fri Nov 11 20:59:50 2016 +0000
- Revision:
- 0:5c4d7b2438d3
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
switches | 0:5c4d7b2438d3 | 1 | /* mbed Microcontroller Library |
switches | 0:5c4d7b2438d3 | 2 | * Copyright (c) 2006-2013 ARM Limited |
switches | 0:5c4d7b2438d3 | 3 | * |
switches | 0:5c4d7b2438d3 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
switches | 0:5c4d7b2438d3 | 5 | * you may not use this file except in compliance with the License. |
switches | 0:5c4d7b2438d3 | 6 | * You may obtain a copy of the License at |
switches | 0:5c4d7b2438d3 | 7 | * |
switches | 0:5c4d7b2438d3 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
switches | 0:5c4d7b2438d3 | 9 | * |
switches | 0:5c4d7b2438d3 | 10 | * Unless required by applicable law or agreed to in writing, software |
switches | 0:5c4d7b2438d3 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
switches | 0:5c4d7b2438d3 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
switches | 0:5c4d7b2438d3 | 13 | * See the License for the specific language governing permissions and |
switches | 0:5c4d7b2438d3 | 14 | * limitations under the License. |
switches | 0:5c4d7b2438d3 | 15 | */ |
switches | 0:5c4d7b2438d3 | 16 | #ifndef MBED_STREAM_H |
switches | 0:5c4d7b2438d3 | 17 | #define MBED_STREAM_H |
switches | 0:5c4d7b2438d3 | 18 | |
switches | 0:5c4d7b2438d3 | 19 | #include "platform/platform.h" |
switches | 0:5c4d7b2438d3 | 20 | #include "drivers/FileLike.h" |
switches | 0:5c4d7b2438d3 | 21 | #include <cstdarg> |
switches | 0:5c4d7b2438d3 | 22 | |
switches | 0:5c4d7b2438d3 | 23 | namespace mbed { |
switches | 0:5c4d7b2438d3 | 24 | /** \addtogroup drivers */ |
switches | 0:5c4d7b2438d3 | 25 | /** @{*/ |
switches | 0:5c4d7b2438d3 | 26 | |
switches | 0:5c4d7b2438d3 | 27 | extern void mbed_set_unbuffered_stream(FILE *_file); |
switches | 0:5c4d7b2438d3 | 28 | extern int mbed_getc(FILE *_file); |
switches | 0:5c4d7b2438d3 | 29 | extern char* mbed_gets(char *s, int size, FILE *_file); |
switches | 0:5c4d7b2438d3 | 30 | |
switches | 0:5c4d7b2438d3 | 31 | /** File stream |
switches | 0:5c4d7b2438d3 | 32 | * |
switches | 0:5c4d7b2438d3 | 33 | * @Note Synchronization level: Set by subclass |
switches | 0:5c4d7b2438d3 | 34 | */ |
switches | 0:5c4d7b2438d3 | 35 | class Stream : public FileLike { |
switches | 0:5c4d7b2438d3 | 36 | |
switches | 0:5c4d7b2438d3 | 37 | public: |
switches | 0:5c4d7b2438d3 | 38 | Stream(const char *name=NULL); |
switches | 0:5c4d7b2438d3 | 39 | virtual ~Stream(); |
switches | 0:5c4d7b2438d3 | 40 | |
switches | 0:5c4d7b2438d3 | 41 | int putc(int c); |
switches | 0:5c4d7b2438d3 | 42 | int puts(const char *s); |
switches | 0:5c4d7b2438d3 | 43 | int getc(); |
switches | 0:5c4d7b2438d3 | 44 | char *gets(char *s, int size); |
switches | 0:5c4d7b2438d3 | 45 | int printf(const char* format, ...); |
switches | 0:5c4d7b2438d3 | 46 | int scanf(const char* format, ...); |
switches | 0:5c4d7b2438d3 | 47 | int vprintf(const char* format, std::va_list args); |
switches | 0:5c4d7b2438d3 | 48 | int vscanf(const char* format, std::va_list args); |
switches | 0:5c4d7b2438d3 | 49 | |
switches | 0:5c4d7b2438d3 | 50 | operator std::FILE*() {return _file;} |
switches | 0:5c4d7b2438d3 | 51 | |
switches | 0:5c4d7b2438d3 | 52 | protected: |
switches | 0:5c4d7b2438d3 | 53 | virtual int close(); |
switches | 0:5c4d7b2438d3 | 54 | virtual ssize_t write(const void* buffer, size_t length); |
switches | 0:5c4d7b2438d3 | 55 | virtual ssize_t read(void* buffer, size_t length); |
switches | 0:5c4d7b2438d3 | 56 | virtual off_t lseek(off_t offset, int whence); |
switches | 0:5c4d7b2438d3 | 57 | virtual int isatty(); |
switches | 0:5c4d7b2438d3 | 58 | virtual int fsync(); |
switches | 0:5c4d7b2438d3 | 59 | virtual off_t flen(); |
switches | 0:5c4d7b2438d3 | 60 | |
switches | 0:5c4d7b2438d3 | 61 | virtual int _putc(int c) = 0; |
switches | 0:5c4d7b2438d3 | 62 | virtual int _getc() = 0; |
switches | 0:5c4d7b2438d3 | 63 | |
switches | 0:5c4d7b2438d3 | 64 | std::FILE *_file; |
switches | 0:5c4d7b2438d3 | 65 | |
switches | 0:5c4d7b2438d3 | 66 | /* disallow copy constructor and assignment operators */ |
switches | 0:5c4d7b2438d3 | 67 | private: |
switches | 0:5c4d7b2438d3 | 68 | Stream(const Stream&); |
switches | 0:5c4d7b2438d3 | 69 | Stream & operator = (const Stream&); |
switches | 0:5c4d7b2438d3 | 70 | }; |
switches | 0:5c4d7b2438d3 | 71 | |
switches | 0:5c4d7b2438d3 | 72 | } // namespace mbed |
switches | 0:5c4d7b2438d3 | 73 | |
switches | 0:5c4d7b2438d3 | 74 | #endif |
switches | 0:5c4d7b2438d3 | 75 | |
switches | 0:5c4d7b2438d3 | 76 | /** @}*/ |