mbed library sources

Committer:
ebrus
Date:
Wed Jul 27 18:35:32 2016 +0000
Revision:
0:0a673c671a56
4

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ebrus 0:0a673c671a56 1 /* mbed Microcontroller Library
ebrus 0:0a673c671a56 2 *******************************************************************************
ebrus 0:0a673c671a56 3 * Copyright (c) 2014, STMicroelectronics
ebrus 0:0a673c671a56 4 * All rights reserved.
ebrus 0:0a673c671a56 5 *
ebrus 0:0a673c671a56 6 * Redistribution and use in source and binary forms, with or without
ebrus 0:0a673c671a56 7 * modification, are permitted provided that the following conditions are met:
ebrus 0:0a673c671a56 8 *
ebrus 0:0a673c671a56 9 * 1. Redistributions of source code must retain the above copyright notice,
ebrus 0:0a673c671a56 10 * this list of conditions and the following disclaimer.
ebrus 0:0a673c671a56 11 * 2. Redistributions in binary form must reproduce the above copyright notice,
ebrus 0:0a673c671a56 12 * this list of conditions and the following disclaimer in the documentation
ebrus 0:0a673c671a56 13 * and/or other materials provided with the distribution.
ebrus 0:0a673c671a56 14 * 3. Neither the name of STMicroelectronics nor the names of its contributors
ebrus 0:0a673c671a56 15 * may be used to endorse or promote products derived from this software
ebrus 0:0a673c671a56 16 * without specific prior written permission.
ebrus 0:0a673c671a56 17 *
ebrus 0:0a673c671a56 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
ebrus 0:0a673c671a56 19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
ebrus 0:0a673c671a56 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
ebrus 0:0a673c671a56 21 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
ebrus 0:0a673c671a56 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
ebrus 0:0a673c671a56 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
ebrus 0:0a673c671a56 24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
ebrus 0:0a673c671a56 25 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
ebrus 0:0a673c671a56 26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
ebrus 0:0a673c671a56 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
ebrus 0:0a673c671a56 28 *******************************************************************************
ebrus 0:0a673c671a56 29 */
ebrus 0:0a673c671a56 30 #ifndef MBED_PINNAMES_H
ebrus 0:0a673c671a56 31 #define MBED_PINNAMES_H
ebrus 0:0a673c671a56 32
ebrus 0:0a673c671a56 33 #include "cmsis.h"
ebrus 0:0a673c671a56 34
ebrus 0:0a673c671a56 35 #ifdef __cplusplus
ebrus 0:0a673c671a56 36 extern "C" {
ebrus 0:0a673c671a56 37 #endif
ebrus 0:0a673c671a56 38
ebrus 0:0a673c671a56 39 // MODE (see GPIOMode_TypeDef structure)
ebrus 0:0a673c671a56 40 // OTYPE (see GPIOOType_TypeDef structure)
ebrus 0:0a673c671a56 41 // PUPD (see GPIOPuPd_TypeDef structure)
ebrus 0:0a673c671a56 42 // AFNUM (see AF_mapping constant table, 0xFF is not used)
ebrus 0:0a673c671a56 43 #define STM_PIN_DATA(MODE, OTYPE, PUPD, AFNUM) (((AFNUM)<<8)|((PUPD)<<4)|((OTYPE)<<2)|((MODE)<<0))
ebrus 0:0a673c671a56 44 #define STM_PIN_MODE(X) (((X)>>0) & 0x3)
ebrus 0:0a673c671a56 45 #define STM_PIN_OTYPE(X) (((X)>>2) & 0x1)
ebrus 0:0a673c671a56 46 #define STM_PIN_PUPD(X) (((X)>>4) & 0x3)
ebrus 0:0a673c671a56 47 #define STM_PIN_AFNUM(X) (((X)>>8) & 0xF)
ebrus 0:0a673c671a56 48
ebrus 0:0a673c671a56 49 // High nibble = port number (0=A, 1=B, 2=C, 3=D, 4=E, 5=F, 6=G, 7=H)
ebrus 0:0a673c671a56 50 // Low nibble = pin number
ebrus 0:0a673c671a56 51 #define STM_PORT(X) (((uint32_t)(X) >> 4) & 0xF)
ebrus 0:0a673c671a56 52 #define STM_PIN(X) ((uint32_t)(X) & 0xF)
ebrus 0:0a673c671a56 53
ebrus 0:0a673c671a56 54 typedef enum {
ebrus 0:0a673c671a56 55 PIN_INPUT,
ebrus 0:0a673c671a56 56 PIN_OUTPUT
ebrus 0:0a673c671a56 57 } PinDirection;
ebrus 0:0a673c671a56 58
ebrus 0:0a673c671a56 59 typedef enum {
ebrus 0:0a673c671a56 60 PA_0 = 0x00,
ebrus 0:0a673c671a56 61 PA_1 = 0x01,
ebrus 0:0a673c671a56 62 PA_2 = 0x02,
ebrus 0:0a673c671a56 63 PA_3 = 0x03,
ebrus 0:0a673c671a56 64 PA_4 = 0x04,
ebrus 0:0a673c671a56 65 PA_5 = 0x05,
ebrus 0:0a673c671a56 66 PA_6 = 0x06,
ebrus 0:0a673c671a56 67 PA_7 = 0x07,
ebrus 0:0a673c671a56 68 PA_8 = 0x08,
ebrus 0:0a673c671a56 69 PA_9 = 0x09,
ebrus 0:0a673c671a56 70 PA_10 = 0x0A,
ebrus 0:0a673c671a56 71 PA_11 = 0x0B,
ebrus 0:0a673c671a56 72 PA_12 = 0x0C,
ebrus 0:0a673c671a56 73 PA_13 = 0x0D,
ebrus 0:0a673c671a56 74 PA_14 = 0x0E,
ebrus 0:0a673c671a56 75 PA_15 = 0x0F,
ebrus 0:0a673c671a56 76
ebrus 0:0a673c671a56 77 PB_0 = 0x10,
ebrus 0:0a673c671a56 78 PB_1 = 0x11,
ebrus 0:0a673c671a56 79 PB_2 = 0x12,
ebrus 0:0a673c671a56 80 PB_3 = 0x13,
ebrus 0:0a673c671a56 81 PB_4 = 0x14,
ebrus 0:0a673c671a56 82 PB_5 = 0x15,
ebrus 0:0a673c671a56 83 PB_6 = 0x16,
ebrus 0:0a673c671a56 84 PB_7 = 0x17,
ebrus 0:0a673c671a56 85 PB_8 = 0x18,
ebrus 0:0a673c671a56 86 PB_9 = 0x19,
ebrus 0:0a673c671a56 87 PB_10 = 0x1A,
ebrus 0:0a673c671a56 88 PB_11 = 0x1B,
ebrus 0:0a673c671a56 89 PB_12 = 0x1C,
ebrus 0:0a673c671a56 90 PB_13 = 0x1D,
ebrus 0:0a673c671a56 91 PB_14 = 0x1E,
ebrus 0:0a673c671a56 92 PB_15 = 0x1F,
ebrus 0:0a673c671a56 93
ebrus 0:0a673c671a56 94 PC_0 = 0x20,
ebrus 0:0a673c671a56 95 PC_1 = 0x21,
ebrus 0:0a673c671a56 96 PC_2 = 0x22,
ebrus 0:0a673c671a56 97 PC_3 = 0x23,
ebrus 0:0a673c671a56 98 PC_4 = 0x24,
ebrus 0:0a673c671a56 99 PC_5 = 0x25,
ebrus 0:0a673c671a56 100 PC_6 = 0x26,
ebrus 0:0a673c671a56 101 PC_7 = 0x27,
ebrus 0:0a673c671a56 102 PC_8 = 0x28,
ebrus 0:0a673c671a56 103 PC_9 = 0x29,
ebrus 0:0a673c671a56 104 PC_10 = 0x2A,
ebrus 0:0a673c671a56 105 PC_11 = 0x2B,
ebrus 0:0a673c671a56 106 PC_12 = 0x2C,
ebrus 0:0a673c671a56 107 PC_13 = 0x2D,
ebrus 0:0a673c671a56 108 PC_14 = 0x2E,
ebrus 0:0a673c671a56 109 PC_15 = 0x2F,
ebrus 0:0a673c671a56 110
ebrus 0:0a673c671a56 111 PD_0 = 0x30,
ebrus 0:0a673c671a56 112 PD_1 = 0x31,
ebrus 0:0a673c671a56 113 PD_2 = 0x32,
ebrus 0:0a673c671a56 114 PD_3 = 0x33,
ebrus 0:0a673c671a56 115 PD_4 = 0x34,
ebrus 0:0a673c671a56 116 PD_5 = 0x35,
ebrus 0:0a673c671a56 117 PD_6 = 0x36,
ebrus 0:0a673c671a56 118 PD_7 = 0x37,
ebrus 0:0a673c671a56 119 PD_8 = 0x38,
ebrus 0:0a673c671a56 120 PD_9 = 0x39,
ebrus 0:0a673c671a56 121 PD_10 = 0x3A,
ebrus 0:0a673c671a56 122 PD_11 = 0x3B,
ebrus 0:0a673c671a56 123 PD_12 = 0x3C,
ebrus 0:0a673c671a56 124 PD_13 = 0x3D,
ebrus 0:0a673c671a56 125 PD_14 = 0x3E,
ebrus 0:0a673c671a56 126 PD_15 = 0x3F,
ebrus 0:0a673c671a56 127
ebrus 0:0a673c671a56 128 PE_0 = 0x40,
ebrus 0:0a673c671a56 129 PE_1 = 0x41,
ebrus 0:0a673c671a56 130 PE_2 = 0x42,
ebrus 0:0a673c671a56 131 PE_3 = 0x43,
ebrus 0:0a673c671a56 132 PE_4 = 0x44,
ebrus 0:0a673c671a56 133 PE_5 = 0x45,
ebrus 0:0a673c671a56 134 PE_6 = 0x46,
ebrus 0:0a673c671a56 135 PE_7 = 0x47,
ebrus 0:0a673c671a56 136 PE_8 = 0x48,
ebrus 0:0a673c671a56 137 PE_9 = 0x49,
ebrus 0:0a673c671a56 138 PE_10 = 0x4A,
ebrus 0:0a673c671a56 139 PE_11 = 0x4B,
ebrus 0:0a673c671a56 140 PE_12 = 0x4C,
ebrus 0:0a673c671a56 141 PE_13 = 0x4D,
ebrus 0:0a673c671a56 142 PE_14 = 0x4E,
ebrus 0:0a673c671a56 143 PE_15 = 0x4F,
ebrus 0:0a673c671a56 144
ebrus 0:0a673c671a56 145 PF_0 = 0x50,
ebrus 0:0a673c671a56 146 PF_1 = 0x51,
ebrus 0:0a673c671a56 147 PF_2 = 0x52,
ebrus 0:0a673c671a56 148 PF_3 = 0x53,
ebrus 0:0a673c671a56 149 PF_4 = 0x54,
ebrus 0:0a673c671a56 150 PF_5 = 0x55,
ebrus 0:0a673c671a56 151 PF_6 = 0x56,
ebrus 0:0a673c671a56 152 PF_7 = 0x57,
ebrus 0:0a673c671a56 153 PF_8 = 0x58,
ebrus 0:0a673c671a56 154 PF_9 = 0x59,
ebrus 0:0a673c671a56 155 PF_10 = 0x5A,
ebrus 0:0a673c671a56 156 PF_11 = 0x5B,
ebrus 0:0a673c671a56 157 PF_12 = 0x5C,
ebrus 0:0a673c671a56 158 PF_13 = 0x5D,
ebrus 0:0a673c671a56 159 PF_14 = 0x5E,
ebrus 0:0a673c671a56 160 PF_15 = 0x5F,
ebrus 0:0a673c671a56 161
ebrus 0:0a673c671a56 162 LED1 = PE_9,
ebrus 0:0a673c671a56 163
ebrus 0:0a673c671a56 164 // Not connected
ebrus 0:0a673c671a56 165 NC = (int)0xFFFFFFFF
ebrus 0:0a673c671a56 166 } PinName;
ebrus 0:0a673c671a56 167
ebrus 0:0a673c671a56 168 typedef enum {
ebrus 0:0a673c671a56 169 PullNone = 0,
ebrus 0:0a673c671a56 170 PullUp = 1,
ebrus 0:0a673c671a56 171 PullDown = 2,
ebrus 0:0a673c671a56 172 OpenDrain = 3,
ebrus 0:0a673c671a56 173 PullDefault = PullNone
ebrus 0:0a673c671a56 174 } PinMode;
ebrus 0:0a673c671a56 175
ebrus 0:0a673c671a56 176 #ifdef __cplusplus
ebrus 0:0a673c671a56 177 }
ebrus 0:0a673c671a56 178 #endif
ebrus 0:0a673c671a56 179
ebrus 0:0a673c671a56 180 #endif