Skip to content

Commit e94cba3

Browse files
committed
[NUCLEO_F303ZE]Add Hal Target
1 parent afd5070 commit e94cba3

File tree

10 files changed

+1086
-13
lines changed

10 files changed

+1086
-13
lines changed

hal/targets.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,19 @@
744744
"device_has": ["ANALOGIN", "ANALOGOUT", "CAN", "I2C", "I2CSLAVE", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SLEEP", "SPI", "SPISLAVE", "STDIO_MESSAGES"],
745745
"release_versions": ["2", "5"]
746746
},
747+
"NUCLEO_F303ZE": {
748+
"supported_form_factors": ["ARDUINO", "MORPHO"],
749+
"core": "Cortex-M4",
750+
"fpu": "single",
751+
"default_toolchain": "uARM",
752+
"extra_labels": ["STM", "STM32F3", "STM32F303ZE"],
753+
"supported_toolchains": ["ARM", "uARM", "IAR", "GCC_ARM"],
754+
"inherits": ["Target"],
755+
"progen": {"target": "nucleo-f303ze"},
756+
"detect_code": ["0745"],
757+
"device_has": ["ANALOGIN", "ANALOGOUT", "CAN", "I2C", "I2CSLAVE", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SLEEP", "SPI", "SPISLAVE", "STDIO_MESSAGES"],
758+
"release": true
759+
},
747760
"NUCLEO_F334R8": {
748761
"supported_form_factors": ["ARDUINO", "MORPHO"],
749762
"core": "Cortex-M4F",
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/* mbed Microcontroller Library
2+
*******************************************************************************
3+
* Copyright (c) 2015, 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)ADC2_BASE,
42+
ADC_3 = (int)ADC3_BASE,
43+
ADC_4 = (int)ADC4_BASE
44+
} ADCName;
45+
46+
typedef enum {
47+
DAC_1 = (int)DAC_BASE
48+
} DACName;
49+
50+
typedef enum {
51+
UART_1 = (int)USART1_BASE,
52+
UART_2 = (int)USART2_BASE,
53+
UART_3 = (int)USART3_BASE,
54+
UART_4 = (int)UART4_BASE,
55+
UART_5 = (int)UART5_BASE
56+
} UARTName;
57+
58+
#define STDIO_UART_TX SERIAL_TX
59+
#define STDIO_UART_RX SERIAL_RX
60+
#define STDIO_UART UART_3
61+
62+
63+
typedef enum {
64+
SPI_1 = (int)SPI1_BASE,
65+
SPI_2 = (int)SPI2_BASE,
66+
SPI_3 = (int)SPI3_BASE,
67+
SPI_4 = (int)SPI4_BASE
68+
69+
} SPIName;
70+
71+
typedef enum {
72+
I2C_1 = (int)I2C1_BASE,
73+
I2C_2 = (int)I2C2_BASE,
74+
I2C_3 = (int)I2C3_BASE
75+
} I2CName;
76+
77+
typedef enum {
78+
PWM_1 = (int)TIM1_BASE,
79+
PWM_2 = (int)TIM2_BASE,
80+
PWM_3 = (int)TIM3_BASE,
81+
PWM_4 = (int)TIM4_BASE,
82+
PWM_8 = (int)TIM8_BASE,
83+
PWM_15 = (int)TIM15_BASE,
84+
PWM_16 = (int)TIM16_BASE,
85+
PWM_17 = (int)TIM17_BASE,
86+
PWM_20 = (int)TIM20_BASE
87+
} PWMName;
88+
89+
typedef enum {
90+
CAN_1 = (int)CAN_BASE
91+
} CANName;
92+
93+
#ifdef __cplusplus
94+
}
95+
#endif
96+
97+
#endif

hal/targets/hal/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303ZE/PeripheralPins.c

Lines changed: 390 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 255 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,255 @@
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) << 7) | ((PUPD) << 4) | ((MODE) << 0)))
41+
#define STM_PIN_DATA_EXT(MODE, PUPD, AFNUM, CHANNEL, INVERTED) ((int)(((INVERTED & 0x01) << 15) | ((CHANNEL & 0x0F) << 11) | ((AFNUM & 0x0F) << 7) | ((PUPD & 0x07) << 4) | ((MODE & 0x0F) << 0)))
42+
#define STM_PIN_MODE(X) (((X) >> 0) & 0x0F)
43+
#define STM_PIN_PUPD(X) (((X) >> 4) & 0x07)
44+
#define STM_PIN_AFNUM(X) (((X) >> 7) & 0x0F)
45+
#define STM_PIN_CHANNEL(X) (((X) >> 11) & 0x0F)
46+
#define STM_PIN_INVERTED(X) (((X) >> 15) & 0x01)
47+
#define STM_MODE_INPUT (0)
48+
#define STM_MODE_OUTPUT_PP (1)
49+
#define STM_MODE_OUTPUT_OD (2)
50+
#define STM_MODE_AF_PP (3)
51+
#define STM_MODE_AF_OD (4)
52+
#define STM_MODE_ANALOG (5)
53+
#define STM_MODE_IT_RISING (6)
54+
#define STM_MODE_IT_FALLING (7)
55+
#define STM_MODE_IT_RISING_FALLING (8)
56+
#define STM_MODE_EVT_RISING (9)
57+
#define STM_MODE_EVT_FALLING (10)
58+
#define STM_MODE_EVT_RISING_FALLING (11)
59+
#define STM_MODE_IT_EVT_RESET (12)
60+
61+
// High nibble = port number (0=A, 1=B, 2=C, 3=D, 4=E, 5=F, 6=G, 7=H)
62+
// Low nibble = pin number
63+
#define STM_PORT(X) (((uint32_t)(X) >> 4) & 0xF)
64+
#define STM_PIN(X) ((uint32_t)(X) & 0xF)
65+
66+
typedef enum {
67+
PIN_INPUT,
68+
PIN_OUTPUT
69+
} PinDirection;
70+
71+
typedef enum {
72+
PA_0 = 0x00,
73+
PA_1 = 0x01,
74+
PA_2 = 0x02,
75+
PA_3 = 0x03,
76+
PA_4 = 0x04,
77+
PA_5 = 0x05,
78+
PA_6 = 0x06,
79+
PA_7 = 0x07,
80+
PA_8 = 0x08,
81+
PA_9 = 0x09,
82+
PA_10 = 0x0A,
83+
PA_11 = 0x0B,
84+
PA_12 = 0x0C,
85+
PA_13 = 0x0D,
86+
PA_14 = 0x0E,
87+
PA_15 = 0x0F,
88+
89+
PB_0 = 0x10,
90+
PB_1 = 0x11,
91+
PB_2 = 0x12,
92+
PB_3 = 0x13,
93+
PB_4 = 0x14,
94+
PB_5 = 0x15,
95+
PB_6 = 0x16,
96+
PB_7 = 0x17,
97+
PB_8 = 0x18,
98+
PB_9 = 0x19,
99+
PB_10 = 0x1A,
100+
PB_11 = 0x1B,
101+
PB_12 = 0x1C,
102+
PB_13 = 0x1D,
103+
PB_14 = 0x1E,
104+
PB_15 = 0x1F,
105+
106+
PC_0 = 0x20,
107+
PC_1 = 0x21,
108+
PC_2 = 0x22,
109+
PC_3 = 0x23,
110+
PC_4 = 0x24,
111+
PC_5 = 0x25,
112+
PC_6 = 0x26,
113+
PC_7 = 0x27,
114+
PC_8 = 0x28,
115+
PC_9 = 0x29,
116+
PC_10 = 0x2A,
117+
PC_11 = 0x2B,
118+
PC_12 = 0x2C,
119+
PC_13 = 0x2D,
120+
PC_14 = 0x2E,
121+
PC_15 = 0x2F,
122+
123+
PD_0 = 0x30,
124+
PD_1 = 0x31,
125+
PD_2 = 0x32,
126+
PD_3 = 0x33,
127+
PD_4 = 0x34,
128+
PD_5 = 0x35,
129+
PD_6 = 0x36,
130+
PD_7 = 0x37,
131+
PD_8 = 0x38,
132+
PD_9 = 0x39,
133+
PD_10 = 0x3A,
134+
PD_11 = 0x3B,
135+
PD_12 = 0x3C,
136+
PD_13 = 0x3D,
137+
PD_14 = 0x3E,
138+
PD_15 = 0x3F,
139+
140+
PE_0 = 0x40,
141+
PE_1 = 0x41,
142+
PE_2 = 0x42,
143+
PE_3 = 0x43,
144+
PE_4 = 0x44,
145+
PE_5 = 0x45,
146+
PE_6 = 0x46,
147+
PE_7 = 0x47,
148+
PE_8 = 0x48,
149+
PE_9 = 0x49,
150+
PE_10 = 0x4A,
151+
PE_11 = 0x4B,
152+
PE_12 = 0x4C,
153+
PE_13 = 0x4D,
154+
PE_14 = 0x4E,
155+
PE_15 = 0x4F,
156+
157+
PF_0 = 0x50,
158+
PF_1 = 0x51,
159+
PF_2 = 0x52,
160+
PF_3 = 0x53,
161+
PF_4 = 0x54,
162+
PF_5 = 0x55,
163+
PF_6 = 0x56,
164+
PF_7 = 0x57,
165+
PF_8 = 0x58,
166+
PF_9 = 0x59,
167+
PF_10 = 0x5A,
168+
PF_11 = 0x5B,
169+
PF_12 = 0x5C,
170+
PF_13 = 0x5D,
171+
PF_14 = 0x5E,
172+
PF_15 = 0x5F,
173+
174+
PG_0 = 0x60,
175+
PG_1 = 0x61,
176+
PG_2 = 0x62,
177+
PG_3 = 0x63,
178+
PG_4 = 0x64,
179+
PG_5 = 0x65,
180+
PG_6 = 0x66,
181+
PG_7 = 0x67,
182+
PG_8 = 0x68,
183+
PG_9 = 0x69,
184+
PG_10 = 0x6A,
185+
PG_11 = 0x6B,
186+
PG_12 = 0x6C,
187+
PG_13 = 0x6D,
188+
PG_14 = 0x6E,
189+
PG_15 = 0x6F,
190+
191+
PH_0 = 0x70,
192+
PH_1 = 0x71,
193+
PH_2 = 0x72,
194+
195+
// Arduino connector namings
196+
A0 = PA_3,
197+
A1 = PC_0,
198+
A2 = PC_3,
199+
A3 = PC_1,
200+
A4 = PC_4,
201+
A5 = PC_5,
202+
D0 = PG_9,
203+
D1 = PG_14,
204+
D2 = PF_15,
205+
D3 = PE_13,
206+
D4 = PF_14,
207+
D5 = PE_11,
208+
D6 = PE_9,
209+
D7 = PF_13,
210+
D8 = PF_12,
211+
D9 = PD_15,
212+
D10 = PD_14,
213+
D11 = PA_7,
214+
D12 = PA_6,
215+
D13 = PA_5,
216+
D14 = PB_9,
217+
D15 = PB_8,
218+
219+
// Generic signals namings
220+
LED1 = PB_0,
221+
LED2 = PB_7,
222+
LED3 = PB_14,
223+
LED4 = LED1,
224+
USER_BUTTON = PC_13,
225+
SERIAL_TX = PD_8, // Virtual Com Port
226+
SERIAL_RX = PD_9, // Virtual Com Port
227+
USBTX = SERIAL_TX, // Virtual Com Port
228+
USBRX = SERIAL_RX, // Virtual Com Port
229+
I2C_SCL = D15,
230+
I2C_SDA = D14,
231+
SPI_MOSI = D11,
232+
SPI_MISO = D12,
233+
SPI_SCK = D13,
234+
SPI_CS = D10,
235+
PWM_OUT = D9,
236+
237+
// Not connected
238+
NC = (int)0xFFFFFFFF
239+
} PinName;
240+
241+
typedef enum {
242+
PullNone = 0,
243+
PullUp = 1,
244+
PullDown = 2,
245+
OpenDrain = 3,
246+
PullDefault = PullNone
247+
} PinMode;
248+
249+
250+
251+
#ifdef __cplusplus
252+
}
253+
#endif
254+
255+
#endif

0 commit comments

Comments
 (0)