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:
100:cbbeb26dbd92
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
Kojto 93:e188a91d3eaa 1 /* mbed Microcontroller Library
Kojto 93:e188a91d3eaa 2 *******************************************************************************
Kojto 93:e188a91d3eaa 3 * Copyright (c) 2014, STMicroelectronics
Kojto 93:e188a91d3eaa 4 * All rights reserved.
Kojto 93:e188a91d3eaa 5 *
Kojto 93:e188a91d3eaa 6 * Redistribution and use in source and binary forms, with or without
Kojto 93:e188a91d3eaa 7 * modification, are permitted provided that the following conditions are met:
Kojto 93:e188a91d3eaa 8 *
Kojto 93:e188a91d3eaa 9 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 93:e188a91d3eaa 10 * this list of conditions and the following disclaimer.
Kojto 93:e188a91d3eaa 11 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 93:e188a91d3eaa 12 * this list of conditions and the following disclaimer in the documentation
Kojto 93:e188a91d3eaa 13 * and/or other materials provided with the distribution.
Kojto 93:e188a91d3eaa 14 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 93:e188a91d3eaa 15 * may be used to endorse or promote products derived from this software
Kojto 93:e188a91d3eaa 16 * without specific prior written permission.
Kojto 93:e188a91d3eaa 17 *
Kojto 93:e188a91d3eaa 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 93:e188a91d3eaa 19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 93:e188a91d3eaa 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 93:e188a91d3eaa 21 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 93:e188a91d3eaa 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 93:e188a91d3eaa 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 93:e188a91d3eaa 24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 93:e188a91d3eaa 25 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 93:e188a91d3eaa 26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 93:e188a91d3eaa 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 93:e188a91d3eaa 28 *******************************************************************************
Kojto 93:e188a91d3eaa 29 */
Kojto 93:e188a91d3eaa 30 #ifndef MBED_GPIO_OBJECT_H
Kojto 93:e188a91d3eaa 31 #define MBED_GPIO_OBJECT_H
Kojto 93:e188a91d3eaa 32
Kojto 93:e188a91d3eaa 33 #include "mbed_assert.h"
Kojto 93:e188a91d3eaa 34 #include "cmsis.h"
Kojto 93:e188a91d3eaa 35 #include "PortNames.h"
Kojto 93:e188a91d3eaa 36 #include "PeripheralNames.h"
Kojto 93:e188a91d3eaa 37 #include "PinNames.h"
Kojto 93:e188a91d3eaa 38
Kojto 93:e188a91d3eaa 39 #ifdef __cplusplus
Kojto 93:e188a91d3eaa 40 extern "C" {
Kojto 93:e188a91d3eaa 41 #endif
Kojto 93:e188a91d3eaa 42
Kojto 93:e188a91d3eaa 43 typedef struct {
Kojto 93:e188a91d3eaa 44 PinName pin;
Kojto 93:e188a91d3eaa 45 uint32_t mask;
Kojto 93:e188a91d3eaa 46 __IO uint32_t *reg_in;
Kojto 122:f9eeca106725 47 __IO uint32_t *reg_set;
Kojto 122:f9eeca106725 48 __IO uint32_t *reg_clr;
Kojto 93:e188a91d3eaa 49 } gpio_t;
Kojto 93:e188a91d3eaa 50
Kojto 93:e188a91d3eaa 51 static inline void gpio_write(gpio_t *obj, int value)
Kojto 93:e188a91d3eaa 52 {
Kojto 93:e188a91d3eaa 53 MBED_ASSERT(obj->pin != (PinName)NC);
Kojto 93:e188a91d3eaa 54 if (value) {
Kojto 93:e188a91d3eaa 55 *obj->reg_set = obj->mask;
Kojto 93:e188a91d3eaa 56 } else {
Kojto 93:e188a91d3eaa 57 *obj->reg_clr = obj->mask;
Kojto 93:e188a91d3eaa 58 }
Kojto 93:e188a91d3eaa 59 }
Kojto 93:e188a91d3eaa 60
Kojto 93:e188a91d3eaa 61 static inline int gpio_read(gpio_t *obj)
Kojto 93:e188a91d3eaa 62 {
Kojto 93:e188a91d3eaa 63 MBED_ASSERT(obj->pin != (PinName)NC);
Kojto 93:e188a91d3eaa 64 return ((*obj->reg_in & obj->mask) ? 1 : 0);
Kojto 93:e188a91d3eaa 65 }
Kojto 93:e188a91d3eaa 66
Kojto 100:cbbeb26dbd92 67 static inline int gpio_is_connected(const gpio_t *obj)
Kojto 100:cbbeb26dbd92 68 {
Kojto 93:e188a91d3eaa 69 return obj->pin != (PinName)NC;
Kojto 93:e188a91d3eaa 70 }
Kojto 93:e188a91d3eaa 71
Kojto 93:e188a91d3eaa 72 #ifdef __cplusplus
Kojto 93:e188a91d3eaa 73 }
Kojto 93:e188a91d3eaa 74 #endif
Kojto 93:e188a91d3eaa 75
Kojto 93:e188a91d3eaa 76 #endif