STM32Cube  Version 2.0
Create Projects for STM32F2 Series with STM32Cube HAL and STM32CubeMX
 All Files Pages
Setup CMSIS Driver

CMSIS-Driver provide generic peripheral interfaces for middleware and application code. The CMSIS-Driver cooperates with the STM32Cube HAL.

In MDK you should select the CMSIS-Driver in the Manage Run-Time Environment window.

select_cmsis_driver.png

You should configure the parameters for these CMSIS-Driver in STM32CubeMX as described below. Once you use Generate Code in STM32CubeMX, the relevant STM32Cube HAL components are added to the MDK project. Refer to Setup STM32Cube Framework - STM32CubeMX for more information about the overall process.

Configuration with STM32CubeMX

For each CMSIS-Driver the setup with STM32CubeMX is explained in the pages below.

GPIO Pin Configuration - User Label

Some CMSIS-Driver have additional GPIO pins that are not covered by the underlying peripheral. The following User Labels assign GPIO pins to these CMSIS-Drivers.

User Label CMSIS-Driver Description
MemoryCard_CD MCI Memory Card: Card Detect Pin
MemoryCard_WP MCI Memory Card: Write Protect Pin
USB_OTG_FS_VBUS_Power USBH_FS Full-speed USB Host: VBUS Power Pin
USB_OTG_FS_Overcurrent USBH_FS Full-speed USB Host: Overcurrent Pin
USB_OTG_HS_VBUS_Power USBH_HS High-speed USB Host: VBUS Power Pin
USB_OTG_HS_Overcurrent USBH_HS High-speed USB Host: Overcurrent Pin
Note
Do not use the User Label names above for pins that are not related to these CMSIS-Driver.

MX_Device.h Configuration File

STM32CubeMX generates for the configuration of the CMSIS-Driver the file MX_Device.h. The file MX_Device.h contains sections for every peripheral that is enabled in the STM32CubeMX configuration. The #define symbols have the same names as in the classic configuration file RTE_Device.h and are used by the CMSIS-Driver when the component Device:STM32Cube Framework (API):STM32CubeMX is selected in the RTE.

Example:

/*-------------------------------- I2C1 --------------------------------*/
#define MX_I2C1 1
/* GPIO Configuration */
/* Pin PB8 */
#define MX_I2C1_SCL_GPIO_Speed GPIO_SPEED_HIGH
#define MX_I2C1_SCL_Pin PB8
#define MX_I2C1_SCL_GPIOx GPIOB
#define MX_I2C1_SCL_GPIO_PuPdOD GPIO_PULLUP
#define MX_I2C1_SCL_GPIO_Pin GPIO_PIN_8
#define MX_I2C1_SCL_GPIO_AF GPIO_AF4_I2C1
#define MX_I2C1_SCL_GPIO_Mode GPIO_MODE_AF_OD
/* Pin PB9 */
#define MX_I2C1_SDA_GPIO_Speed GPIO_SPEED_HIGH
#define MX_I2C1_SDA_Pin PB9
#define MX_I2C1_SDA_GPIOx GPIOB
#define MX_I2C1_SDA_GPIO_PuPdOD GPIO_PULLUP
#define MX_I2C1_SDA_GPIO_Pin GPIO_PIN_9
#define MX_I2C1_SDA_GPIO_AF GPIO_AF4_I2C1
#define MX_I2C1_SDA_GPIO_Mode GPIO_MODE_AF_OD