summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--stmhal/Makefile2
-rw-r--r--stmhal/boards/NETDUINO_PLUS_2/mpconfigboard.h29
-rw-r--r--stmhal/boards/PYBOARD3/mpconfigboard.h32
-rw-r--r--stmhal/boards/PYBOARD4/mpconfigboard.h33
-rw-r--r--stmhal/boards/PYBV10/mpconfigboard.h35
-rw-r--r--stmhal/boards/PYBV10/pins.csv (renamed from stmhal/boards/PYBv10/pins.csv)1
-rw-r--r--stmhal/boards/PYBV10/stm32f4xx_hal_conf.h (renamed from stmhal/boards/PYBOARD4/stm32f4xx_hal_conf.h)0
-rw-r--r--stmhal/boards/PYBV3/mpconfigboard.h35
-rw-r--r--stmhal/boards/PYBV3/pins.csv (renamed from stmhal/boards/PYBOARD3/pins.csv)2
-rw-r--r--stmhal/boards/PYBV3/stm32f4xx_hal_conf.h (renamed from stmhal/boards/PYBv10/stm32f4xx_hal_conf.h)0
-rw-r--r--stmhal/boards/PYBV4/mpconfigboard.h35
-rw-r--r--stmhal/boards/PYBV4/pins.csv (renamed from stmhal/boards/PYBOARD4/pins.csv)1
-rw-r--r--stmhal/boards/PYBV4/stm32f4xx_hal_conf.h393
-rw-r--r--stmhal/boards/PYBv10/mpconfigboard.h33
-rw-r--r--stmhal/boards/STM32F4DISC/mpconfigboard.h27
-rw-r--r--stmhal/diskio.c10
-rw-r--r--stmhal/lcd.c4
-rw-r--r--stmhal/led.c36
-rw-r--r--stmhal/pin_map.c2
-rw-r--r--stmhal/sdcard.c20
-rw-r--r--stmhal/usart.c2
-rw-r--r--stmhal/usb.c4
-rw-r--r--stmhal/usbd_msc_storage.c6
-rw-r--r--stmhal/usrsw.c16
24 files changed, 586 insertions, 172 deletions
diff --git a/stmhal/Makefile b/stmhal/Makefile
index 67c1ebcb42..0f3fe46cfa 100644
--- a/stmhal/Makefile
+++ b/stmhal/Makefile
@@ -29,7 +29,7 @@ INC += -I$(FATFS_DIR)/src
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 -Werror -ansi -std=gnu99 $(CFLAGS_CORTEX_M4) $(COPT)
-BOARD ?= PYBv10
+BOARD ?= PYBV10
ifeq ($(wildcard boards/$(BOARD)/.),)
$(error Invalid BOARD specified)
endif
diff --git a/stmhal/boards/NETDUINO_PLUS_2/mpconfigboard.h b/stmhal/boards/NETDUINO_PLUS_2/mpconfigboard.h
index 948b886819..a01d37aea8 100644
--- a/stmhal/boards/NETDUINO_PLUS_2/mpconfigboard.h
+++ b/stmhal/boards/NETDUINO_PLUS_2/mpconfigboard.h
@@ -19,19 +19,16 @@
#define MICROPY_HW_ENABLE_DAC (0)
// USRSW is pulled low. Pressing the button makes the input go high.
-#define USRSW_PIN (pin_B11)
-#define USRSW_PULL (GPIO_NOPULL)
-#define USRSW_EXTI_MODE (GPIO_MODE_IT_RISING)
-#define USRSW_PRESSED (1)
-
-/* LED */
-#define PYB_LED1 (pin_A10) // Blue LED
-#define PYB_LED2 (pin_C13) // White LED (aka Power)
-#define PYB_LED3 (pin_A10) // Same as Led(1)
-#define PYB_LED4 (pin_C13) // Same as Led(2)
-
-#define PYB_OTYPE (GPIO_MODE_OUTPUT_PP)
-
-#define PYB_LED_ON(pin) (pin->gpio->BSRRL = pin->pin_mask)
-#define PYB_LED_OFF(pin) (pin->gpio->BSRRH = pin->pin_mask)
-
+#define MICROPY_HW_USRSW_PIN (pin_B11)
+#define MICROPY_HW_USRSW_PULL (GPIO_NOPULL)
+#define MICROPY_HW_USRSW_EXTI_MODE (GPIO_MODE_IT_RISING)
+#define MICROPY_HW_USRSW_PRESSED (1)
+
+// LEDs
+#define MICROPY_HW_LED1 (pin_A10) // Blue LED
+#define MICROPY_HW_LED2 (pin_C13) // White LED (aka Power)
+#define MICROPY_HW_LED3 (pin_A10) // Same as Led(1)
+#define MICROPY_HW_LED4 (pin_C13) // Same as Led(2)
+#define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP)
+#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRRL = pin->pin_mask)
+#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRRH = pin->pin_mask)
diff --git a/stmhal/boards/PYBOARD3/mpconfigboard.h b/stmhal/boards/PYBOARD3/mpconfigboard.h
deleted file mode 100644
index 1cd1d94818..0000000000
--- a/stmhal/boards/PYBOARD3/mpconfigboard.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#define PYBOARD3
-
-#define MICROPY_HW_BOARD_NAME "PYBv3"
-
-#define MICROPY_HW_HAS_SWITCH (1)
-#define MICROPY_HW_HAS_SDCARD (1)
-#define MICROPY_HW_HAS_MMA7660 (1)
-#define MICROPY_HW_HAS_LIS3DSH (0)
-#define MICROPY_HW_HAS_LCD (0)
-#define MICROPY_HW_HAS_WLAN (0)
-#define MICROPY_HW_ENABLE_RNG (1)
-#define MICROPY_HW_ENABLE_RTC (1)
-#define MICROPY_HW_ENABLE_TIMER (1)
-#define MICROPY_HW_ENABLE_SERVO (1)
-#define MICROPY_HW_ENABLE_DAC (0)
-
-// USRSW has no pullup or pulldown, and pressing the switch makes the input go low
-#define USRSW_PIN (pin_A13)
-#define USRSW_PULL (GPIO_PULLUP)
-#define USRSW_EXTI_MODE (GPIO_MODE_IT_FALLING)
-#define USRSW_PRESSED (0)
-
-/* LED */
-#define PYB_LED1 (pin_A8) // R1 - red
-#define PYB_LED2 (pin_A10) // R2 - red
-#define PYB_LED3 (pin_C4) // G1 - green
-#define PYB_LED4 (pin_C5) // G2 - green
-
-#define PYB_OTYPE (GPIO_MODE_OUTPUT_PP)
-
-#define PYB_LED_ON(pin) (pin->gpio->BSRRH = pin->pin_mask)
-#define PYB_LED_OFF(pin) (pin->gpio->BSRRL = pin->pin_mask)
diff --git a/stmhal/boards/PYBOARD4/mpconfigboard.h b/stmhal/boards/PYBOARD4/mpconfigboard.h
deleted file mode 100644
index 9a046ffffa..0000000000
--- a/stmhal/boards/PYBOARD4/mpconfigboard.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#define PYBOARD4
-
-#define MICROPY_HW_BOARD_NAME "PYBv4"
-
-#define MICROPY_HW_HAS_SWITCH (1)
-#define MICROPY_HW_HAS_SDCARD (1)
-#define MICROPY_HW_HAS_MMA7660 (1)
-#define MICROPY_HW_HAS_LIS3DSH (0)
-#define MICROPY_HW_HAS_LCD (1)
-#define MICROPY_HW_HAS_WLAN (0)
-#define MICROPY_HW_ENABLE_RNG (1)
-#define MICROPY_HW_ENABLE_RTC (1)
-#define MICROPY_HW_ENABLE_TIMER (1)
-#define MICROPY_HW_ENABLE_SERVO (1)
-#define MICROPY_HW_ENABLE_DAC (1)
-
-// USRSW has no pullup or pulldown, and pressing the switch makes the input go low
-#define USRSW_PIN (pin_B3)
-#define USRSW_PULL (GPIO_PULLUP)
-#define USRSW_EXTI_MODE (GPIO_MODE_IT_FALLING)
-#define USRSW_PRESSED (0)
-
-/* LED */
-#define PYB_LED1 (pin_A13) // red
-#define PYB_LED2 (pin_A14) // green
-#define PYB_LED3 (pin_A15) // yellow
-#define PYB_LED4 (pin_B4) // blue
-
-#define PYB_OTYPE (GPIO_MODE_OUTPUT_PP)
-
-#define PYB_LED_ON(pin) (pin->gpio->BSRRL = pin->pin_mask)
-#define PYB_LED_OFF(pin) (pin->gpio->BSRRH = pin->pin_mask)
-
diff --git a/stmhal/boards/PYBV10/mpconfigboard.h b/stmhal/boards/PYBV10/mpconfigboard.h
new file mode 100644
index 0000000000..9386c04a2d
--- /dev/null
+++ b/stmhal/boards/PYBV10/mpconfigboard.h
@@ -0,0 +1,35 @@
+#define PYBV10
+
+#define MICROPY_HW_BOARD_NAME "PYBv1.0"
+
+#define MICROPY_HW_HAS_SWITCH (1)
+#define MICROPY_HW_HAS_SDCARD (1)
+#define MICROPY_HW_HAS_MMA7660 (1)
+#define MICROPY_HW_HAS_LIS3DSH (0)
+#define MICROPY_HW_HAS_LCD (1)
+#define MICROPY_HW_HAS_WLAN (0)
+#define MICROPY_HW_ENABLE_RNG (1)
+#define MICROPY_HW_ENABLE_RTC (1)
+#define MICROPY_HW_ENABLE_TIMER (1)
+#define MICROPY_HW_ENABLE_SERVO (1)
+#define MICROPY_HW_ENABLE_DAC (1)
+
+// USRSW has no pullup or pulldown, and pressing the switch makes the input go low
+#define MICROPY_HW_USRSW_PIN (pin_B3)
+#define MICROPY_HW_USRSW_PULL (GPIO_PULLUP)
+#define MICROPY_HW_USRSW_EXTI_MODE (GPIO_MODE_IT_FALLING)
+#define MICROPY_HW_USRSW_PRESSED (0)
+
+// The pyboard has 4 LEDs
+#define MICROPY_HW_LED1 (pin_A13) // red
+#define MICROPY_HW_LED2 (pin_A14) // green
+#define MICROPY_HW_LED3 (pin_A15) // yellow
+#define MICROPY_HW_LED4 (pin_B4) // blue
+#define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP)
+#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRRL = pin->pin_mask)
+#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRRH = pin->pin_mask)
+
+// SD card detect switch
+#define MICROPY_HW_SDCARD_DETECT_PIN (pin_A8)
+#define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP)
+#define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_RESET)
diff --git a/stmhal/boards/PYBv10/pins.csv b/stmhal/boards/PYBV10/pins.csv
index 2ca7fef184..34d96c8dd6 100644
--- a/stmhal/boards/PYBv10/pins.csv
+++ b/stmhal/boards/PYBV10/pins.csv
@@ -43,3 +43,4 @@ LED_RED,PA13
LED_GREEN,PA14
LED_YELLOW,PA15
SW,PB3
+SD,PA8
diff --git a/stmhal/boards/PYBOARD4/stm32f4xx_hal_conf.h b/stmhal/boards/PYBV10/stm32f4xx_hal_conf.h
index 315c24dc67..315c24dc67 100644
--- a/stmhal/boards/PYBOARD4/stm32f4xx_hal_conf.h
+++ b/stmhal/boards/PYBV10/stm32f4xx_hal_conf.h
diff --git a/stmhal/boards/PYBV3/mpconfigboard.h b/stmhal/boards/PYBV3/mpconfigboard.h
new file mode 100644
index 0000000000..f47a01bc4c
--- /dev/null
+++ b/stmhal/boards/PYBV3/mpconfigboard.h
@@ -0,0 +1,35 @@
+#define PYBV3
+
+#define MICROPY_HW_BOARD_NAME "PYBv3"
+
+#define MICROPY_HW_HAS_SWITCH (1)
+#define MICROPY_HW_HAS_SDCARD (1)
+#define MICROPY_HW_HAS_MMA7660 (1)
+#define MICROPY_HW_HAS_LIS3DSH (0)
+#define MICROPY_HW_HAS_LCD (0)
+#define MICROPY_HW_HAS_WLAN (0)
+#define MICROPY_HW_ENABLE_RNG (1)
+#define MICROPY_HW_ENABLE_RTC (1)
+#define MICROPY_HW_ENABLE_TIMER (1)
+#define MICROPY_HW_ENABLE_SERVO (1)
+#define MICROPY_HW_ENABLE_DAC (0)
+
+// USRSW has no pullup or pulldown, and pressing the switch makes the input go low
+#define MICROPY_HW_USRSW_PIN (pin_A13)
+#define MICROPY_HW_USRSW_PULL (GPIO_PULLUP)
+#define MICROPY_HW_USRSW_EXTI_MODE (GPIO_MODE_IT_FALLING)
+#define MICROPY_HW_USRSW_PRESSED (0)
+
+// LEDs
+#define MICROPY_HW_LED1 (pin_A8) // R1 - red
+#define MICROPY_HW_LED2 (pin_A10) // R2 - red
+#define MICROPY_HW_LED3 (pin_C4) // G1 - green
+#define MICROPY_HW_LED4 (pin_C5) // G2 - green
+#define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP)
+#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRRH = pin->pin_mask)
+#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRRL = pin->pin_mask)
+
+// SD card detect switch
+#define MICROPY_HW_SDCARD_DETECT_PIN (pin_C13)
+#define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLDOWN)
+#define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_SET)
diff --git a/stmhal/boards/PYBOARD3/pins.csv b/stmhal/boards/PYBV3/pins.csv
index cc07b15445..cce8a9e111 100644
--- a/stmhal/boards/PYBOARD3/pins.csv
+++ b/stmhal/boards/PYBV3/pins.csv
@@ -34,4 +34,4 @@ LED_R2,PA10
LED_G1,PC4
LED_G2,PC5
SW,PA13
-
+SD,PC13
diff --git a/stmhal/boards/PYBv10/stm32f4xx_hal_conf.h b/stmhal/boards/PYBV3/stm32f4xx_hal_conf.h
index 315c24dc67..315c24dc67 100644
--- a/stmhal/boards/PYBv10/stm32f4xx_hal_conf.h
+++ b/stmhal/boards/PYBV3/stm32f4xx_hal_conf.h
diff --git a/stmhal/boards/PYBV4/mpconfigboard.h b/stmhal/boards/PYBV4/mpconfigboard.h
new file mode 100644
index 0000000000..1846491c3a
--- /dev/null
+++ b/stmhal/boards/PYBV4/mpconfigboard.h
@@ -0,0 +1,35 @@
+#define PYBV4
+
+#define MICROPY_HW_BOARD_NAME "PYBv4"
+
+#define MICROPY_HW_HAS_SWITCH (1)
+#define MICROPY_HW_HAS_SDCARD (1)
+#define MICROPY_HW_HAS_MMA7660 (1)
+#define MICROPY_HW_HAS_LIS3DSH (0)
+#define MICROPY_HW_HAS_LCD (1)
+#define MICROPY_HW_HAS_WLAN (0)
+#define MICROPY_HW_ENABLE_RNG (1)
+#define MICROPY_HW_ENABLE_RTC (1)
+#define MICROPY_HW_ENABLE_TIMER (1)
+#define MICROPY_HW_ENABLE_SERVO (1)
+#define MICROPY_HW_ENABLE_DAC (1)
+
+// USRSW has no pullup or pulldown, and pressing the switch makes the input go low
+#define MICROPY_HW_USRSW_PIN (pin_B3)
+#define MICROPY_HW_USRSW_PULL (GPIO_PULLUP)
+#define MICROPY_HW_USRSW_EXTI_MODE (GPIO_MODE_IT_FALLING)
+#define MICROPY_HW_USRSW_PRESSED (0)
+
+// LEDs
+#define MICROPY_HW_LED1 (pin_A13) // red
+#define MICROPY_HW_LED2 (pin_A14) // green
+#define MICROPY_HW_LED3 (pin_A15) // yellow
+#define MICROPY_HW_LED4 (pin_B4) // blue
+#define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP)
+#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRRL = pin->pin_mask)
+#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRRH = pin->pin_mask)
+
+// SD card detect switch
+#define MICROPY_HW_SDCARD_DETECT_PIN (pin_A8)
+#define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP)
+#define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_RESET)
diff --git a/stmhal/boards/PYBOARD4/pins.csv b/stmhal/boards/PYBV4/pins.csv
index 2ca7fef184..34d96c8dd6 100644
--- a/stmhal/boards/PYBOARD4/pins.csv
+++ b/stmhal/boards/PYBV4/pins.csv
@@ -43,3 +43,4 @@ LED_RED,PA13
LED_GREEN,PA14
LED_YELLOW,PA15
SW,PB3
+SD,PA8
diff --git a/stmhal/boards/PYBV4/stm32f4xx_hal_conf.h b/stmhal/boards/PYBV4/stm32f4xx_hal_conf.h
new file mode 100644
index 0000000000..315c24dc67
--- /dev/null
+++ b/stmhal/boards/PYBV4/stm32f4xx_hal_conf.h
@@ -0,0 +1,393 @@
+/**
+ ******************************************************************************
+ * @file stm32f4xx_hal_conf.h
+ * @author MCD Application Team
+ * @version V1.0.1
+ * @date 26-February-2014
+ * @brief HAL configuration file.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F4xx_HAL_CONF_H
+#define __STM32F4xx_HAL_CONF_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+#define STM32F405xx
+#define USE_USB_FS
+
+/* ########################## Module Selection ############################## */
+/**
+ * @brief This is the list of modules to be used in the HAL driver
+ */
+#define HAL_MODULE_ENABLED
+#define HAL_ADC_MODULE_ENABLED
+#define HAL_CAN_MODULE_ENABLED
+#define HAL_CRC_MODULE_ENABLED
+#define HAL_CRYP_MODULE_ENABLED
+#define HAL_DAC_MODULE_ENABLED
+#define HAL_DCMI_MODULE_ENABLED
+#define HAL_DMA_MODULE_ENABLED
+/* #define HAL_DMA2D_MODULE_ENABLED */
+#define HAL_ETH_MODULE_ENABLED
+#define HAL_FLASH_MODULE_ENABLED
+#define HAL_NAND_MODULE_ENABLED
+#define HAL_NOR_MODULE_ENABLED
+#define HAL_PCCARD_MODULE_ENABLED
+#define HAL_SRAM_MODULE_ENABLED
+/* #define HAL_SDRAM_MODULE_ENABLED */
+#define HAL_HASH_MODULE_ENABLED
+#define HAL_GPIO_MODULE_ENABLED
+#define HAL_I2C_MODULE_ENABLED
+#define HAL_I2S_MODULE_ENABLED
+#define HAL_IWDG_MODULE_ENABLED
+#define HAL_LTDC_MODULE_ENABLED
+#define HAL_PWR_MODULE_ENABLED
+#define HAL_RCC_MODULE_ENABLED
+#define HAL_RNG_MODULE_ENABLED
+#define HAL_RTC_MODULE_ENABLED
+/* #define HAL_SAI_MODULE_ENABLED */
+#define HAL_SD_MODULE_ENABLED
+#define HAL_SPI_MODULE_ENABLED
+#define HAL_TIM_MODULE_ENABLED
+#define HAL_UART_MODULE_ENABLED
+#define HAL_USART_MODULE_ENABLED
+#define HAL_IRDA_MODULE_ENABLED
+#define HAL_SMARTCARD_MODULE_ENABLED
+#define HAL_WWDG_MODULE_ENABLED
+#define HAL_CORTEX_MODULE_ENABLED
+#define HAL_PCD_MODULE_ENABLED
+#define HAL_HCD_MODULE_ENABLED
+
+
+/* ########################## HSE/HSI Values adaptation ##################### */
+/**
+ * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSE is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSE_VALUE)
+ #define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */
+#endif /* HSE_VALUE */
+
+#if !defined (HSE_STARTUP_TIMEOUT)
+ #define HSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for HSE start up, in ms */
+#endif /* HSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief Internal High Speed oscillator (HSI) value.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSI is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSI_VALUE)
+ #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/
+#endif /* HSI_VALUE */
+
+/**
+ * @brief External clock source for I2S peripheral
+ * This value is used by the I2S HAL module to compute the I2S clock source
+ * frequency, this source is inserted directly through I2S_CKIN pad.
+ */
+#if !defined (EXTERNAL_CLOCK_VALUE)
+ #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000) /*!< Value of the Internal oscillator in Hz*/
+#endif /* EXTERNAL_CLOCK_VALUE */
+
+/* Tip: To avoid modifying this file each time you need to use different HSE,
+ === you can define the HSE value in your toolchain compiler preprocessor. */
+
+/* ########################### System Configuration ######################### */
+/**
+ * @brief This is the HAL system configuration section
+ */
+#define VDD_VALUE ((uint32_t)3300) /*!< Value of VDD in mv */
+#define USE_RTOS 0
+#define PREFETCH_ENABLE 1
+#define INSTRUCTION_CACHE_ENABLE 1
+#define DATA_CACHE_ENABLE 1
+
+/* ########################## Assert Selection ############################## */
+/**
+ * @brief Uncomment the line below to expanse the "assert_param" macro in the
+ * HAL drivers code
+ */
+/* #define USE_FULL_ASSERT 1 */
+
+/* ################## Ethernet peripheral configuration ##################### */
+
+/* Section 1 : Ethernet peripheral configuration */
+
+/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
+#define MAC_ADDR0 2
+#define MAC_ADDR1 0
+#define MAC_ADDR2 0
+#define MAC_ADDR3 0
+#define MAC_ADDR4 0
+#define MAC_ADDR5 0
+
+/* Definition of the Ethernet driver buffers size and count */
+#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
+#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
+#define ETH_RXBUFNB ((uint32_t)4) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
+#define ETH_TXBUFNB ((uint32_t)4) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
+
+/* Section 2: PHY configuration section */
+
+/* DP83848 PHY Address*/
+#define DP83848_PHY_ADDRESS 0x01
+/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
+#define PHY_RESET_DELAY ((uint32_t)0x000000FF)
+/* PHY Configuration delay */
+#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFF)
+
+#define PHY_READ_TO ((uint32_t)0x0000FFFF)
+#define PHY_WRITE_TO ((uint32_t)0x0000FFFF)
+
+/* Section 3: Common PHY Registers */
+
+#define PHY_BCR ((uint16_t)0x00) /*!< Transceiver Basic Control Register */
+#define PHY_BSR ((uint16_t)0x01) /*!< Transceiver Basic Status Register */
+
+#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */
+#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */
+#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */
+#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */
+#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */
+#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */
+#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */
+#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */
+#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */
+#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */
+
+#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */
+#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */
+#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */
+
+/* Section 4: Extended PHY Registers */
+
+#define PHY_SR ((uint16_t)0x10) /*!< PHY status register Offset */
+#define PHY_MICR ((uint16_t)0x11) /*!< MII Interrupt Control Register */
+#define PHY_MISR ((uint16_t)0x12) /*!< MII Interrupt Status and Misc. Control Register */
+
+#define PHY_LINK_STATUS ((uint16_t)0x0001) /*!< PHY Link mask */
+#define PHY_SPEED_STATUS ((uint16_t)0x0002) /*!< PHY Speed mask */
+#define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /*!< PHY Duplex mask */
+
+#define PHY_MICR_INT_EN ((uint16_t)0x0002) /*!< PHY Enable interrupts */
+#define PHY_MICR_INT_OE ((uint16_t)0x0001) /*!< PHY Enable output interrupt events */
+
+#define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) /*!< Enable Interrupt on change of link status */
+#define PHY_LINK_INTERRUPT ((uint16_t)0x2000) /*!< PHY link status interrupt mask */
+
+/* Includes ------------------------------------------------------------------*/
+/**
+ * @brief Include module's header file
+ */
+
+#ifdef HAL_RCC_MODULE_ENABLED
+ #include "stm32f4xx_hal_rcc.h"
+#endif /* HAL_RCC_MODULE_ENABLED */
+
+#ifdef HAL_GPIO_MODULE_ENABLED
+ #include "stm32f4xx_hal_gpio.h"
+#endif /* HAL_GPIO_MODULE_ENABLED */
+
+#ifdef HAL_DMA_MODULE_ENABLED
+ #include "stm32f4xx_hal_dma.h"
+#endif /* HAL_DMA_MODULE_ENABLED */
+
+#ifdef HAL_CORTEX_MODULE_ENABLED
+ #include "stm32f4xx_hal_cortex.h"
+#endif /* HAL_CORTEX_MODULE_ENABLED */
+
+#ifdef HAL_ADC_MODULE_ENABLED
+ #include "stm32f4xx_hal_adc.h"
+#endif /* HAL_ADC_MODULE_ENABLED */
+
+#ifdef HAL_CAN_MODULE_ENABLED
+ #include "stm32f4xx_hal_can.h"
+#endif /* HAL_CAN_MODULE_ENABLED */
+
+#ifdef HAL_CRC_MODULE_ENABLED
+ #include "stm32f4xx_hal_crc.h"
+#endif /* HAL_CRC_MODULE_ENABLED */
+
+#ifdef HAL_CRYP_MODULE_ENABLED
+ #include "stm32f4xx_hal_cryp.h"
+#endif /* HAL_CRYP_MODULE_ENABLED */
+
+#ifdef HAL_DMA2D_MODULE_ENABLED
+ #include "stm32f4xx_hal_dma2d.h"
+#endif /* HAL_DMA2D_MODULE_ENABLED */
+
+#ifdef HAL_DAC_MODULE_ENABLED
+ #include "stm32f4xx_hal_dac.h"
+#endif /* HAL_DAC_MODULE_ENABLED */
+
+#ifdef HAL_DCMI_MODULE_ENABLED
+ #include "stm32f4xx_hal_dcmi.h"
+#endif /* HAL_DCMI_MODULE_ENABLED */
+
+#ifdef HAL_ETH_MODULE_ENABLED
+ #include "stm32f4xx_hal_eth.h"
+#endif /* HAL_ETH_MODULE_ENABLED */
+
+#ifdef HAL_FLASH_MODULE_ENABLED
+ #include "stm32f4xx_hal_flash.h"
+#endif /* HAL_FLASH_MODULE_ENABLED */
+
+#ifdef HAL_SRAM_MODULE_ENABLED
+ #include "stm32f4xx_hal_sram.h"
+#endif /* HAL_SRAM_MODULE_ENABLED */
+
+#ifdef HAL_NOR_MODULE_ENABLED
+ #include "stm32f4xx_hal_nor.h"
+#endif /* HAL_NOR_MODULE_ENABLED */
+
+#ifdef HAL_NAND_MODULE_ENABLED
+ #include "stm32f4xx_hal_nand.h"
+#endif /* HAL_NAND_MODULE_ENABLED */
+
+#ifdef HAL_PCCARD_MODULE_ENABLED
+ #include "stm32f4xx_hal_pccard.h"
+#endif /* HAL_PCCARD_MODULE_ENABLED */
+
+#ifdef HAL_SDRAM_MODULE_ENABLED
+ #include "stm32f4xx_hal_sdram.h"
+#endif /* HAL_SDRAM_MODULE_ENABLED */
+
+#ifdef HAL_HASH_MODULE_ENABLED
+ #include "stm32f4xx_hal_hash.h"
+#endif /* HAL_HASH_MODULE_ENABLED */
+
+#ifdef HAL_I2C_MODULE_ENABLED
+ #include "stm32f4xx_hal_i2c.h"
+#endif /* HAL_I2C_MODULE_ENABLED */
+
+#ifdef HAL_I2S_MODULE_ENABLED
+ #include "stm32f4xx_hal_i2s.h"
+#endif /* HAL_I2S_MODULE_ENABLED */
+
+#ifdef HAL_IWDG_MODULE_ENABLED
+ #include "stm32f4xx_hal_iwdg.h"
+#endif /* HAL_IWDG_MODULE_ENABLED */
+
+#ifdef HAL_LTDC_MODULE_ENABLED
+ #include "stm32f4xx_hal_ltdc.h"
+#endif /* HAL_LTDC_MODULE_ENABLED */
+
+#ifdef HAL_PWR_MODULE_ENABLED
+ #include "stm32f4xx_hal_pwr.h"
+#endif /* HAL_PWR_MODULE_ENABLED */
+
+#ifdef HAL_RNG_MODULE_ENABLED
+ #include "stm32f4xx_hal_rng.h"
+#endif /* HAL_RNG_MODULE_ENABLED */
+
+#ifdef HAL_RTC_MODULE_ENABLED
+ #include "stm32f4xx_hal_rtc.h"
+#endif /* HAL_RTC_MODULE_ENABLED */
+
+#ifdef HAL_SAI_MODULE_ENABLED
+ #include "stm32f4xx_hal_sai.h"
+#endif /* HAL_SAI_MODULE_ENABLED */
+
+#ifdef HAL_SD_MODULE_ENABLED
+ #include "stm32f4xx_hal_sd.h"
+#endif /* HAL_SD_MODULE_ENABLED */
+
+#ifdef HAL_SPI_MODULE_ENABLED
+ #include "stm32f4xx_hal_spi.h"
+#endif /* HAL_SPI_MODULE_ENABLED */
+
+#ifdef HAL_TIM_MODULE_ENABLED
+ #include "stm32f4xx_hal_tim.h"
+#endif /* HAL_TIM_MODULE_ENABLED */
+
+#ifdef HAL_UART_MODULE_ENABLED
+ #include "stm32f4xx_hal_uart.h"
+#endif /* HAL_UART_MODULE_ENABLED */
+
+#ifdef HAL_USART_MODULE_ENABLED
+ #include "stm32f4xx_hal_usart.h"
+#endif /* HAL_USART_MODULE_ENABLED */
+
+#ifdef HAL_IRDA_MODULE_ENABLED
+ #include "stm32f4xx_hal_irda.h"
+#endif /* HAL_IRDA_MODULE_ENABLED */
+
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
+ #include "stm32f4xx_hal_smartcard.h"
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */
+
+#ifdef HAL_WWDG_MODULE_ENABLED
+ #include "stm32f4xx_hal_wwdg.h"
+#endif /* HAL_WWDG_MODULE_ENABLED */
+
+#ifdef HAL_PCD_MODULE_ENABLED
+ #include "stm32f4xx_hal_pcd.h"
+#endif /* HAL_PCD_MODULE_ENABLED */
+
+#ifdef HAL_HCD_MODULE_ENABLED
+ #include "stm32f4xx_hal_hcd.h"
+#endif /* HAL_HCD_MODULE_ENABLED */
+
+/* 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 */
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F4xx_HAL_CONF_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/stmhal/boards/PYBv10/mpconfigboard.h b/stmhal/boards/PYBv10/mpconfigboard.h
deleted file mode 100644
index f5ebe25cc4..0000000000
--- a/stmhal/boards/PYBv10/mpconfigboard.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#define PYBv10
-
-#define MICROPY_HW_BOARD_NAME "PYBv1.0"
-
-#define MICROPY_HW_HAS_SWITCH (1)
-#define MICROPY_HW_HAS_SDCARD (1)
-#define MICROPY_HW_HAS_MMA7660 (1)
-#define MICROPY_HW_HAS_LIS3DSH (0)
-#define MICROPY_HW_HAS_LCD (1)
-#define MICROPY_HW_HAS_WLAN (0)
-#define MICROPY_HW_ENABLE_RNG (1)
-#define MICROPY_HW_ENABLE_RTC (1)
-#define MICROPY_HW_ENABLE_TIMER (1)
-#define MICROPY_HW_ENABLE_SERVO (1)
-#define MICROPY_HW_ENABLE_DAC (1)
-
-// USRSW has no pullup or pulldown, and pressing the switch makes the input go low
-#define USRSW_PIN (pin_B3)
-#define USRSW_PULL (GPIO_PULLUP)
-#define USRSW_EXTI_MODE (GPIO_MODE_IT_FALLING)
-#define USRSW_PRESSED (0)
-
-/* LED */
-#define PYB_LED1 (pin_A13) // red
-#define PYB_LED2 (pin_A14) // green
-#define PYB_LED3 (pin_A15) // yellow
-#define PYB_LED4 (pin_B4) // blue
-
-#define PYB_OTYPE (GPIO_MODE_OUTPUT_PP)
-
-#define PYB_LED_ON(pin) (pin->gpio->BSRRL = pin->pin_mask)
-#define PYB_LED_OFF(pin) (pin->gpio->BSRRH = pin->pin_mask)
-
diff --git a/stmhal/boards/STM32F4DISC/mpconfigboard.h b/stmhal/boards/STM32F4DISC/mpconfigboard.h
index 2a58b27bdf..3bfdfbfb80 100644
--- a/stmhal/boards/STM32F4DISC/mpconfigboard.h
+++ b/stmhal/boards/STM32F4DISC/mpconfigboard.h
@@ -15,19 +15,16 @@
#define MICROPY_HW_ENABLE_DAC (0)
// USRSW is pulled low. Pressing the button makes the input go high.
-#define USRSW_PIN (pin_A0)
-#define USRSW_PULL (GPIO_NOPULL)
-#define USRSW_EXTI_MODE (GPIO_MODE_IT_RISING)
-#define USRSW_PRESSED (1)
-
-/* LED */
-#define PYB_LED1 (pin_D14) // red
-#define PYB_LED2 (pin_D12) // green
-#define PYB_LED3 (pin_D13) // orange
-#define PYB_LED4 (pin_D15) // blue
-
-#define PYB_OTYPE (GPIO_MODE_OUTPUT_PP)
-
-#define PYB_LED_ON(pin) (pin->gpio->BSRRL = pin->pin_mask)
-#define PYB_LED_OFF(pin) (pin->gpio->BSRRH = pin->pin_mask)
+#define MICROPY_HW_USRSW_PIN (pin_A0)
+#define MICROPY_HW_USRSW_PULL (GPIO_NOPULL)
+#define MICROPY_HW_USRSW_EXTI_MODE (GPIO_MODE_IT_RISING)
+#define MICROPY_HW_USRSW_PRESSED (1)
+// LEDs
+#define MICROPY_HW_LED1 (pin_D14) // red
+#define MICROPY_HW_LED2 (pin_D12) // green
+#define MICROPY_HW_LED3 (pin_D13) // orange
+#define MICROPY_HW_LED4 (pin_D15) // blue
+#define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP)
+#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRRL = pin->pin_mask)
+#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRRH = pin->pin_mask)
diff --git a/stmhal/diskio.c b/stmhal/diskio.c
index 4d6f998f55..0c67a23d68 100644
--- a/stmhal/diskio.c
+++ b/stmhal/diskio.c
@@ -41,12 +41,14 @@ DSTATUS disk_initialize (
storage_init();
return 0;
+#if MICROPY_HW_HAS_SDCARD
case PD_SDCARD:
if (!sdcard_power_on()) {
return STA_NODISK;
}
// TODO return STA_PROTECT if SD card is read only
return 0;
+#endif
}
return STA_NOINIT;
@@ -65,9 +67,11 @@ DSTATUS disk_status (
// flash is ready
return 0;
+#if MICROPY_HW_HAS_SDCARD
case PD_SDCARD:
// TODO return STA_PROTECT if SD card is read only
return 0;
+#endif
}
return STA_NOINIT;
@@ -93,11 +97,13 @@ DRESULT disk_read (
}
return RES_OK;
+#if MICROPY_HW_HAS_SDCARD
case PD_SDCARD:
if (!sdcard_read_blocks(buff, sector, count)) {
return RES_ERROR;
}
return RES_OK;
+#endif
}
return RES_PARERR;
@@ -124,11 +130,13 @@ DRESULT disk_write (
}
return RES_OK;
+#if MICROPY_HW_HAS_SDCARD
case PD_SDCARD:
if (!sdcard_write_blocks(buff, sector, count)) {
return RES_ERROR;
}
return RES_OK;
+#endif
}
return RES_PARERR;
@@ -160,6 +168,7 @@ DRESULT disk_ioctl (
}
break;
+#if MICROPY_HW_HAS_SDCARD
case PD_SDCARD:
switch (cmd) {
case CTRL_SYNC:
@@ -170,6 +179,7 @@ DRESULT disk_ioctl (
return RES_OK;
}
break;
+#endif
}
return RES_PARERR;
diff --git a/stmhal/lcd.c b/stmhal/lcd.c
index c5952fa48c..e2b9e22976 100644
--- a/stmhal/lcd.c
+++ b/stmhal/lcd.c
@@ -17,14 +17,14 @@
#include "font_petme128_8x8.h"
#include "lcd.h"
-#if defined(PYBOARD3)
+#if defined(PYBV3)
#define PYB_LCD_PORT (GPIOA)
#define PYB_LCD_CS1_PIN (GPIO_PIN_0)
#define PYB_LCD_RST_PIN (GPIO_PIN_1)
#define PYB_LCD_A0_PIN (GPIO_PIN_2)
#define PYB_LCD_SCL_PIN (GPIO_PIN_3)
#define PYB_LCD_SI_PIN (GPIO_PIN_4)
-#elif defined(PYBOARD4) || defined(PYBv10)
+#elif defined(PYBV4) || defined(PYBV10)
// X position
#define PYB_LCD_PORT (GPIOA)
#define PYB_LCD_CS1_PIN (GPIO_PIN_2) // X3
diff --git a/stmhal/led.c b/stmhal/led.c
index 5ff50fbb88..506e82e548 100644
--- a/stmhal/led.c
+++ b/stmhal/led.c
@@ -15,13 +15,13 @@
#include "build/pins.h"
static const pin_obj_t *gLed[] = {
- &PYB_LED1,
-#if defined(PYB_LED2)
- &PYB_LED2,
-#if defined(PYB_LED3)
- &PYB_LED3,
-#if defined(PYB_LED4)
- &PYB_LED4,
+ &MICROPY_HW_LED1,
+#if defined(MICROPY_HW_LED2)
+ &MICROPY_HW_LED2,
+#if defined(MICROPY_HW_LED3)
+ &MICROPY_HW_LED3,
+#if defined(MICROPY_HW_LED4)
+ &MICROPY_HW_LED4,
#endif
#endif
#endif
@@ -34,27 +34,27 @@ void led_init(void) {
/* Configure I/O speed, mode, output type and pull */
GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
- GPIO_InitStructure.Mode = PYB_OTYPE;
+ GPIO_InitStructure.Mode = MICROPY_HW_LED_OTYPE;
GPIO_InitStructure.Pull = GPIO_NOPULL;
/* Turn off LEDs and initialize */
for (int led = 0; led < NUM_LEDS; led++) {
- PYB_LED_OFF(gLed[led]);
+ MICROPY_HW_LED_OFF(gLed[led]);
GPIO_InitStructure.Pin = gLed[led]->pin_mask;
HAL_GPIO_Init(gLed[led]->gpio, &GPIO_InitStructure);
}
-#if defined(PYBOARD4) || defined(PYBv10)
+#if defined(PYBV4) || defined(PYBV10)
// LED4 (blue) is on PB4 which is TIM3_CH1
// we use PWM on this channel to fade the LED
// GPIO configuration
- GPIO_InitStructure.Pin = PYB_LED4.pin_mask;
+ GPIO_InitStructure.Pin = MICROPY_HW_LED4.pin_mask;
GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;
GPIO_InitStructure.Speed = GPIO_SPEED_FAST;
GPIO_InitStructure.Pull = GPIO_NOPULL;
GPIO_InitStructure.Alternate = GPIO_AF2_TIM3;
- HAL_GPIO_Init(PYB_LED4.gpio, &GPIO_InitStructure);
+ HAL_GPIO_Init(MICROPY_HW_LED4.gpio, &GPIO_InitStructure);
// PWM mode configuration
TIM_OC_InitTypeDef oc_init;
@@ -73,7 +73,7 @@ void led_state(pyb_led_t led, int state) {
if (led < 1 || led > NUM_LEDS) {
return;
}
-#if defined(PYBOARD4) || defined(PYBv10)
+#if defined(PYBV4) || defined(PYBV10)
if (led == 4) {
if (state) {
TIM3->CCR1 = 0xffff;
@@ -87,10 +87,10 @@ void led_state(pyb_led_t led, int state) {
//printf("led_state(%d,%d)\n", led, state);
if (state == 0) {
// turn LED off
- PYB_LED_OFF(led_pin);
+ MICROPY_HW_LED_OFF(led_pin);
} else {
// turn LED on
- PYB_LED_ON(led_pin);
+ MICROPY_HW_LED_ON(led_pin);
}
}
@@ -99,7 +99,7 @@ void led_toggle(pyb_led_t led) {
return;
}
-#if defined(PYBOARD4) || defined(PYBv10)
+#if defined(PYBV4) || defined(PYBV10)
if (led == 4) {
if (TIM3->CCR1 == 0) {
TIM3->CCR1 = 0xffff;
@@ -129,7 +129,7 @@ int led_get_intensity(pyb_led_t led) {
return 0;
}
-#if defined(PYBOARD4) || defined(PYBv10)
+#if defined(PYBV4) || defined(PYBV10)
if (led == 4) {
machine_uint_t i = TIM3->CCR1 * 255 / ((USBD_CDC_POLLING_INTERVAL*1000) - 1);
if (i > 255) {
@@ -153,7 +153,7 @@ int led_get_intensity(pyb_led_t led) {
}
void led_set_intensity(pyb_led_t led, machine_int_t intensity) {
-#if defined(PYBOARD4) || defined(PYBv10)
+#if defined(PYBV4) || defined(PYBV10)
if (led == 4) {
// set intensity using PWM pulse width
if (intensity < 0) {
diff --git a/stmhal/pin_map.c b/stmhal/pin_map.c
index c546231c80..a754d24a05 100644
--- a/stmhal/pin_map.c
+++ b/stmhal/pin_map.c
@@ -23,7 +23,7 @@
//
// CPU pins which correspond to the board pins are available
// as pyb.cpu.Name. For the CPU pins, the names are the port letter
-// followed by the pin number. On the PYBOARD4, pyb.Pin.board.X1 and
+// followed by the pin number. On the PYBV4, pyb.Pin.board.X1 and
// pyb.Pin.cpu.B6 are the same pin.
//
// You can also use strings:
diff --git a/stmhal/sdcard.c b/stmhal/sdcard.c
index 5620aef5b4..ae03c9f3fa 100644
--- a/stmhal/sdcard.c
+++ b/stmhal/sdcard.c
@@ -9,14 +9,12 @@
#include "map.h"
#include "runtime.h"
#include "sdcard.h"
+#include "pin.h"
+#include "build/pins.h"
-static SD_HandleTypeDef sd_handle;
+#if MICROPY_HW_HAS_SDCARD
-#define SDCARD_DETECT_GPIO_PORT (GPIOA)
-#define SDCARD_DETECT_GPIO_PIN (GPIO_PIN_8)
-#define SDCARD_DETECT_GPIO_PULL (GPIO_PULLUP)
-#define SDCARD_DETECT_GPIO_PRESENT (GPIO_PIN_RESET)
-#define __SDCARD_DETECT_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE()
+static SD_HandleTypeDef sd_handle;
void sdcard_init(void) {
GPIO_InitTypeDef GPIO_Init_Structure;
@@ -39,10 +37,10 @@ void sdcard_init(void) {
// configure the SD card detect pin
// we do this here so we can detect if the SD card is inserted before powering it on
GPIO_Init_Structure.Mode = GPIO_MODE_INPUT;
- GPIO_Init_Structure.Pull = SDCARD_DETECT_GPIO_PULL;
+ GPIO_Init_Structure.Pull = MICROPY_HW_SDCARD_DETECT_PULL;
GPIO_Init_Structure.Speed = GPIO_SPEED_HIGH;
- GPIO_Init_Structure.Pin = SDCARD_DETECT_GPIO_PIN;
- HAL_GPIO_Init(SDCARD_DETECT_GPIO_PORT, &GPIO_Init_Structure);
+ GPIO_Init_Structure.Pin = MICROPY_HW_SDCARD_DETECT_PIN.pin_mask;
+ HAL_GPIO_Init(MICROPY_HW_SDCARD_DETECT_PIN.gpio, &GPIO_Init_Structure);
}
void HAL_SD_MspInit(SD_HandleTypeDef *hsd) {
@@ -60,7 +58,7 @@ void HAL_SD_MspDeInit(SD_HandleTypeDef *hsd) {
}
bool sdcard_is_present(void) {
- return HAL_GPIO_ReadPin(SDCARD_DETECT_GPIO_PORT, SDCARD_DETECT_GPIO_PIN) == SDCARD_DETECT_GPIO_PRESENT;
+ return HAL_GPIO_ReadPin(MICROPY_HW_SDCARD_DETECT_PIN.gpio, MICROPY_HW_SDCARD_DETECT_PIN.pin_mask) == MICROPY_HW_SDCARD_DETECT_PRESENT;
}
bool sdcard_power_on(void) {
@@ -248,3 +246,5 @@ static const mp_obj_type_t sdcard_type = {
};
const mp_obj_base_t pyb_sdcard_obj = {&sdcard_type};
+
+#endif // MICROPY_HW_HAS_SDCARD
diff --git a/stmhal/usart.c b/stmhal/usart.c
index daf8a9e1fc..14539c597c 100644
--- a/stmhal/usart.c
+++ b/stmhal/usart.c
@@ -52,7 +52,7 @@ void usart_init(pyb_usart_obj_t *usart_obj, uint32_t baudrate) {
case PYB_USART_3:
USARTx = USART3;
-#if defined(PYBOARD3) || defined(PYBOARD4)
+#if defined(PYBV3) || defined(PYBV4)
GPIO_Port = GPIOB;
GPIO_AF_USARTx = GPIO_AF7_USART3;
GPIO_Pin = GPIO_PIN_10 | GPIO_PIN_11;
diff --git a/stmhal/usb.c b/stmhal/usb.c
index 3d795f1823..97ea2e1b41 100644
--- a/stmhal/usb.c
+++ b/stmhal/usb.c
@@ -31,11 +31,15 @@ void pyb_usb_dev_init(usb_device_mode_t mode, usb_storage_medium_t medium) {
USBD_Init(&hUSBDDevice, &VCP_Desc, 0);
USBD_RegisterClass(&hUSBDDevice, &USBD_CDC_MSC_HID);
USBD_CDC_RegisterInterface(&hUSBDDevice, (USBD_CDC_ItfTypeDef*)&USBD_CDC_fops);
+#if MICROPY_HW_HAS_SDCARD
if (medium == USB_STORAGE_MEDIUM_FLASH) {
USBD_MSC_RegisterStorage(&hUSBDDevice, (USBD_StorageTypeDef*)&USBD_FLASH_STORAGE_fops);
} else {
USBD_MSC_RegisterStorage(&hUSBDDevice, (USBD_StorageTypeDef*)&USBD_SDCARD_STORAGE_fops);
}
+#else
+ USBD_MSC_RegisterStorage(&hUSBDDevice, (USBD_StorageTypeDef*)&USBD_FLASH_STORAGE_fops);
+#endif
USBD_Start(&hUSBDDevice);
}
dev_is_enabled = 1;
diff --git a/stmhal/usbd_msc_storage.c b/stmhal/usbd_msc_storage.c
index 1b4545cd30..f3ecd023d1 100644
--- a/stmhal/usbd_msc_storage.c
+++ b/stmhal/usbd_msc_storage.c
@@ -27,7 +27,7 @@
******************************************************************************
*/
-#include "usbd_cdc_msc.h"
+#include "usbd_cdc_msc_hid.h"
#include "usbd_msc_storage.h"
#include "misc.h"
@@ -159,6 +159,8 @@ const USBD_StorageTypeDef USBD_FLASH_STORAGE_fops = {
/******************************************************************************/
// Callback functions for when the SD card is the mass storage device
+#if MICROPY_HW_HAS_SDCARD
+
static const int8_t SDCARD_STORAGE_Inquirydata[] = { // 36 bytes
// LUN 0
0x00,
@@ -318,3 +320,5 @@ const USBD_StorageTypeDef USBD_SDCARD_STORAGE_fops = {
SDCARD_STORAGE_GetMaxLun,
(int8_t *)SDCARD_STORAGE_Inquirydata,
};
+
+#endif // MICROPY_HW_HAS_SDCARD
diff --git a/stmhal/usrsw.c b/stmhal/usrsw.c
index 60032c4ecb..038fbf9efb 100644
--- a/stmhal/usrsw.c
+++ b/stmhal/usrsw.c
@@ -42,26 +42,26 @@ static MP_DEFINE_CONST_FUN_OBJ_1(switch_callback_obj, switch_callback);
// this function inits the switch GPIO so that it can be used
void switch_init0(void) {
GPIO_InitTypeDef init;
- init.Pin = USRSW_PIN.pin_mask;
+ init.Pin = MICROPY_HW_USRSW_PIN.pin_mask;
init.Mode = GPIO_MODE_INPUT;
- init.Pull = USRSW_PULL;
+ init.Pull = MICROPY_HW_USRSW_PULL;
init.Speed = GPIO_SPEED_FAST;
- HAL_GPIO_Init(USRSW_PIN.gpio, &init);
+ HAL_GPIO_Init(MICROPY_HW_USRSW_PIN.gpio, &init);
}
// this function inits the callback and EXTI function of the switch
void switch_init(void) {
switch_user_callback_obj = mp_const_none;
- exti_register((mp_obj_t)&USRSW_PIN,
- MP_OBJ_NEW_SMALL_INT(USRSW_EXTI_MODE),
- MP_OBJ_NEW_SMALL_INT(USRSW_PULL),
+ exti_register((mp_obj_t)&MICROPY_HW_USRSW_PIN,
+ MP_OBJ_NEW_SMALL_INT(MICROPY_HW_USRSW_EXTI_MODE),
+ MP_OBJ_NEW_SMALL_INT(MICROPY_HW_USRSW_PULL),
(mp_obj_t)&switch_callback_obj,
NULL);
}
int switch_get(void) {
- int val = ((USRSW_PIN.gpio->IDR & USRSW_PIN.pin_mask) != 0);
- return val == USRSW_PRESSED;
+ int val = ((MICROPY_HW_USRSW_PIN.gpio->IDR & MICROPY_HW_USRSW_PIN.pin_mask) != 0);
+ return val == MICROPY_HW_USRSW_PRESSED;
}
/******************************************************************************/