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:
75:dc225afb6914
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 68:f37f3b9c9f0b 1 /* mbed Microcontroller Library
bogdanm 68:f37f3b9c9f0b 2 * Copyright (c) 2006-2013 ARM Limited
bogdanm 68:f37f3b9c9f0b 3 *
bogdanm 68:f37f3b9c9f0b 4 * Licensed under the Apache License, Version 2.0 (the "License");
bogdanm 68:f37f3b9c9f0b 5 * you may not use this file except in compliance with the License.
bogdanm 68:f37f3b9c9f0b 6 * You may obtain a copy of the License at
bogdanm 68:f37f3b9c9f0b 7 *
bogdanm 68:f37f3b9c9f0b 8 * http://www.apache.org/licenses/LICENSE-2.0
bogdanm 68:f37f3b9c9f0b 9 *
bogdanm 68:f37f3b9c9f0b 10 * Unless required by applicable law or agreed to in writing, software
bogdanm 68:f37f3b9c9f0b 11 * distributed under the License is distributed on an "AS IS" BASIS,
bogdanm 68:f37f3b9c9f0b 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
bogdanm 68:f37f3b9c9f0b 13 * See the License for the specific language governing permissions and
bogdanm 68:f37f3b9c9f0b 14 * limitations under the License.
bogdanm 68:f37f3b9c9f0b 15 */
bogdanm 68:f37f3b9c9f0b 16 #ifndef MBED_RAW_SERIAL_H
bogdanm 68:f37f3b9c9f0b 17 #define MBED_RAW_SERIAL_H
bogdanm 68:f37f3b9c9f0b 18
bogdanm 68:f37f3b9c9f0b 19 #include "platform.h"
bogdanm 68:f37f3b9c9f0b 20
bogdanm 68:f37f3b9c9f0b 21 #if DEVICE_SERIAL
bogdanm 68:f37f3b9c9f0b 22
bogdanm 68:f37f3b9c9f0b 23 #include "SerialBase.h"
bogdanm 68:f37f3b9c9f0b 24 #include "serial_api.h"
bogdanm 68:f37f3b9c9f0b 25
bogdanm 68:f37f3b9c9f0b 26 namespace mbed {
bogdanm 68:f37f3b9c9f0b 27
bogdanm 68:f37f3b9c9f0b 28 /** A serial port (UART) for communication with other serial devices
bogdanm 68:f37f3b9c9f0b 29 * This is a variation of the Serial class that doesn't use streams,
bogdanm 68:f37f3b9c9f0b 30 * thus making it safe to use in interrupt handlers with the RTOS.
bogdanm 68:f37f3b9c9f0b 31 *
bogdanm 68:f37f3b9c9f0b 32 * Can be used for Full Duplex communication, or Simplex by specifying
bogdanm 68:f37f3b9c9f0b 33 * one pin as NC (Not Connected)
bogdanm 68:f37f3b9c9f0b 34 *
Kojto 122:f9eeca106725 35 * @Note Synchronization level: Not protected
Kojto 122:f9eeca106725 36 *
bogdanm 68:f37f3b9c9f0b 37 * Example:
bogdanm 68:f37f3b9c9f0b 38 * @code
bogdanm 68:f37f3b9c9f0b 39 * // Send a char to the PC
bogdanm 68:f37f3b9c9f0b 40 *
bogdanm 68:f37f3b9c9f0b 41 * #include "mbed.h"
bogdanm 68:f37f3b9c9f0b 42 *
bogdanm 68:f37f3b9c9f0b 43 * RawSerial pc(USBTX, USBRX);
bogdanm 68:f37f3b9c9f0b 44 *
bogdanm 68:f37f3b9c9f0b 45 * int main() {
bogdanm 68:f37f3b9c9f0b 46 * pc.putc('A');
bogdanm 68:f37f3b9c9f0b 47 * }
bogdanm 68:f37f3b9c9f0b 48 * @endcode
bogdanm 68:f37f3b9c9f0b 49 */
bogdanm 68:f37f3b9c9f0b 50 class RawSerial: public SerialBase {
bogdanm 68:f37f3b9c9f0b 51
bogdanm 68:f37f3b9c9f0b 52 public:
bogdanm 68:f37f3b9c9f0b 53 /** Create a RawSerial port, connected to the specified transmit and receive pins
bogdanm 68:f37f3b9c9f0b 54 *
bogdanm 68:f37f3b9c9f0b 55 * @param tx Transmit pin
bogdanm 68:f37f3b9c9f0b 56 * @param rx Receive pin
bogdanm 68:f37f3b9c9f0b 57 *
bogdanm 68:f37f3b9c9f0b 58 * @note
bogdanm 68:f37f3b9c9f0b 59 * Either tx or rx may be specified as NC if unused
bogdanm 68:f37f3b9c9f0b 60 */
bogdanm 68:f37f3b9c9f0b 61 RawSerial(PinName tx, PinName rx);
bogdanm 68:f37f3b9c9f0b 62
bogdanm 68:f37f3b9c9f0b 63 /** Write a char to the serial port
bogdanm 68:f37f3b9c9f0b 64 *
bogdanm 68:f37f3b9c9f0b 65 * @param c The char to write
bogdanm 68:f37f3b9c9f0b 66 *
bogdanm 68:f37f3b9c9f0b 67 * @returns The written char or -1 if an error occured
bogdanm 68:f37f3b9c9f0b 68 */
bogdanm 68:f37f3b9c9f0b 69 int putc(int c);
bogdanm 68:f37f3b9c9f0b 70
bogdanm 68:f37f3b9c9f0b 71 /** Read a char from the serial port
bogdanm 68:f37f3b9c9f0b 72 *
bogdanm 68:f37f3b9c9f0b 73 * @returns The char read from the serial port
bogdanm 68:f37f3b9c9f0b 74 */
bogdanm 68:f37f3b9c9f0b 75 int getc();
bogdanm 75:dc225afb6914 76
bogdanm 75:dc225afb6914 77 /** Write a string to the serial port
bogdanm 75:dc225afb6914 78 *
bogdanm 75:dc225afb6914 79 * @param str The string to write
bogdanm 75:dc225afb6914 80 *
bogdanm 75:dc225afb6914 81 * @returns 0 if the write succeeds, EOF for error
bogdanm 75:dc225afb6914 82 */
bogdanm 75:dc225afb6914 83 int puts(const char *str);
bogdanm 75:dc225afb6914 84
bogdanm 75:dc225afb6914 85 int printf(const char *format, ...);
Kojto 122:f9eeca106725 86
Kojto 122:f9eeca106725 87 protected:
Kojto 122:f9eeca106725 88
Kojto 122:f9eeca106725 89 /** Acquire exclusive access to this serial port
Kojto 122:f9eeca106725 90 */
Kojto 122:f9eeca106725 91 virtual void lock(void);
Kojto 122:f9eeca106725 92
Kojto 122:f9eeca106725 93 /** Release exclusive access to this serial port
Kojto 122:f9eeca106725 94 */
Kojto 122:f9eeca106725 95 virtual void unlock(void);
bogdanm 68:f37f3b9c9f0b 96 };
bogdanm 68:f37f3b9c9f0b 97
bogdanm 68:f37f3b9c9f0b 98 } // namespace mbed
bogdanm 68:f37f3b9c9f0b 99
bogdanm 68:f37f3b9c9f0b 100 #endif
bogdanm 68:f37f3b9c9f0b 101
bogdanm 68:f37f3b9c9f0b 102 #endif