The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
Kojto
Date:
Thu Jul 07 14:34:11 2016 +0100
Revision:
122:f9eeca106725
Parent:
98:8ab26030e058
Child:
123:b0220dba8be7
Release 122 of the mbed library

Changes:
- new targets - Nucleo L432KC, Beetle, Nucleo F446ZE, Nucleo L011K4
- Thread safety addition - mbed API should contain a statement about thread safety
- critical section API addition
- CAS API (core_util_atomic_incr/decr)
- DEVICE_ are generated from targets.json file, device.h deprecated
- Callback replaces FunctionPointer to provide std like interface
- mbed HAL API docs improvements
- toolchain - prexif attributes with MBED_
- add new attributes - packed, weak, forcedinline, align
- target.json - contains targets definitions
- ST - L1XX - Cube update to 1.5
- SPI clock selection fix (clock from APB domain)
- F7 - Cube update v1.4.0
- L0 - baudrate init fix
- L1 - Cube update v1.5
- F3 - baudrate init fix, 3 targets CAN support
- F4 - Cube update v1.12.0, 3 targets CAN support
- L4XX - Cube update v1.5.1
- F0 - update Cube to v1.5.0
- L4 - 2 targets (L476RG/VG) CAN support
- NXP - pwm clock fix for KSDK2 MCU
- LPC2368 - remove ARM toolchain support - due to regression
- KSDK2 - fix SPI , I2C address and repeat start
- Silabs - some fixes backported from mbed 3
- Renesas - RZ_A1H - SystemCoreClockUpdate addition

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 66:9c8f0e3462fb 1 /* mbed Microcontroller Library
bogdanm 66:9c8f0e3462fb 2 * Copyright (c) 2006-2013 ARM Limited
bogdanm 66:9c8f0e3462fb 3 *
bogdanm 66:9c8f0e3462fb 4 * Licensed under the Apache License, Version 2.0 (the "License");
bogdanm 66:9c8f0e3462fb 5 * you may not use this file except in compliance with the License.
bogdanm 66:9c8f0e3462fb 6 * You may obtain a copy of the License at
bogdanm 66:9c8f0e3462fb 7 *
bogdanm 66:9c8f0e3462fb 8 * http://www.apache.org/licenses/LICENSE-2.0
bogdanm 66:9c8f0e3462fb 9 *
bogdanm 66:9c8f0e3462fb 10 * Unless required by applicable law or agreed to in writing, software
bogdanm 66:9c8f0e3462fb 11 * distributed under the License is distributed on an "AS IS" BASIS,
bogdanm 66:9c8f0e3462fb 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
bogdanm 66:9c8f0e3462fb 13 * See the License for the specific language governing permissions and
bogdanm 66:9c8f0e3462fb 14 * limitations under the License.
bogdanm 66:9c8f0e3462fb 15 */
bogdanm 66:9c8f0e3462fb 16 #ifndef MBED_SERIAL_H
bogdanm 66:9c8f0e3462fb 17 #define MBED_SERIAL_H
bogdanm 66:9c8f0e3462fb 18
bogdanm 66:9c8f0e3462fb 19 #include "platform.h"
bogdanm 66:9c8f0e3462fb 20
bogdanm 66:9c8f0e3462fb 21 #if DEVICE_SERIAL
bogdanm 66:9c8f0e3462fb 22
bogdanm 66:9c8f0e3462fb 23 #include "Stream.h"
bogdanm 68:f37f3b9c9f0b 24 #include "SerialBase.h"
bogdanm 66:9c8f0e3462fb 25 #include "serial_api.h"
bogdanm 66:9c8f0e3462fb 26
bogdanm 66:9c8f0e3462fb 27 namespace mbed {
bogdanm 66:9c8f0e3462fb 28
bogdanm 66:9c8f0e3462fb 29 /** A serial port (UART) for communication with other serial devices
bogdanm 66:9c8f0e3462fb 30 *
bogdanm 66:9c8f0e3462fb 31 * Can be used for Full Duplex communication, or Simplex by specifying
bogdanm 66:9c8f0e3462fb 32 * one pin as NC (Not Connected)
bogdanm 66:9c8f0e3462fb 33 *
Kojto 122:f9eeca106725 34 * @Note Synchronization level: Thread safe
Kojto 122:f9eeca106725 35 *
bogdanm 66:9c8f0e3462fb 36 * Example:
bogdanm 66:9c8f0e3462fb 37 * @code
bogdanm 66:9c8f0e3462fb 38 * // Print "Hello World" to the PC
bogdanm 66:9c8f0e3462fb 39 *
bogdanm 66:9c8f0e3462fb 40 * #include "mbed.h"
bogdanm 66:9c8f0e3462fb 41 *
bogdanm 66:9c8f0e3462fb 42 * Serial pc(USBTX, USBRX);
bogdanm 66:9c8f0e3462fb 43 *
bogdanm 66:9c8f0e3462fb 44 * int main() {
bogdanm 66:9c8f0e3462fb 45 * pc.printf("Hello World\n");
bogdanm 66:9c8f0e3462fb 46 * }
bogdanm 66:9c8f0e3462fb 47 * @endcode
bogdanm 66:9c8f0e3462fb 48 */
bogdanm 68:f37f3b9c9f0b 49 class Serial : public SerialBase, public Stream {
bogdanm 66:9c8f0e3462fb 50
bogdanm 66:9c8f0e3462fb 51 public:
Kojto 98:8ab26030e058 52 #if DEVICE_SERIAL_ASYNCH
Kojto 98:8ab26030e058 53 using SerialBase::read;
Kojto 98:8ab26030e058 54 using SerialBase::write;
Kojto 98:8ab26030e058 55 #endif
Kojto 98:8ab26030e058 56
bogdanm 66:9c8f0e3462fb 57 /** Create a Serial port, connected to the specified transmit and receive pins
bogdanm 66:9c8f0e3462fb 58 *
bogdanm 66:9c8f0e3462fb 59 * @param tx Transmit pin
bogdanm 66:9c8f0e3462fb 60 * @param rx Receive pin
bogdanm 66:9c8f0e3462fb 61 *
bogdanm 66:9c8f0e3462fb 62 * @note
bogdanm 66:9c8f0e3462fb 63 * Either tx or rx may be specified as NC if unused
bogdanm 66:9c8f0e3462fb 64 */
bogdanm 66:9c8f0e3462fb 65 Serial(PinName tx, PinName rx, const char *name=NULL);
bogdanm 66:9c8f0e3462fb 66
bogdanm 66:9c8f0e3462fb 67 protected:
bogdanm 66:9c8f0e3462fb 68 virtual int _getc();
bogdanm 85:024bf7f99721 69 virtual int _putc(int c);
Kojto 122:f9eeca106725 70 virtual void lock();
Kojto 122:f9eeca106725 71 virtual void unlock();
Kojto 122:f9eeca106725 72
Kojto 122:f9eeca106725 73 PlatformMutex _mutex;
bogdanm 66:9c8f0e3462fb 74 };
bogdanm 66:9c8f0e3462fb 75
bogdanm 66:9c8f0e3462fb 76 } // namespace mbed
bogdanm 66:9c8f0e3462fb 77
bogdanm 66:9c8f0e3462fb 78 #endif
bogdanm 66:9c8f0e3462fb 79
bogdanm 66:9c8f0e3462fb 80 #endif