Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
mbed-dev/drivers/Serial.cpp@2:5acdd8565d02, 2017-02-25 (annotated)
- Committer:
- elmot
- Date:
- Sat Feb 25 00:23:53 2017 +0000
- Revision:
- 2:5acdd8565d02
- Parent:
- 1:d0dfbce63a89
Ready to show
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
elmot | 1:d0dfbce63a89 | 1 | /* mbed Microcontroller Library |
elmot | 1:d0dfbce63a89 | 2 | * Copyright (c) 2006-2013 ARM Limited |
elmot | 1:d0dfbce63a89 | 3 | * |
elmot | 1:d0dfbce63a89 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
elmot | 1:d0dfbce63a89 | 5 | * you may not use this file except in compliance with the License. |
elmot | 1:d0dfbce63a89 | 6 | * You may obtain a copy of the License at |
elmot | 1:d0dfbce63a89 | 7 | * |
elmot | 1:d0dfbce63a89 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
elmot | 1:d0dfbce63a89 | 9 | * |
elmot | 1:d0dfbce63a89 | 10 | * Unless required by applicable law or agreed to in writing, software |
elmot | 1:d0dfbce63a89 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
elmot | 1:d0dfbce63a89 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
elmot | 1:d0dfbce63a89 | 13 | * See the License for the specific language governing permissions and |
elmot | 1:d0dfbce63a89 | 14 | * limitations under the License. |
elmot | 1:d0dfbce63a89 | 15 | */ |
elmot | 1:d0dfbce63a89 | 16 | #include "drivers/Serial.h" |
elmot | 1:d0dfbce63a89 | 17 | #include "platform/wait_api.h" |
elmot | 1:d0dfbce63a89 | 18 | |
elmot | 1:d0dfbce63a89 | 19 | #if DEVICE_SERIAL |
elmot | 1:d0dfbce63a89 | 20 | |
elmot | 1:d0dfbce63a89 | 21 | namespace mbed { |
elmot | 1:d0dfbce63a89 | 22 | |
elmot | 1:d0dfbce63a89 | 23 | Serial::Serial(PinName tx, PinName rx, const char *name, int baud) : SerialBase(tx, rx, baud), Stream(name) { |
elmot | 1:d0dfbce63a89 | 24 | } |
elmot | 1:d0dfbce63a89 | 25 | |
elmot | 1:d0dfbce63a89 | 26 | Serial::Serial(PinName tx, PinName rx, int baud): SerialBase(tx, rx, baud), Stream(NULL) { |
elmot | 1:d0dfbce63a89 | 27 | } |
elmot | 1:d0dfbce63a89 | 28 | |
elmot | 1:d0dfbce63a89 | 29 | int Serial::_getc() { |
elmot | 1:d0dfbce63a89 | 30 | // Mutex is already held |
elmot | 1:d0dfbce63a89 | 31 | return _base_getc(); |
elmot | 1:d0dfbce63a89 | 32 | } |
elmot | 1:d0dfbce63a89 | 33 | |
elmot | 1:d0dfbce63a89 | 34 | int Serial::_putc(int c) { |
elmot | 1:d0dfbce63a89 | 35 | // Mutex is already held |
elmot | 1:d0dfbce63a89 | 36 | return _base_putc(c); |
elmot | 1:d0dfbce63a89 | 37 | } |
elmot | 1:d0dfbce63a89 | 38 | |
elmot | 1:d0dfbce63a89 | 39 | void Serial::lock() { |
elmot | 1:d0dfbce63a89 | 40 | _mutex.lock(); |
elmot | 1:d0dfbce63a89 | 41 | } |
elmot | 1:d0dfbce63a89 | 42 | |
elmot | 1:d0dfbce63a89 | 43 | void Serial::unlock() { |
elmot | 1:d0dfbce63a89 | 44 | _mutex.unlock(); |
elmot | 1:d0dfbce63a89 | 45 | } |
elmot | 1:d0dfbce63a89 | 46 | |
elmot | 1:d0dfbce63a89 | 47 | } // namespace mbed |
elmot | 1:d0dfbce63a89 | 48 | |
elmot | 1:d0dfbce63a89 | 49 | #endif |