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