Skip to content

Commit 294db25

Browse files
committed
[NUCLEO_F091RC] First commit of HAL files
1 parent c285cc8 commit 294db25

File tree

20 files changed

+3305
-0
lines changed

20 files changed

+3305
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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+
} ADCName;
42+
43+
typedef enum {
44+
DAC_1 = (int)DAC_BASE
45+
} DACName;
46+
47+
typedef enum {
48+
UART_1 = (int)USART1_BASE,
49+
UART_2 = (int)USART2_BASE,
50+
UART_3 = (int)USART3_BASE,
51+
UART_4 = (int)USART4_BASE,
52+
UART_5 = (int)USART5_BASE,
53+
UART_6 = (int)USART6_BASE,
54+
UART_7 = (int)USART7_BASE,
55+
UART_8 = (int)USART8_BASE
56+
} UARTName;
57+
58+
#define STDIO_UART_TX PA_2
59+
#define STDIO_UART_RX PA_3
60+
#define STDIO_UART UART_2
61+
62+
typedef enum {
63+
SPI_1 = (int)SPI1_BASE,
64+
SPI_2 = (int)SPI2_BASE
65+
} SPIName;
66+
67+
typedef enum {
68+
I2C_1 = (int)I2C1_BASE,
69+
I2C_2 = (int)I2C2_BASE
70+
} I2CName;
71+
72+
typedef enum {
73+
PWM_1 = (int)TIM1_BASE,
74+
PWM_2 = (int)TIM2_BASE,
75+
PWM_3 = (int)TIM3_BASE,
76+
PWM_14 = (int)TIM14_BASE,
77+
PWM_15 = (int)TIM15_BASE,
78+
PWM_16 = (int)TIM16_BASE,
79+
PWM_17 = (int)TIM17_BASE
80+
} PWMName;
81+
82+
#ifdef __cplusplus
83+
}
84+
#endif
85+
86+
#endif
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
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+
#define STM_PIN_DATA(MODE, PUPD, AFNUM) ((int)(((AFNUM) << 7) | ((PUPD) << 4) | ((MODE) << 0)))
40+
41+
#define STM_PIN_MODE(X) (((X) >> 0) & 0x0F)
42+
#define STM_PIN_PUPD(X) (((X) >> 4) & 0x07)
43+
#define STM_PIN_AFNUM(X) (((X) >> 7) & 0x0F)
44+
45+
#define STM_MODE_INPUT (0)
46+
#define STM_MODE_OUTPUT_PP (1)
47+
#define STM_MODE_OUTPUT_OD (2)
48+
#define STM_MODE_AF_PP (3)
49+
#define STM_MODE_AF_OD (4)
50+
#define STM_MODE_ANALOG (5)
51+
#define STM_MODE_IT_RISING (6)
52+
#define STM_MODE_IT_FALLING (7)
53+
#define STM_MODE_IT_RISING_FALLING (8)
54+
#define STM_MODE_EVT_RISING (9)
55+
#define STM_MODE_EVT_FALLING (10)
56+
#define STM_MODE_EVT_RISING_FALLING (11)
57+
#define STM_MODE_IT_EVT_RESET (12)
58+
59+
// High nibble = port number (0=A, 1=B, 2=C, 3=D, 4=E, 5=F, 6=G, 7=H)
60+
// Low nibble = pin number
61+
#define STM_PORT(X) (((uint32_t)(X) >> 4) & 0xF)
62+
#define STM_PIN(X) ((uint32_t)(X) & 0xF)
63+
64+
typedef enum {
65+
PIN_INPUT,
66+
PIN_OUTPUT
67+
} PinDirection;
68+
69+
typedef enum {
70+
PA_0 = 0x00,
71+
PA_1 = 0x01,
72+
PA_2 = 0x02,
73+
PA_3 = 0x03,
74+
PA_4 = 0x04,
75+
PA_5 = 0x05,
76+
PA_6 = 0x06,
77+
PA_7 = 0x07,
78+
PA_8 = 0x08,
79+
PA_9 = 0x09,
80+
PA_10 = 0x0A,
81+
PA_11 = 0x0B,
82+
PA_12 = 0x0C,
83+
PA_13 = 0x0D,
84+
PA_14 = 0x0E,
85+
PA_15 = 0x0F,
86+
87+
PB_0 = 0x10,
88+
PB_1 = 0x11,
89+
PB_2 = 0x12,
90+
PB_3 = 0x13,
91+
PB_4 = 0x14,
92+
PB_5 = 0x15,
93+
PB_6 = 0x16,
94+
PB_7 = 0x17,
95+
PB_8 = 0x18,
96+
PB_9 = 0x19,
97+
PB_10 = 0x1A,
98+
PB_11 = 0x1B,
99+
PB_12 = 0x1C,
100+
PB_13 = 0x1D,
101+
PB_14 = 0x1E,
102+
PB_15 = 0x1F,
103+
104+
PC_0 = 0x20,
105+
PC_1 = 0x21,
106+
PC_2 = 0x22,
107+
PC_3 = 0x23,
108+
PC_4 = 0x24,
109+
PC_5 = 0x25,
110+
PC_6 = 0x26,
111+
PC_7 = 0x27,
112+
PC_8 = 0x28,
113+
PC_9 = 0x29,
114+
PC_10 = 0x2A,
115+
PC_11 = 0x2B,
116+
PC_12 = 0x2C,
117+
PC_13 = 0x2D,
118+
PC_14 = 0x2E,
119+
PC_15 = 0x2F,
120+
121+
PD_2 = 0x32,
122+
123+
PF_0 = 0x50,
124+
PF_1 = 0x51,
125+
PF_11 = 0x5B,
126+
127+
// Arduino connector namings
128+
A0 = PA_0,
129+
A1 = PA_1,
130+
A2 = PA_4,
131+
A3 = PB_0,
132+
A4 = PC_1,
133+
A5 = PC_0,
134+
D0 = PA_3,
135+
D1 = PA_2,
136+
D2 = PA_10,
137+
D3 = PB_3,
138+
D4 = PB_5,
139+
D5 = PB_4,
140+
D6 = PB_10,
141+
D7 = PA_8,
142+
D8 = PA_9,
143+
D9 = PC_7,
144+
D10 = PB_6,
145+
D11 = PA_7,
146+
D12 = PA_6,
147+
D13 = PA_5,
148+
D14 = PB_9,
149+
D15 = PB_8,
150+
151+
// Generic signals namings
152+
LED1 = PA_5,
153+
LED2 = PA_5,
154+
LED3 = PA_5,
155+
LED4 = PA_5,
156+
USER_BUTTON = PC_13,
157+
SERIAL_TX = PA_2,
158+
SERIAL_RX = PA_3,
159+
USBTX = PA_2,
160+
USBRX = PA_3,
161+
I2C_SCL = PB_8,
162+
I2C_SDA = PB_9,
163+
SPI_MOSI = PA_7,
164+
SPI_MISO = PA_6,
165+
SPI_SCK = PA_5,
166+
SPI_CS = PB_6,
167+
PWM_OUT = PB_3,
168+
169+
// Not connected
170+
NC = (int)0xFFFFFFFF
171+
} PinName;
172+
173+
typedef enum {
174+
PullNone = 0,
175+
PullUp = 1,
176+
PullDown = 2,
177+
OpenDrain = 3,
178+
PullDefault = PullNone
179+
} PinMode;
180+
181+
#ifdef __cplusplus
182+
}
183+
#endif
184+
185+
#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+
PortF = 5
43+
} PortName;
44+
45+
#ifdef __cplusplus
46+
}
47+
#endif
48+
#endif

0 commit comments

Comments
 (0)