Fork of mbed-dev with the NUCLEO-L152RE target modified for use with the STM32L151RB (128 kB flash, 16 kB RAM).

Fork of mbed-dev by mbed official

To use this, remove the default "mbed" library and import this one instead. Target must be NUCLEO_L152RE.

Committer:
bogdanm
Date:
Thu Oct 01 15:25:22 2015 +0300
Revision:
0:9b334a45a8ff
Initial commit on mbed-dev

Replaces mbed-src (now inactive)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 0:9b334a45a8ff 1 /* mbed Microcontroller Library
bogdanm 0:9b334a45a8ff 2 * Copyright (c) 2006-2013 ARM Limited
bogdanm 0:9b334a45a8ff 3 *
bogdanm 0:9b334a45a8ff 4 * Licensed under the Apache License, Version 2.0 (the "License");
bogdanm 0:9b334a45a8ff 5 * you may not use this file except in compliance with the License.
bogdanm 0:9b334a45a8ff 6 * You may obtain a copy of the License at
bogdanm 0:9b334a45a8ff 7 *
bogdanm 0:9b334a45a8ff 8 * http://www.apache.org/licenses/LICENSE-2.0
bogdanm 0:9b334a45a8ff 9 *
bogdanm 0:9b334a45a8ff 10 * Unless required by applicable law or agreed to in writing, software
bogdanm 0:9b334a45a8ff 11 * distributed under the License is distributed on an "AS IS" BASIS,
bogdanm 0:9b334a45a8ff 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
bogdanm 0:9b334a45a8ff 13 * See the License for the specific language governing permissions and
bogdanm 0:9b334a45a8ff 14 * limitations under the License.
bogdanm 0:9b334a45a8ff 15 */
bogdanm 0:9b334a45a8ff 16 #ifndef MBED_STREAM_H
bogdanm 0:9b334a45a8ff 17 #define MBED_STREAM_H
bogdanm 0:9b334a45a8ff 18
bogdanm 0:9b334a45a8ff 19 #include "platform.h"
bogdanm 0:9b334a45a8ff 20 #include "FileLike.h"
bogdanm 0:9b334a45a8ff 21
bogdanm 0:9b334a45a8ff 22 namespace mbed {
bogdanm 0:9b334a45a8ff 23
bogdanm 0:9b334a45a8ff 24 extern void mbed_set_unbuffered_stream(FILE *_file);
bogdanm 0:9b334a45a8ff 25 extern int mbed_getc(FILE *_file);
bogdanm 0:9b334a45a8ff 26 extern char* mbed_gets(char *s, int size, FILE *_file);
bogdanm 0:9b334a45a8ff 27
bogdanm 0:9b334a45a8ff 28 class Stream : public FileLike {
bogdanm 0:9b334a45a8ff 29
bogdanm 0:9b334a45a8ff 30 public:
bogdanm 0:9b334a45a8ff 31 Stream(const char *name=NULL);
bogdanm 0:9b334a45a8ff 32 virtual ~Stream();
bogdanm 0:9b334a45a8ff 33
bogdanm 0:9b334a45a8ff 34 int putc(int c);
bogdanm 0:9b334a45a8ff 35 int puts(const char *s);
bogdanm 0:9b334a45a8ff 36 int getc();
bogdanm 0:9b334a45a8ff 37 char *gets(char *s, int size);
bogdanm 0:9b334a45a8ff 38 int printf(const char* format, ...);
bogdanm 0:9b334a45a8ff 39 int scanf(const char* format, ...);
bogdanm 0:9b334a45a8ff 40
bogdanm 0:9b334a45a8ff 41 operator std::FILE*() {return _file;}
bogdanm 0:9b334a45a8ff 42
bogdanm 0:9b334a45a8ff 43 protected:
bogdanm 0:9b334a45a8ff 44 virtual int close();
bogdanm 0:9b334a45a8ff 45 virtual ssize_t write(const void* buffer, size_t length);
bogdanm 0:9b334a45a8ff 46 virtual ssize_t read(void* buffer, size_t length);
bogdanm 0:9b334a45a8ff 47 virtual off_t lseek(off_t offset, int whence);
bogdanm 0:9b334a45a8ff 48 virtual int isatty();
bogdanm 0:9b334a45a8ff 49 virtual int fsync();
bogdanm 0:9b334a45a8ff 50 virtual off_t flen();
bogdanm 0:9b334a45a8ff 51
bogdanm 0:9b334a45a8ff 52 virtual int _putc(int c) = 0;
bogdanm 0:9b334a45a8ff 53 virtual int _getc() = 0;
bogdanm 0:9b334a45a8ff 54
bogdanm 0:9b334a45a8ff 55 std::FILE *_file;
bogdanm 0:9b334a45a8ff 56
bogdanm 0:9b334a45a8ff 57 /* disallow copy constructor and assignment operators */
bogdanm 0:9b334a45a8ff 58 private:
bogdanm 0:9b334a45a8ff 59 Stream(const Stream&);
bogdanm 0:9b334a45a8ff 60 Stream & operator = (const Stream&);
bogdanm 0:9b334a45a8ff 61 };
bogdanm 0:9b334a45a8ff 62
bogdanm 0:9b334a45a8ff 63 } // namespace mbed
bogdanm 0:9b334a45a8ff 64
bogdanm 0:9b334a45a8ff 65 #endif