Modified version of the mbed library for use with the Nucleo boards.

Dependents:   EEPROMWrite Full-Project

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Mon Sep 28 14:00:11 2015 +0100
Revision:
632:7687fb9c4f91
Synchronized with git revision f7ce4ed029cc611121464252ff28d5e8beb895b0

Full URL: https://github.com/mbedmicro/mbed/commit/f7ce4ed029cc611121464252ff28d5e8beb895b0/

NUCLEO_F303K8 - add support of the STM32F303K8

Who changed what in which revision?

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