Skip to content

Commit 99b0820

Browse files
committed
[NUCLEO_F401RE] Add hal files
1 parent 01fc443 commit 99b0820

File tree

18 files changed

+2520
-0
lines changed

18 files changed

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

0 commit comments

Comments
 (0)