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:
bogdanm
Date:
Fri Sep 12 16:41:52 2014 +0100
Revision:
89:552587b429a1
Parent:
82:6473597d706e
Child:
90:cb3d968589d8
Release 89 of the mbed library

Main changes:

- low power optimizations for Nordic targets
- code structure changes for Freescale K64F targets
- bug fixes in various backends

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 82:6473597d706e 1 /* mbed Microcontroller Library
bogdanm 82:6473597d706e 2 *******************************************************************************
bogdanm 82:6473597d706e 3 * Copyright (c) 2014, STMicroelectronics
bogdanm 82:6473597d706e 4 * All rights reserved.
bogdanm 82:6473597d706e 5 *
bogdanm 82:6473597d706e 6 * Redistribution and use in source and binary forms, with or without
bogdanm 82:6473597d706e 7 * modification, are permitted provided that the following conditions are met:
bogdanm 82:6473597d706e 8 *
bogdanm 82:6473597d706e 9 * 1. Redistributions of source code must retain the above copyright notice,
bogdanm 82:6473597d706e 10 * this list of conditions and the following disclaimer.
bogdanm 82:6473597d706e 11 * 2. Redistributions in binary form must reproduce the above copyright notice,
bogdanm 82:6473597d706e 12 * this list of conditions and the following disclaimer in the documentation
bogdanm 82:6473597d706e 13 * and/or other materials provided with the distribution.
bogdanm 82:6473597d706e 14 * 3. Neither the name of STMicroelectronics nor the names of its contributors
bogdanm 82:6473597d706e 15 * may be used to endorse or promote products derived from this software
bogdanm 82:6473597d706e 16 * without specific prior written permission.
bogdanm 82:6473597d706e 17 *
bogdanm 82:6473597d706e 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bogdanm 82:6473597d706e 19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bogdanm 82:6473597d706e 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bogdanm 82:6473597d706e 21 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
bogdanm 82:6473597d706e 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
bogdanm 82:6473597d706e 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
bogdanm 82:6473597d706e 24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
bogdanm 82:6473597d706e 25 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bogdanm 82:6473597d706e 26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
bogdanm 82:6473597d706e 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bogdanm 82:6473597d706e 28 *******************************************************************************
bogdanm 82:6473597d706e 29 */
bogdanm 82:6473597d706e 30 #ifndef MBED_PINNAMES_H
bogdanm 82:6473597d706e 31 #define MBED_PINNAMES_H
bogdanm 82:6473597d706e 32
bogdanm 82:6473597d706e 33 #include "cmsis.h"
bogdanm 82:6473597d706e 34
bogdanm 82:6473597d706e 35 #ifdef __cplusplus
bogdanm 82:6473597d706e 36 extern "C" {
bogdanm 82:6473597d706e 37 #endif
bogdanm 82:6473597d706e 38
bogdanm 82:6473597d706e 39 // See stm32f4xx_hal_gpio.h and stm32f4xx_hal_gpio_ex.h for values of MODE, PUPD and AFNUM
bogdanm 82:6473597d706e 40 #define STM_PIN_DATA(MODE, PUPD, AFNUM) ((int)(((AFNUM) << 7) | ((PUPD) << 4) | ((MODE) << 0)))
bogdanm 82:6473597d706e 41 #define STM_PIN_MODE(X) (((X) >> 0) & 0x0F)
bogdanm 82:6473597d706e 42 #define STM_PIN_PUPD(X) (((X) >> 4) & 0x07)
bogdanm 82:6473597d706e 43 #define STM_PIN_AFNUM(X) (((X) >> 7) & 0x0F)
bogdanm 82:6473597d706e 44 #define STM_MODE_INPUT (0)
bogdanm 82:6473597d706e 45 #define STM_MODE_OUTPUT_PP (1)
bogdanm 82:6473597d706e 46 #define STM_MODE_OUTPUT_OD (2)
bogdanm 82:6473597d706e 47 #define STM_MODE_AF_PP (3)
bogdanm 82:6473597d706e 48 #define STM_MODE_AF_OD (4)
bogdanm 82:6473597d706e 49 #define STM_MODE_ANALOG (5)
bogdanm 82:6473597d706e 50 #define STM_MODE_IT_RISING (6)
bogdanm 82:6473597d706e 51 #define STM_MODE_IT_FALLING (7)
bogdanm 82:6473597d706e 52 #define STM_MODE_IT_RISING_FALLING (8)
bogdanm 82:6473597d706e 53 #define STM_MODE_EVT_RISING (9)
bogdanm 82:6473597d706e 54 #define STM_MODE_EVT_FALLING (10)
bogdanm 82:6473597d706e 55 #define STM_MODE_EVT_RISING_FALLING (11)
bogdanm 82:6473597d706e 56
bogdanm 82:6473597d706e 57 // High nibble = port number (0=A, 1=B, 2=C, 3=D, 4=E, 5=F, 6=G, 7=H)
bogdanm 82:6473597d706e 58 // Low nibble = pin number
bogdanm 82:6473597d706e 59 #define STM_PORT(X) (((uint32_t)(X) >> 4) & 0xF)
bogdanm 82:6473597d706e 60 #define STM_PIN(X) ((uint32_t)(X) & 0xF)
bogdanm 82:6473597d706e 61
bogdanm 82:6473597d706e 62 typedef enum {
bogdanm 82:6473597d706e 63 PIN_INPUT,
bogdanm 82:6473597d706e 64 PIN_OUTPUT
bogdanm 82:6473597d706e 65 } PinDirection;
bogdanm 82:6473597d706e 66
bogdanm 82:6473597d706e 67 typedef enum {
bogdanm 82:6473597d706e 68 PA_0 = 0x00,
bogdanm 82:6473597d706e 69 PA_1 = 0x01,
bogdanm 82:6473597d706e 70 PA_2 = 0x02,
bogdanm 82:6473597d706e 71 PA_3 = 0x03,
bogdanm 82:6473597d706e 72 PA_4 = 0x04,
bogdanm 82:6473597d706e 73 PA_5 = 0x05,
bogdanm 82:6473597d706e 74 PA_6 = 0x06,
bogdanm 82:6473597d706e 75 PA_7 = 0x07,
bogdanm 82:6473597d706e 76 PA_8 = 0x08,
bogdanm 82:6473597d706e 77 PA_9 = 0x09,
bogdanm 82:6473597d706e 78 PA_10 = 0x0A,
bogdanm 82:6473597d706e 79 PA_11 = 0x0B,
bogdanm 82:6473597d706e 80 PA_12 = 0x0C,
bogdanm 82:6473597d706e 81 PA_13 = 0x0D,
bogdanm 82:6473597d706e 82 PA_14 = 0x0E,
bogdanm 82:6473597d706e 83 PA_15 = 0x0F,
bogdanm 82:6473597d706e 84
bogdanm 82:6473597d706e 85 PB_0 = 0x10,
bogdanm 82:6473597d706e 86 PB_1 = 0x11,
bogdanm 82:6473597d706e 87 PB_2 = 0x12,
bogdanm 82:6473597d706e 88 PB_3 = 0x13,
bogdanm 82:6473597d706e 89 PB_4 = 0x14,
bogdanm 82:6473597d706e 90 PB_5 = 0x15,
bogdanm 82:6473597d706e 91 PB_6 = 0x16,
bogdanm 82:6473597d706e 92 PB_7 = 0x17,
bogdanm 82:6473597d706e 93 PB_8 = 0x18,
bogdanm 82:6473597d706e 94 PB_9 = 0x19,
bogdanm 82:6473597d706e 95 PB_10 = 0x1A,
bogdanm 82:6473597d706e 96 PB_12 = 0x1C,
bogdanm 82:6473597d706e 97 PB_13 = 0x1D,
bogdanm 82:6473597d706e 98 PB_14 = 0x1E,
bogdanm 82:6473597d706e 99 PB_15 = 0x1F,
bogdanm 82:6473597d706e 100
bogdanm 82:6473597d706e 101 PC_0 = 0x20,
bogdanm 82:6473597d706e 102 PC_1 = 0x21,
bogdanm 82:6473597d706e 103 PC_2 = 0x22,
bogdanm 82:6473597d706e 104 PC_3 = 0x23,
bogdanm 82:6473597d706e 105 PC_4 = 0x24,
bogdanm 82:6473597d706e 106 PC_5 = 0x25,
bogdanm 82:6473597d706e 107 PC_6 = 0x26,
bogdanm 82:6473597d706e 108 PC_7 = 0x27,
bogdanm 82:6473597d706e 109 PC_8 = 0x28,
bogdanm 82:6473597d706e 110 PC_9 = 0x29,
bogdanm 82:6473597d706e 111 PC_10 = 0x2A,
bogdanm 82:6473597d706e 112 PC_11 = 0x2B,
bogdanm 82:6473597d706e 113 PC_12 = 0x2C,
bogdanm 82:6473597d706e 114 PC_13 = 0x2D,
bogdanm 82:6473597d706e 115 PC_14 = 0x2E,
bogdanm 82:6473597d706e 116 PC_15 = 0x2F,
bogdanm 82:6473597d706e 117
bogdanm 82:6473597d706e 118 PD_2 = 0x32,
bogdanm 82:6473597d706e 119
bogdanm 82:6473597d706e 120 PH_0 = 0x70,
bogdanm 82:6473597d706e 121 PH_1 = 0x71,
bogdanm 82:6473597d706e 122
bogdanm 82:6473597d706e 123 // Arduino connector namings
bogdanm 82:6473597d706e 124 A0 = PA_0,
bogdanm 82:6473597d706e 125 A1 = PA_1,
bogdanm 82:6473597d706e 126 A2 = PA_4,
bogdanm 82:6473597d706e 127 A3 = PB_0,
bogdanm 82:6473597d706e 128 A4 = PC_1,
bogdanm 82:6473597d706e 129 A5 = PC_0,
bogdanm 82:6473597d706e 130 D0 = PA_3,
bogdanm 82:6473597d706e 131 D1 = PA_2,
bogdanm 82:6473597d706e 132 D2 = PA_10,
bogdanm 82:6473597d706e 133 D3 = PB_3,
bogdanm 82:6473597d706e 134 D4 = PB_5,
bogdanm 82:6473597d706e 135 D5 = PB_4,
bogdanm 82:6473597d706e 136 D6 = PB_10,
bogdanm 82:6473597d706e 137 D7 = PA_8,
bogdanm 82:6473597d706e 138 D8 = PA_9,
bogdanm 82:6473597d706e 139 D9 = PC_7,
bogdanm 82:6473597d706e 140 D10 = PB_6,
bogdanm 82:6473597d706e 141 D11 = PA_7,
bogdanm 82:6473597d706e 142 D12 = PA_6,
bogdanm 82:6473597d706e 143 D13 = PA_5,
bogdanm 82:6473597d706e 144 D14 = PB_9,
bogdanm 82:6473597d706e 145 D15 = PB_8,
bogdanm 82:6473597d706e 146
bogdanm 82:6473597d706e 147 // Generic signals namings
bogdanm 82:6473597d706e 148 LED1 = PA_5,
bogdanm 82:6473597d706e 149 LED2 = PA_5,
bogdanm 82:6473597d706e 150 LED3 = PA_5,
bogdanm 82:6473597d706e 151 LED4 = PA_5,
bogdanm 82:6473597d706e 152 USER_BUTTON = PC_13,
bogdanm 82:6473597d706e 153 SERIAL_TX = PA_2,
bogdanm 82:6473597d706e 154 SERIAL_RX = PA_3,
bogdanm 82:6473597d706e 155 USBTX = PA_2,
bogdanm 82:6473597d706e 156 USBRX = PA_3,
bogdanm 82:6473597d706e 157 I2C_SCL = PB_8,
bogdanm 82:6473597d706e 158 I2C_SDA = PB_9,
bogdanm 82:6473597d706e 159 SPI_MOSI = PA_7,
bogdanm 82:6473597d706e 160 SPI_MISO = PA_6,
bogdanm 82:6473597d706e 161 SPI_SCK = PA_5,
bogdanm 82:6473597d706e 162 SPI_CS = PB_6,
bogdanm 82:6473597d706e 163 PWM_OUT = PB_3,
bogdanm 82:6473597d706e 164
bogdanm 82:6473597d706e 165 // Not connected
bogdanm 82:6473597d706e 166 NC = (int)0xFFFFFFFF
bogdanm 82:6473597d706e 167 } PinName;
bogdanm 82:6473597d706e 168
bogdanm 82:6473597d706e 169 typedef enum {
bogdanm 82:6473597d706e 170 PullNone = 0,
bogdanm 82:6473597d706e 171 PullUp = 1,
bogdanm 82:6473597d706e 172 PullDown = 2,
bogdanm 82:6473597d706e 173 OpenDrain = 3,
bogdanm 82:6473597d706e 174 PullDefault = PullNone
bogdanm 82:6473597d706e 175 } PinMode;
bogdanm 82:6473597d706e 176
bogdanm 82:6473597d706e 177 #ifdef __cplusplus
bogdanm 82:6473597d706e 178 }
bogdanm 82:6473597d706e 179 #endif
bogdanm 82:6473597d706e 180
bogdanm 82:6473597d706e 181 #endif