From ea8bf8105812b36fbf1596a78c6e14aa0a0c5a36 Mon Sep 17 00:00:00 2001
From: Dave Hylands <dhylands@gmail.com>
Date: Tue, 28 Jul 2015 08:36:26 -0700
Subject: [PATCH] stmhal: Replace #include "stm32f4xx_hal.h" with #include
 STM32_HAL_H.

---
 stmhal/Makefile           | 1 +
 stmhal/accel.c            | 2 +-
 stmhal/adc.c              | 2 +-
 stmhal/dac.c              | 2 +-
 stmhal/diskio.c           | 2 +-
 stmhal/dma.c              | 2 +-
 stmhal/flash.c            | 2 +-
 stmhal/lcd.c              | 2 +-
 stmhal/led.c              | 2 +-
 stmhal/modpyb.c           | 2 +-
 stmhal/modstm.c           | 2 +-
 stmhal/modutime.c         | 2 +-
 stmhal/mpconfigport.h     | 2 +-
 stmhal/mphal.h            | 2 +-
 stmhal/pendsv.c           | 2 +-
 stmhal/rng.c              | 2 +-
 stmhal/rtc.c              | 2 +-
 stmhal/sdcard.c           | 2 +-
 stmhal/servo.c            | 2 +-
 stmhal/stm32f4xx_it.c     | 2 +-
 stmhal/storage.c          | 2 +-
 stmhal/system_stm32f4xx.c | 2 +-
 stmhal/systick.c          | 2 +-
 stmhal/timer.c            | 2 +-
 stmhal/usbd_conf.c        | 2 +-
 stmhal/usbd_conf.h        | 2 +-
 26 files changed, 26 insertions(+), 25 deletions(-)

diff --git a/stmhal/Makefile b/stmhal/Makefile
index 4931ebf80..b1424a61e 100644
--- a/stmhal/Makefile
+++ b/stmhal/Makefile
@@ -47,6 +47,7 @@ INC += -I../lib/timeutils
 CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mabi=aapcs-linux -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fsingle-precision-constant -Wdouble-promotion
 CFLAGS = $(INC) -Wall -Wpointer-arith -Werror -ansi -std=gnu99 -nostdlib $(CFLAGS_MOD) $(CFLAGS_CORTEX_M4) $(COPT)
 CFLAGS += -Iboards/$(BOARD)
+CFLAGS += -DSTM32_HAL_H='<stm32$(MCU_SERIES)xx_hal.h>'
 
 LDFLAGS = -nostdlib -T $(LD_FILE) -Map=$(@:.elf=.map) --cref
 LIBS =
diff --git a/stmhal/accel.c b/stmhal/accel.c
index a61e8ef3e..64ac85266 100644
--- a/stmhal/accel.c
+++ b/stmhal/accel.c
@@ -27,7 +27,7 @@
 #include <stdio.h>
 #include <string.h>
 
-#include "stm32f4xx_hal.h"
+#include STM32_HAL_H
 
 #include "py/nlr.h"
 #include "py/runtime.h"
diff --git a/stmhal/adc.c b/stmhal/adc.c
index 9ec8eac72..7431a356d 100644
--- a/stmhal/adc.c
+++ b/stmhal/adc.c
@@ -25,7 +25,7 @@
  */
 
 #include <stdio.h>
-#include <stm32f4xx_hal.h>
+#include STM32_HAL_H
 #include <string.h>
 
 #include "py/nlr.h"
diff --git a/stmhal/dac.c b/stmhal/dac.c
index b1e688442..178017e22 100644
--- a/stmhal/dac.c
+++ b/stmhal/dac.c
@@ -28,7 +28,7 @@
 #include <stdint.h>
 #include <string.h>
 
-#include "stm32f4xx_hal.h"
+#include STM32_HAL_H
 
 #include "py/nlr.h"
 #include "py/runtime.h"
diff --git a/stmhal/diskio.c b/stmhal/diskio.c
index abad2f41a..3fd83ec90 100644
--- a/stmhal/diskio.c
+++ b/stmhal/diskio.c
@@ -30,7 +30,7 @@
 #include <stdint.h>
 #include <stdio.h>
 
-#include "stm32f4xx_hal.h"
+#include STM32_HAL_H
 
 #include "py/runtime.h"
 #include "lib/fatfs/ff.h"        /* FatFs lower layer API */
diff --git a/stmhal/dma.c b/stmhal/dma.c
index 77474b767..674e4a937 100644
--- a/stmhal/dma.c
+++ b/stmhal/dma.c
@@ -27,7 +27,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdint.h>
-#include <stm32f4xx_hal.h>
+#include STM32_HAL_H
 
 #include "dma.h"
 
diff --git a/stmhal/flash.c b/stmhal/flash.c
index f576f927a..7eef9b979 100644
--- a/stmhal/flash.c
+++ b/stmhal/flash.c
@@ -24,7 +24,7 @@
  * THE SOFTWARE.
  */
 
-#include <stm32f4xx_hal.h>
+#include STM32_HAL_H
 
 #include "flash.h"
 
diff --git a/stmhal/lcd.c b/stmhal/lcd.c
index f0f7ae90f..12d96e699 100644
--- a/stmhal/lcd.c
+++ b/stmhal/lcd.c
@@ -26,7 +26,7 @@
 
 #include <stdio.h>
 #include <string.h>
-#include <stm32f4xx_hal.h>
+#include STM32_HAL_H
 
 #include "py/nlr.h"
 #include "py/runtime.h"
diff --git a/stmhal/led.c b/stmhal/led.c
index 5c538eee1..11a2ec431 100644
--- a/stmhal/led.c
+++ b/stmhal/led.c
@@ -25,7 +25,7 @@
  */
 
 #include <stdio.h>
-#include <stm32f4xx_hal.h>
+#include STM32_HAL_H
 
 #include "py/nlr.h"
 #include "py/runtime.h"
diff --git a/stmhal/modpyb.c b/stmhal/modpyb.c
index 2c5c19903..2f2e03996 100644
--- a/stmhal/modpyb.c
+++ b/stmhal/modpyb.c
@@ -27,7 +27,7 @@
 #include <stdint.h>
 #include <stdio.h>
 
-#include "stm32f4xx_hal.h"
+#include STM32_HAL_H
 
 #include "py/mpstate.h"
 #include "py/nlr.h"
diff --git a/stmhal/modstm.c b/stmhal/modstm.c
index b795d296b..cedc89481 100644
--- a/stmhal/modstm.c
+++ b/stmhal/modstm.c
@@ -27,7 +27,7 @@
 #include <stdio.h>
 #include <stdint.h>
 
-#include "stm32f4xx_hal.h"
+#include STM32_HAL_H
 
 #include "py/nlr.h"
 #include "py/obj.h"
diff --git a/stmhal/modutime.c b/stmhal/modutime.c
index 75605a37c..72ed4d251 100644
--- a/stmhal/modutime.c
+++ b/stmhal/modutime.c
@@ -26,7 +26,7 @@
 
 #include <stdio.h>
 #include <string.h>
-#include "stm32f4xx_hal.h"
+#include STM32_HAL_H
 
 #include "py/nlr.h"
 #include "py/obj.h"
diff --git a/stmhal/mpconfigport.h b/stmhal/mpconfigport.h
index 67efd091b..0ed8c2189 100644
--- a/stmhal/mpconfigport.h
+++ b/stmhal/mpconfigport.h
@@ -200,7 +200,7 @@ void mp_hal_stdout_tx_strn_cooked(const char *str, mp_uint_t len);
 // value from disable_irq back to enable_irq.  If you really need
 // to know the machine-specific values, see irq.h.
 
-#include <stm32f4xx_hal.h>
+#include STM32_HAL_H
 
 static inline void enable_irq(mp_uint_t state) {
     __set_PRIMASK(state);
diff --git a/stmhal/mphal.h b/stmhal/mphal.h
index b705facc4..e211cc02f 100644
--- a/stmhal/mphal.h
+++ b/stmhal/mphal.h
@@ -1,5 +1,5 @@
 // We use the ST Cube HAL library for most hardware peripherals
-#include <stm32f4xx_hal.h>
+#include STM32_HAL_H
 
 // Basic GPIO functions
 #define GPIO_read_pin(gpio, pin)        (((gpio)->IDR >> (pin)) & 1)
diff --git a/stmhal/pendsv.c b/stmhal/pendsv.c
index 5f5603f35..f374e06fd 100644
--- a/stmhal/pendsv.c
+++ b/stmhal/pendsv.c
@@ -25,7 +25,7 @@
  */
 
 #include <stdlib.h>
-#include <stm32f4xx_hal.h>
+#include STM32_HAL_H
 
 #include "py/mpstate.h"
 #include "py/runtime.h"
diff --git a/stmhal/rng.c b/stmhal/rng.c
index c2685ce2b..2571bc3a0 100644
--- a/stmhal/rng.c
+++ b/stmhal/rng.c
@@ -26,7 +26,7 @@
 
 #include <string.h>
 
-#include "stm32f4xx_hal.h"
+#include STM32_HAL_H
 
 #include "py/obj.h"
 #include "rng.h"
diff --git a/stmhal/rtc.c b/stmhal/rtc.c
index 8b21c6ee5..00821cabb 100644
--- a/stmhal/rtc.c
+++ b/stmhal/rtc.c
@@ -26,7 +26,7 @@
 
 #include <stdio.h>
 
-#include "stm32f4xx_hal.h"
+#include STM32_HAL_H
 
 #include "py/runtime.h"
 #include "rtc.h"
diff --git a/stmhal/sdcard.c b/stmhal/sdcard.c
index 0eac1615c..2e98f73c1 100644
--- a/stmhal/sdcard.c
+++ b/stmhal/sdcard.c
@@ -26,7 +26,7 @@
 
 // TODO make it work with DMA
 
-#include <stm32f4xx_hal.h>
+#include STM32_HAL_H
 
 #include "py/nlr.h"
 #include "py/runtime.h"
diff --git a/stmhal/servo.c b/stmhal/servo.c
index 4c4f95da4..7f5a09f77 100644
--- a/stmhal/servo.c
+++ b/stmhal/servo.c
@@ -26,7 +26,7 @@
 
 #include <stdio.h>
 
-#include "stm32f4xx_hal.h"
+#include STM32_HAL_H
 
 #include "py/nlr.h"
 #include "py/runtime.h"
diff --git a/stmhal/stm32f4xx_it.c b/stmhal/stm32f4xx_it.c
index 26c914da6..7be5af30f 100644
--- a/stmhal/stm32f4xx_it.c
+++ b/stmhal/stm32f4xx_it.c
@@ -68,7 +68,7 @@
 #include <stdio.h>
 
 #include "stm32f4xx_it.h"
-#include "stm32f4xx_hal.h"
+#include STM32_HAL_H
 
 #include "py/obj.h"
 #include "pendsv.h"
diff --git a/stmhal/storage.c b/stmhal/storage.c
index da3541c58..97dfc74b2 100644
--- a/stmhal/storage.c
+++ b/stmhal/storage.c
@@ -26,7 +26,7 @@
 
 #include <stdint.h>
 #include <string.h>
-#include <stm32f4xx_hal.h>
+#include STM32_HAL_H
 
 #include "py/obj.h"
 #include "systick.h"
diff --git a/stmhal/system_stm32f4xx.c b/stmhal/system_stm32f4xx.c
index 207fb528b..f6dbf70db 100644
--- a/stmhal/system_stm32f4xx.c
+++ b/stmhal/system_stm32f4xx.c
@@ -92,7 +92,7 @@
   */
 
 #include "mpconfigboard.h"
-#include "stm32f4xx_hal.h"
+#include STM32_HAL_H
 
 void __fatal_error(const char *msg);
 
diff --git a/stmhal/systick.c b/stmhal/systick.c
index 027e72a41..aed5b9690 100644
--- a/stmhal/systick.c
+++ b/stmhal/systick.c
@@ -24,7 +24,7 @@
  * THE SOFTWARE.
  */
 
-#include <stm32f4xx_hal.h>
+#include STM32_HAL_H
 
 #include "py/obj.h"
 #include "irq.h"
diff --git a/stmhal/timer.c b/stmhal/timer.c
index 002e6b429..f88229b8a 100644
--- a/stmhal/timer.c
+++ b/stmhal/timer.c
@@ -28,7 +28,7 @@
 #include <stdio.h>
 #include <string.h>
 
-#include <stm32f4xx_hal.h>
+#include STM32_HAL_H
 #include "usbd_cdc_msc_hid.h"
 #include "usbd_cdc_interface.h"
 
diff --git a/stmhal/usbd_conf.c b/stmhal/usbd_conf.c
index c55db33c9..600c17a41 100644
--- a/stmhal/usbd_conf.c
+++ b/stmhal/usbd_conf.c
@@ -30,7 +30,7 @@
   */
 
 /* Includes ------------------------------------------------------------------*/
-#include "stm32f4xx_hal.h"
+#include STM32_HAL_H
 #include "usbd_core.h"
 
 /* Private typedef -----------------------------------------------------------*/
diff --git a/stmhal/usbd_conf.h b/stmhal/usbd_conf.h
index fc8015f31..5415eb10b 100644
--- a/stmhal/usbd_conf.h
+++ b/stmhal/usbd_conf.h
@@ -34,7 +34,7 @@
 #define __USBD_CONF_H
 
 /* Includes ------------------------------------------------------------------*/
-#include "stm32f4xx_hal.h"
+#include STM32_HAL_H
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-- 
GitLab