2015-09-09 05:17 AM
When using CubeMX to generate project (e.g. for SW4STM32), the code for SD Card looks like this:
void MX_SDIO_SD_Init(void){ hsd.Instance = SDIO; hsd.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING; hsd.Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE; hsd.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE; hsd.Init.BusWide = SDIO_BUS_WIDE_1B; hsd.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE; hsd.Init.ClockDiv = 4; HAL_SD_Init(&hsd, &SDCardInfo); HAL_SD_WideBusOperation_Config(&hsd, SDIO_BUS_WIDE_4B);}The user has no possibility to add own error detection code, as there is no use section. My suggestion is to return the status type like this:HAL_SD_ErrorTypedef MX_SDIO_SD_Init(void){ HAL_SD_ErrorTypedef err = SD_OK; hsd.Instance = SDIO; hsd.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING; hsd.Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE; hsd.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE; hsd.Init.BusWide = SDIO_BUS_WIDE_1B; hsd.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE; hsd.Init.ClockDiv = 4; err = HAL_SD_Init(&hsd, &SDCardInfo); if(err != SD_OK) { return err; } err = HAL_SD_WideBusOperation_Config(&hsd, SDIO_BUS_WIDE_4B); return err;}- Robert #improvement #hal #cubemx2015-09-11 08:34 AM
Hi hartung.robert,
Could you precise the STM32CubeMx version and the product you are using? -Shahrzad-2015-10-12 05:51 AM
Hi shahrzad,
I am using: STM32CubeMX Version 4.1.0, STM32Cube V1.0I am using an STM32F2 processor.- Robert2015-10-12 10:16 AM
Hi hartung.robert,
In main.c file, there is an emplacement for user code directly after the call of ''MX_SDIO_SD_Init(void)'' function.I think that you can add your code within it. The behavior is what you expect. -Shahrzad-