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.
TARGET_SAKURAIO_EVB_01/TARGET_STM/PinNamesTypes.h@159:7130f322cb7e, 2017-12-21 (annotated)
- Committer:
- mbed_official
- Date:
- Thu Dec 21 18:20:02 2017 +0000
- Revision:
- 159:7130f322cb7e
- Child:
- 170:e95d10626187
mbed library version 157
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 159:7130f322cb7e | 1 | /* mbed Microcontroller Library |
mbed_official | 159:7130f322cb7e | 2 | ******************************************************************************* |
mbed_official | 159:7130f322cb7e | 3 | * Copyright (c) 2016, STMicroelectronics |
mbed_official | 159:7130f322cb7e | 4 | * All rights reserved. |
mbed_official | 159:7130f322cb7e | 5 | * |
mbed_official | 159:7130f322cb7e | 6 | * Redistribution and use in source and binary forms, with or without |
mbed_official | 159:7130f322cb7e | 7 | * modification, are permitted provided that the following conditions are met: |
mbed_official | 159:7130f322cb7e | 8 | * |
mbed_official | 159:7130f322cb7e | 9 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 159:7130f322cb7e | 10 | * this list of conditions and the following disclaimer. |
mbed_official | 159:7130f322cb7e | 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 159:7130f322cb7e | 12 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 159:7130f322cb7e | 13 | * and/or other materials provided with the distribution. |
mbed_official | 159:7130f322cb7e | 14 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 159:7130f322cb7e | 15 | * may be used to endorse or promote products derived from this software |
mbed_official | 159:7130f322cb7e | 16 | * without specific prior written permission. |
mbed_official | 159:7130f322cb7e | 17 | * |
mbed_official | 159:7130f322cb7e | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 159:7130f322cb7e | 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 159:7130f322cb7e | 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 159:7130f322cb7e | 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 159:7130f322cb7e | 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 159:7130f322cb7e | 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 159:7130f322cb7e | 24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 159:7130f322cb7e | 25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 159:7130f322cb7e | 26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 159:7130f322cb7e | 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 159:7130f322cb7e | 28 | ******************************************************************************* |
mbed_official | 159:7130f322cb7e | 29 | */ |
mbed_official | 159:7130f322cb7e | 30 | #ifndef MBED_PINNAMESTYPES_H |
mbed_official | 159:7130f322cb7e | 31 | #define MBED_PINNAMESTYPES_H |
mbed_official | 159:7130f322cb7e | 32 | |
mbed_official | 159:7130f322cb7e | 33 | #include "cmsis.h" |
mbed_official | 159:7130f322cb7e | 34 | |
mbed_official | 159:7130f322cb7e | 35 | #ifdef __cplusplus |
mbed_official | 159:7130f322cb7e | 36 | extern "C" { |
mbed_official | 159:7130f322cb7e | 37 | #endif |
mbed_official | 159:7130f322cb7e | 38 | |
mbed_official | 159:7130f322cb7e | 39 | /* STM PIN data as used in pin_function is coded on 32 bits as below |
mbed_official | 159:7130f322cb7e | 40 | * [2:0] Function (like in MODER reg) : Input / Output / Alt / Analog |
mbed_official | 159:7130f322cb7e | 41 | * [3] Output Push-Pull / Open Drain (as in OTYPER reg) |
mbed_official | 159:7130f322cb7e | 42 | * [5:4] as in PUPDR reg: No Pull, Pull-up, Pull-Donc |
mbed_official | 159:7130f322cb7e | 43 | * [7:6] Reserved for speed config (as in OSPEEDR), but not used yet |
mbed_official | 159:7130f322cb7e | 44 | * [11:8] Alternate Num (as in AFRL/AFRG reg) |
mbed_official | 159:7130f322cb7e | 45 | * [16:12] Channel (Analog/Timer specific) |
mbed_official | 159:7130f322cb7e | 46 | * [17] Inverted (Analog/Timer specific) |
mbed_official | 159:7130f322cb7e | 47 | * [18] Analog ADC control - Only valid for specific families |
mbed_official | 159:7130f322cb7e | 48 | * [32:19] Reserved |
mbed_official | 159:7130f322cb7e | 49 | */ |
mbed_official | 159:7130f322cb7e | 50 | |
mbed_official | 159:7130f322cb7e | 51 | #define STM_PIN_FUNCTION_MASK 0x07 |
mbed_official | 159:7130f322cb7e | 52 | #define STM_PIN_FUNCTION_SHIFT 0 |
mbed_official | 159:7130f322cb7e | 53 | #define STM_PIN_FUNCTION_BITS (STM_PIN_FUNCTION_MASK << STM_PIN_FUNCTION_SHIFT) |
mbed_official | 159:7130f322cb7e | 54 | |
mbed_official | 159:7130f322cb7e | 55 | #define STM_PIN_OD_MASK 0x01 |
mbed_official | 159:7130f322cb7e | 56 | #define STM_PIN_OD_SHIFT 3 |
mbed_official | 159:7130f322cb7e | 57 | #define STM_PIN_OD_BITS (STM_PIN_OD_MASK << STM_PIN_OD_SHIFT) |
mbed_official | 159:7130f322cb7e | 58 | |
mbed_official | 159:7130f322cb7e | 59 | #define STM_PIN_PUPD_MASK 0x03 |
mbed_official | 159:7130f322cb7e | 60 | #define STM_PIN_PUPD_SHIFT 4 |
mbed_official | 159:7130f322cb7e | 61 | #define STM_PIN_PUPD_BITS (STM_PIN_PUPD_MASK << STM_PIN_PUPD_SHIFT) |
mbed_official | 159:7130f322cb7e | 62 | |
mbed_official | 159:7130f322cb7e | 63 | #define STM_PIN_SPEED_MASK 0x03 |
mbed_official | 159:7130f322cb7e | 64 | #define STM_PIN_SPEED_SHIFT 6 |
mbed_official | 159:7130f322cb7e | 65 | #define STM_PIN_SPEED_BITS (STM_PIN_SPEED_MASK << STM_PIN_SPEED_SHIFT) |
mbed_official | 159:7130f322cb7e | 66 | |
mbed_official | 159:7130f322cb7e | 67 | #define STM_PIN_AFNUM_MASK 0x0F |
mbed_official | 159:7130f322cb7e | 68 | #define STM_PIN_AFNUM_SHIFT 8 |
mbed_official | 159:7130f322cb7e | 69 | #define STM_PIN_AFNUM_BITS (STM_PIN_AFNUM_MASK << STM_PIN_AFNUM_SHIFT) |
mbed_official | 159:7130f322cb7e | 70 | |
mbed_official | 159:7130f322cb7e | 71 | #define STM_PIN_CHAN_MASK 0x1F |
mbed_official | 159:7130f322cb7e | 72 | #define STM_PIN_CHAN_SHIFT 12 |
mbed_official | 159:7130f322cb7e | 73 | #define STM_PIN_CHANNEL_BIT (STM_PIN_CHAN_MASK << STM_PIN_CHAN_SHIFT) |
mbed_official | 159:7130f322cb7e | 74 | |
mbed_official | 159:7130f322cb7e | 75 | #define STM_PIN_INV_MASK 0x01 |
mbed_official | 159:7130f322cb7e | 76 | #define STM_PIN_INV_SHIFT 17 |
mbed_official | 159:7130f322cb7e | 77 | #define STM_PIN_INV_BIT (STM_PIN_INV_MASK << STM_PIN_INV_SHIFT) |
mbed_official | 159:7130f322cb7e | 78 | |
mbed_official | 159:7130f322cb7e | 79 | #define STM_PIN_AN_CTRL_MASK 0x01 |
mbed_official | 159:7130f322cb7e | 80 | #define STM_PIN_AN_CTRL_SHIFT 18 |
mbed_official | 159:7130f322cb7e | 81 | #define STM_PIN_ANALOG_CONTROL_BIT (STM_PIN_AN_CTRL_MASK << STM_PIN_AN_CTRL_SHIFT) |
mbed_official | 159:7130f322cb7e | 82 | |
mbed_official | 159:7130f322cb7e | 83 | #define STM_PIN_FUNCTION(X) (((X) >> STM_PIN_FUNCTION_SHIFT) & STM_PIN_FUNCTION_MASK) |
mbed_official | 159:7130f322cb7e | 84 | #define STM_PIN_OD(X) (((X) >> STM_PIN_OD_SHIFT) & STM_PIN_OD_MASK) |
mbed_official | 159:7130f322cb7e | 85 | #define STM_PIN_PUPD(X) (((X) >> STM_PIN_PUPD_SHIFT) & STM_PIN_PUPD_MASK) |
mbed_official | 159:7130f322cb7e | 86 | #define STM_PIN_SPEED(X) (((X) >> STM_PIN_SPEED_SHIFT) & STM_PIN_SPEED_MASK) |
mbed_official | 159:7130f322cb7e | 87 | #define STM_PIN_AFNUM(X) (((X) >> STM_PIN_AFNUM_SHIFT) & STM_PIN_AFNUM_MASK) |
mbed_official | 159:7130f322cb7e | 88 | #define STM_PIN_CHANNEL(X) (((X) >> STM_PIN_CHAN_SHIFT) & STM_PIN_CHAN_MASK) |
mbed_official | 159:7130f322cb7e | 89 | #define STM_PIN_INVERTED(X) (((X) >> STM_PIN_INV_SHIFT) & STM_PIN_INV_MASK) |
mbed_official | 159:7130f322cb7e | 90 | #define STM_PIN_ANALOG_CONTROL(X) (((X) >> STM_PIN_AN_CTRL_SHIFT) & STM_PIN_AN_CTRL_MASK) |
mbed_official | 159:7130f322cb7e | 91 | |
mbed_official | 159:7130f322cb7e | 92 | #define STM_PIN_DEFINE(FUNC_OD, PUPD, AFNUM) ((int)(FUNC_OD) |\ |
mbed_official | 159:7130f322cb7e | 93 | ((PUPD & STM_PIN_PUPD_MASK) << STM_PIN_PUPD_SHIFT) |\ |
mbed_official | 159:7130f322cb7e | 94 | ((AFNUM & STM_PIN_AFNUM_MASK) << STM_PIN_AFNUM_SHIFT)) |
mbed_official | 159:7130f322cb7e | 95 | |
mbed_official | 159:7130f322cb7e | 96 | #define STM_PIN_DEFINE_EXT(FUNC_OD, PUPD, AFNUM, CHAN, INV) \ |
mbed_official | 159:7130f322cb7e | 97 | ((int)(FUNC_OD) |\ |
mbed_official | 159:7130f322cb7e | 98 | ((PUPD & STM_PIN_PUPD_MASK) << STM_PIN_PUPD_SHIFT) |\ |
mbed_official | 159:7130f322cb7e | 99 | ((AFNUM & STM_PIN_AFNUM_MASK) << STM_PIN_AFNUM_SHIFT) |\ |
mbed_official | 159:7130f322cb7e | 100 | ((CHAN & STM_PIN_CHAN_MASK) << STM_PIN_CHAN_SHIFT) |\ |
mbed_official | 159:7130f322cb7e | 101 | ((INV & STM_PIN_INV_MASK) << STM_PIN_INV_SHIFT)) |
mbed_official | 159:7130f322cb7e | 102 | |
mbed_official | 159:7130f322cb7e | 103 | /* |
mbed_official | 159:7130f322cb7e | 104 | * MACROS to support the legacy definition of PIN formats |
mbed_official | 159:7130f322cb7e | 105 | * The STM_MODE_ defines contain the function and the Push-pull/OpenDrain |
mbed_official | 159:7130f322cb7e | 106 | * configuration (legacy inheritance). |
mbed_official | 159:7130f322cb7e | 107 | */ |
mbed_official | 159:7130f322cb7e | 108 | #define STM_PIN_DATA(FUNC_OD, PUPD, AFNUM) \ |
mbed_official | 159:7130f322cb7e | 109 | STM_PIN_DEFINE(FUNC_OD, PUPD, AFNUM) |
mbed_official | 159:7130f322cb7e | 110 | #define STM_PIN_DATA_EXT(FUNC_OD, PUPD, AFNUM, CHANNEL, INVERTED) \ |
mbed_official | 159:7130f322cb7e | 111 | STM_PIN_DEFINE_EXT(FUNC_OD, PUPD, AFNUM, CHANNEL, INVERTED) |
mbed_official | 159:7130f322cb7e | 112 | |
mbed_official | 159:7130f322cb7e | 113 | typedef enum { |
mbed_official | 159:7130f322cb7e | 114 | STM_PIN_INPUT = 0, |
mbed_official | 159:7130f322cb7e | 115 | STM_PIN_OUTPUT = 1, |
mbed_official | 159:7130f322cb7e | 116 | STM_PIN_ALTERNATE = 2, |
mbed_official | 159:7130f322cb7e | 117 | STM_PIN_ANALOG = 3, |
mbed_official | 159:7130f322cb7e | 118 | } StmPinFunction; |
mbed_official | 159:7130f322cb7e | 119 | |
mbed_official | 159:7130f322cb7e | 120 | #define STM_MODE_INPUT (STM_PIN_INPUT) |
mbed_official | 159:7130f322cb7e | 121 | #define STM_MODE_OUTPUT_PP (STM_PIN_OUTPUT) |
mbed_official | 159:7130f322cb7e | 122 | #define STM_MODE_OUTPUT_OD (STM_PIN_OUTPUT | STM_PIN_OD_BITS) |
mbed_official | 159:7130f322cb7e | 123 | #define STM_MODE_AF_PP (STM_PIN_ALTERNATE) |
mbed_official | 159:7130f322cb7e | 124 | #define STM_MODE_AF_OD (STM_PIN_ALTERNATE | STM_PIN_OD_BITS) |
mbed_official | 159:7130f322cb7e | 125 | #define STM_MODE_ANALOG (STM_PIN_ANALOG) |
mbed_official | 159:7130f322cb7e | 126 | #define STM_MODE_ANALOG_ADC_CONTROL (STM_PIN_ANALOG | STM_PIN_ANALOG_CONTROL_BIT) |
mbed_official | 159:7130f322cb7e | 127 | |
mbed_official | 159:7130f322cb7e | 128 | // High nibble = port number (0=A, 1=B, 2=C, 3=D, 4=E, 5=F, 6=G, 7=H) |
mbed_official | 159:7130f322cb7e | 129 | // Low nibble = pin number |
mbed_official | 159:7130f322cb7e | 130 | #define STM_PORT(X) (((uint32_t)(X) >> 4) & 0xF) |
mbed_official | 159:7130f322cb7e | 131 | #define STM_PIN(X) ((uint32_t)(X) & 0xF) |
mbed_official | 159:7130f322cb7e | 132 | |
mbed_official | 159:7130f322cb7e | 133 | /* Defines to be used by application */ |
mbed_official | 159:7130f322cb7e | 134 | typedef enum { |
mbed_official | 159:7130f322cb7e | 135 | PIN_INPUT = 0, |
mbed_official | 159:7130f322cb7e | 136 | PIN_OUTPUT |
mbed_official | 159:7130f322cb7e | 137 | } PinDirection; |
mbed_official | 159:7130f322cb7e | 138 | |
mbed_official | 159:7130f322cb7e | 139 | typedef enum { |
mbed_official | 159:7130f322cb7e | 140 | PullNone = 0, |
mbed_official | 159:7130f322cb7e | 141 | PullUp = 1, |
mbed_official | 159:7130f322cb7e | 142 | PullDown = 2, |
mbed_official | 159:7130f322cb7e | 143 | OpenDrainPullUp = 3, |
mbed_official | 159:7130f322cb7e | 144 | OpenDrainNoPull = 4, |
mbed_official | 159:7130f322cb7e | 145 | OpenDrainPullDown = 5, |
mbed_official | 159:7130f322cb7e | 146 | PushPullNoPull = PullNone, |
mbed_official | 159:7130f322cb7e | 147 | PushPullPullUp = PullUp, |
mbed_official | 159:7130f322cb7e | 148 | PushPullPullDown = PullDown, |
mbed_official | 159:7130f322cb7e | 149 | OpenDrain = OpenDrainPullUp, |
mbed_official | 159:7130f322cb7e | 150 | PullDefault = PullNone |
mbed_official | 159:7130f322cb7e | 151 | } PinMode; |
mbed_official | 159:7130f322cb7e | 152 | |
mbed_official | 159:7130f322cb7e | 153 | #ifdef __cplusplus |
mbed_official | 159:7130f322cb7e | 154 | } |
mbed_official | 159:7130f322cb7e | 155 | #endif |
mbed_official | 159:7130f322cb7e | 156 | |
mbed_official | 159:7130f322cb7e | 157 | #endif |
mbed_official | 159:7130f322cb7e | 158 |