-
Notifications
You must be signed in to change notification settings - Fork 9
/
STM32F3-Discovery_FW_V1.1.0-gcc.patch
388 lines (371 loc) · 14.3 KB
/
STM32F3-Discovery_FW_V1.1.0-gcc.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..83d036b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+deps
+dirs
+*.a
+objs
+inst
diff --git a/Libraries/CMSIS/Include/core_cm0.h b/Libraries/CMSIS/Include/core_cm0.h
index 9e707d7..fa22aad 100644
--- a/Libraries/CMSIS/Include/core_cm0.h
+++ b/Libraries/CMSIS/Include/core_cm0.h
@@ -73,8 +73,8 @@
#elif defined ( __GNUC__ )
#define __ASM __asm /*!< asm keyword for GNU Compiler */
- #define __INLINE inline /*!< inline keyword for GNU Compiler */
- #define __STATIC_INLINE static inline
+ #define __INLINE __attribute__((always_inline)) inline /*!< inline keyword for GNU Compiler */
+ #define __STATIC_INLINE __attribute__((always_inline)) static inline
#elif defined ( __TASKING__ )
#define __ASM __asm /*!< asm keyword for TASKING Compiler */
diff --git a/Libraries/CMSIS/Include/core_cm3.h b/Libraries/CMSIS/Include/core_cm3.h
index efac390..ae8c5fc 100644
--- a/Libraries/CMSIS/Include/core_cm3.h
+++ b/Libraries/CMSIS/Include/core_cm3.h
@@ -77,8 +77,8 @@
#elif defined ( __GNUC__ )
#define __ASM __asm /*!< asm keyword for GNU Compiler */
- #define __INLINE inline /*!< inline keyword for GNU Compiler */
- #define __STATIC_INLINE static inline
+ #define __INLINE __attribute__((always_inline)) inline /*!< inline keyword for GNU Compiler */
+ #define __STATIC_INLINE __attribute__((always_inline)) static inline
#elif defined ( __TASKING__ )
#define __ASM __asm /*!< asm keyword for TASKING Compiler */
diff --git a/Libraries/CMSIS/Include/core_cm4.h b/Libraries/CMSIS/Include/core_cm4.h
index ef818e4..65e5325 100644
--- a/Libraries/CMSIS/Include/core_cm4.h
+++ b/Libraries/CMSIS/Include/core_cm4.h
@@ -77,8 +77,8 @@
#elif defined ( __GNUC__ )
#define __ASM __asm /*!< asm keyword for GNU Compiler */
- #define __INLINE inline /*!< inline keyword for GNU Compiler */
- #define __STATIC_INLINE static inline
+ #define __INLINE __attribute__((always_inline)) inline /*!< inline keyword for GNU Compiler */
+ #define __STATIC_INLINE __attribute__((always_inline)) static inline
#elif defined ( __TASKING__ )
#define __ASM __asm /*!< asm keyword for TASKING Compiler */
diff --git a/Libraries/CMSIS/Include/core_sc000.h b/Libraries/CMSIS/Include/core_sc000.h
index d35b4c2..e2e9ce2 100644
--- a/Libraries/CMSIS/Include/core_sc000.h
+++ b/Libraries/CMSIS/Include/core_sc000.h
@@ -73,8 +73,8 @@
#elif defined ( __GNUC__ )
#define __ASM __asm /*!< asm keyword for GNU Compiler */
- #define __INLINE inline /*!< inline keyword for GNU Compiler */
- #define __STATIC_INLINE static inline
+ #define __INLINE __attribute__((always_inline)) inline /*!< inline keyword for GNU Compiler */
+ #define __STATIC_INLINE __attribute__((always_inline)) static inline
#elif defined ( __TASKING__ )
#define __ASM __asm /*!< asm keyword for TASKING Compiler */
diff --git a/Libraries/CMSIS/Include/core_sc300.h b/Libraries/CMSIS/Include/core_sc300.h
index 7fdc8ee..5f7f1ea 100644
--- a/Libraries/CMSIS/Include/core_sc300.h
+++ b/Libraries/CMSIS/Include/core_sc300.h
@@ -73,8 +73,8 @@
#elif defined ( __GNUC__ )
#define __ASM __asm /*!< asm keyword for GNU Compiler */
- #define __INLINE inline /*!< inline keyword for GNU Compiler */
- #define __STATIC_INLINE static inline
+ #define __INLINE __attribute__((always_inline)) inline /*!< inline keyword for GNU Compiler */
+ #define __STATIC_INLINE __attribute__((always_inline)) static inline
#elif defined ( __TASKING__ )
#define __ASM __asm /*!< asm keyword for TASKING Compiler */
diff --git a/Libraries/Makefile b/Libraries/Makefile
new file mode 100644
index 0000000..8c6bf89
--- /dev/null
+++ b/Libraries/Makefile
@@ -0,0 +1,55 @@
+#
+# Makefile to build the core STM32F3 library.
+# Refined from mblythe86-stm32f3-discovery-basic-template.
+#
+LIB = libstm32f3.a
+
+PREFIX = arm-none-eabi-
+CC=$(PREFIX)gcc
+AR=$(PREFIX)ar
+
+vpath %.c STM32F30x_StdPeriph_Driver/src STM32_USB-FS-Device_Driver/src
+INCLUDEPATH = . CMSIS/Include CMSIS/Device/ST/STM32F30x/Include STM32F30x_StdPeriph_Driver/inc STM32_USB-FS-Device_Driver/inc
+
+CFLAGS = -g -O2 -Wall
+CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m4 -march=armv7e-m
+CFLAGS += -mfpu=fpv4-sp-d16 -mfloat-abi=hard
+CFLAGS += -ffreestanding -nostdlib
+CFLAGS += --include stm32f30x_conf.h
+CFLAGS += $(patsubst %,-I%,$(INCLUDEPATH))
+
+SRCS = stm32f30x_adc.c stm32f30x_can.c stm32f30x_comp.c stm32f30x_crc.c \
+ stm32f30x_dac.c stm32f30x_dbgmcu.c stm32f30x_dma.c \
+ stm32f30x_exti.c stm32f30x_flash.c stm32f30x_gpio.c \
+ stm32f30x_i2c.c stm32f30x_iwdg.c stm32f30x_misc.c stm32f30x_opamp.c \
+ stm32f30x_pwr.c stm32f30x_rcc.c stm32f30x_rtc.c stm32f30x_spi.c \
+ stm32f30x_syscfg.c stm32f30x_tim.c stm32f30x_usart.c \
+ stm32f30x_wwdg.c usb_core.c usb_init.c usb_int.c usb_mem.c \
+ usb_regs.c usb_sil.c
+
+OBJS = $(addprefix objs/,$(SRCS:.c=.o))
+DEPS = $(addprefix deps/,$(SRCS:.c=.d))
+
+.PHONY: all clean
+
+all: $(LIB)
+
+install: all
+ cp -f $(patsubst %,%/*.h,$(INCLUDEPATH)) ../inst
+ cp -f $(LIB) ../inst
+
+-include $(DEPS)
+
+dirs: deps objs
+deps objs:
+ @mkdir -p $@
+
+objs/%.o : %.c dirs
+ $(CC) $(CFLAGS) -c -o $@ $< -MMD -MF deps/$(*F).d
+
+$(LIB): $(OBJS)
+ $(AR) -r $@ $(OBJS)
+
+clean:
+ rm -f dirs $(OBJS) $(DEPS) $(LIB)
+ rmdir deps objs
diff --git a/Libraries/STM32F30x_StdPeriph_Driver/src/stm32f30x_tim.c b/Libraries/STM32F30x_StdPeriph_Driver/src/stm32f30x_tim.c
index 1ec0ed9..b7cbf48 100644
--- a/Libraries/STM32F30x_StdPeriph_Driver/src/stm32f30x_tim.c
+++ b/Libraries/STM32F30x_StdPeriph_Driver/src/stm32f30x_tim.c
@@ -120,7 +120,7 @@
#include "stm32f30x_tim.h"
#include "stm32f30x_rcc.h"
-/** @addtogroup STM32F2xx_StdPeriph_Driver
+/** @addtogroup STM32F30x_StdPeriph_Driver
* @{
*/
diff --git a/Libraries/STM32_USB-FS-Device_Driver/inc/usb_sil.h b/Libraries/STM32_USB-FS-Device_Driver/inc/usb_sil.h
index 0e941cc..b9d8fd0 100644
--- a/Libraries/STM32_USB-FS-Device_Driver/inc/usb_sil.h
+++ b/Libraries/STM32_USB-FS-Device_Driver/inc/usb_sil.h
@@ -36,7 +36,7 @@
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
-uint32_t USB_SIL_Init(void);
+uint32_t USB_SIL_Init(uint16_t interrupt_mask);
uint32_t USB_SIL_Write(uint8_t bEpAddr, uint8_t* pBufferPointer, uint32_t wBufferSize);
uint32_t USB_SIL_Read(uint8_t bEpAddr, uint8_t* pBufferPointer);
diff --git a/Libraries/STM32_USB-FS-Device_Driver/src/usb_sil.c b/Libraries/STM32_USB-FS-Device_Driver/src/usb_sil.c
index 2419904..96b6cc8 100644
--- a/Libraries/STM32_USB-FS-Device_Driver/src/usb_sil.c
+++ b/Libraries/STM32_USB-FS-Device_Driver/src/usb_sil.c
@@ -45,14 +45,13 @@
* Output : None.
* Return : Status.
*******************************************************************************/
-uint32_t USB_SIL_Init(void)
+uint32_t USB_SIL_Init(uint16_t interrupt_mask)
{
/* USB interrupts initialization */
/* clear pending interrupts */
_SetISTR(0);
- wInterrupt_Mask = IMR_MSK;
/* set interrupts mask */
- _SetCNTR(wInterrupt_Mask);
+ _SetCNTR(interrupt_mask);
return 0;
}
diff --git a/Libraries/hw_config.h b/Libraries/hw_config.h
new file mode 100644
index 0000000..99f2fd4
--- /dev/null
+++ b/Libraries/hw_config.h
@@ -0,0 +1,14 @@
+/*
+ * Definitions to rename the global variables in the USB support library
+ */
+#define Data_Mul_MaxPacketSize USB_Data_Mul_MaxPacketSize
+#define StatusInfo USB_StatusInfo
+#define Device_Info USB_Device_Info
+#define EPindex USB_EPindex
+#define SaveState USB_SaveState
+#define pInformation USB_pInformation
+#define pProperty USB_pProperty
+#define pUser_Standard_Requests USB_pUser_Standard_Requests
+#define wInterrupt_Mask USB_wInterrupt_Mask
+#define SaveRState USB_SaveRState
+#define SaveTState USB_SaveTState
diff --git a/Libraries/stm32f30x_conf.h b/Libraries/stm32f30x_conf.h
new file mode 100644
index 0000000..abcae8a
--- /dev/null
+++ b/Libraries/stm32f30x_conf.h
@@ -0,0 +1,82 @@
+/**
+ ******************************************************************************
+ * @file stm32f30x_conf.h
+ * @author MCD Application Team
+ * @version V1.1.0
+ * @date 20-September-2012
+ * @brief Library configuration file.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
+ *
+ * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.st.com/software_license_agreement_liberty_v2
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F30X_CONF_H
+#define __STM32F30X_CONF_H
+
+/* Includes ------------------------------------------------------------------*/
+/* Comment the line below to disable peripheral header file inclusion */
+#include "stm32f30x_adc.h"
+#include "stm32f30x_can.h"
+#include "stm32f30x_crc.h"
+#include "stm32f30x_comp.h"
+#include "stm32f30x_dac.h"
+#include "stm32f30x_dbgmcu.h"
+#include "stm32f30x_dma.h"
+#include "stm32f30x_exti.h"
+#include "stm32f30x_flash.h"
+#include "stm32f30x_gpio.h"
+#include "stm32f30x_syscfg.h"
+#include "stm32f30x_i2c.h"
+#include "stm32f30x_iwdg.h"
+#include "stm32f30x_opamp.h"
+#include "stm32f30x_pwr.h"
+#include "stm32f30x_rcc.h"
+#include "stm32f30x_rtc.h"
+#include "stm32f30x_spi.h"
+#include "stm32f30x_tim.h"
+#include "stm32f30x_usart.h"
+#include "stm32f30x_wwdg.h"
+#include "stm32f30x_misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+/* Uncomment the line below to expanse the "assert_param" macro in the
+ Standard Peripheral Library drivers code */
+/* #define USE_FULL_ASSERT 1 */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr: If expr is false, it calls assert_failed function which reports
+ * the name of the source file and the source line number of the call
+ * that failed. If expr is true, it returns no value.
+ * @retval None
+ */
+ #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+ void assert_failed(uint8_t* file, uint32_t line);
+#else
+ #define assert_param(expr) ((void)0)
+#endif /* USE_FULL_ASSERT */
+
+#endif /* __STM32F30X_CONF_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Libraries/usb_conf.h b/Libraries/usb_conf.h
new file mode 100644
index 0000000..db3355f
--- /dev/null
+++ b/Libraries/usb_conf.h
@@ -0,0 +1 @@
+/* Not needed */
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..1041873
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,3 @@
+all install clean:
+ $(MAKE) -C Libraries $@
+ $(MAKE) -C Utilities $@
diff --git a/Project/Peripheral_Examples/USB_Example/usb_prop.c b/Project/Peripheral_Examples/USB_Example/usb_prop.c
index 90cad66..2949c18 100644
--- a/Project/Peripheral_Examples/USB_Example/usb_prop.c
+++ b/Project/Peripheral_Examples/USB_Example/usb_prop.c
@@ -139,7 +139,7 @@ void Joystick_init(void)
PowerOn();
/* Perform basic device initialization operations */
- USB_SIL_Init();
+ USB_SIL_Init(wInterrupt_Mask = IMR_MSK);
bDeviceState = UNCONNECTED;
}
diff --git a/Utilities/Makefile b/Utilities/Makefile
new file mode 100644
index 0000000..9126c30
--- /dev/null
+++ b/Utilities/Makefile
@@ -0,0 +1,48 @@
+#
+# Makefile to build the core STM32F3 library.
+# Refined from mblythe86-stm32f3-discovery-basic-template.
+#
+LIB = libstm32f3-util.a
+
+PREFIX = arm-none-eabi-
+CC=$(PREFIX)gcc
+AR=$(PREFIX)ar
+
+vpath %.c STM32F3_Discovery
+INCLUDEPATH = ../inst STM32F3_Discovery
+
+CFLAGS = -g -O2 -Wall
+CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m4 -march=armv7e-m
+CFLAGS += -mfpu=fpv4-sp-d16 -mfloat-abi=hard
+CFLAGS += -ffreestanding -nostdlib
+CFLAGS += --include stm32f30x_conf.h
+CFLAGS += $(patsubst %,-I%,$(INCLUDEPATH))
+
+SRCS = stm32f3_discovery.c stm32f3_discovery_l3gd20.c stm32f3_discovery_lsm303dlhc.c
+
+OBJS = $(addprefix objs/,$(SRCS:.c=.o))
+DEPS = $(addprefix deps/,$(SRCS:.c=.d))
+
+.PHONY: all clean
+
+all: $(LIB)
+
+install: all
+ cp -f $(patsubst %,%/*.h,STM32F3_Discovery) ../inst
+ cp -f $(LIB) ../inst
+
+-include $(DEPS)
+
+dirs: deps objs
+deps objs:
+ @mkdir -p $@
+
+objs/%.o : %.c dirs
+ $(CC) $(CFLAGS) -c -o $@ $< -MMD -MF deps/$(*F).d
+
+$(LIB): $(OBJS)
+ $(AR) -r $@ $(OBJS)
+
+clean:
+ rm -f dirs $(OBJS) $(DEPS) $(LIB)
+ rmdir deps objs
diff --git a/inst/.gitignore b/inst/.gitignore
new file mode 100644
index 0000000..e69de29