cancel
Showing results for 
Search instead for 
Did you mean: 

Where is the SPI configured in the uSD FatFS example for the F7 microcontrollers?

JWood
Associate II

I've been sucessfully using the SD card example in the CubeF7 files, but I can't understand where the SPI connections are set up, and if I was to choose SDIO instead, where would I do that?

It seems to just magically know I've connected it to the SPIA port on the nucleo board, without any of the lengthy initialisation you normally see in the main.c file.

Thanks!

This discussion is locked. Please start a new topic to ask your question.
1 REPLY 1

The NUCLEO / ADAFRUIT stuff is hidden in the BSP code

STM32Cube_FW_F7_V1.16.0\Drivers\BSP\STM32F7xx_Nucleo_144\stm32f7xx_nucleo_144.h

/*############################### SPI_A #######################################*/

#ifdef HAL_SPI_MODULE_ENABLED

#define NUCLEO_SPIx                   SPI1

#define NUCLEO_SPIx_CLK_ENABLE()            __HAL_RCC_SPI1_CLK_ENABLE()

#define NUCLEO_SPIx_SCK_AF               GPIO_AF5_SPI1

#define NUCLEO_SPIx_SCK_GPIO_PORT            GPIOA

#define NUCLEO_SPIx_SCK_PIN               GPIO_PIN_5

#define NUCLEO_SPIx_SCK_GPIO_CLK_ENABLE()        __HAL_RCC_GPIOA_CLK_ENABLE()

#define NUCLEO_SPIx_SCK_GPIO_CLK_DISABLE()       __HAL_RCC_GPIOA_CLK_DISABLE()

#define NUCLEO_SPIx_MISO_MOSI_AF            GPIO_AF5_SPI1

#define NUCLEO_SPIx_MISO_MOSI_GPIO_PORT         GPIOA

#define NUCLEO_SPIx_MISO_MOSI_GPIO_CLK_ENABLE()     __HAL_RCC_GPIOA_CLK_ENABLE()

#define NUCLEO_SPIx_MISO_MOSI_GPIO_CLK_DISABLE()    __HAL_RCC_GPIOA_CLK_DISABLE()

#define NUCLEO_SPIx_MISO_PIN              GPIO_PIN_6

#define NUCLEO_SPIx_MOSI_PIN              GPIO_PIN_7

...

/**

 * @brief SD Control Lines management

 */

#define SD_CS_LOW()    HAL_GPIO_WritePin(SD_CS_GPIO_PORT, SD_CS_PIN, GPIO_PIN_RESET)

#define SD_CS_HIGH()   HAL_GPIO_WritePin(SD_CS_GPIO_PORT, SD_CS_PIN, GPIO_PIN_SET)

...

/**

 * @brief SD Control Interface pins (shield D4)

 */

#define SD_CS_PIN                 GPIO_PIN_14

#define SD_CS_GPIO_PORT              GPIOF

#define SD_CS_GPIO_CLK_ENABLE()         __HAL_RCC_GPIOF_CLK_ENABLE()

#define SD_CS_GPIO_CLK_DISABLE()        __HAL_RCC_GPIOF_CLK_DISABLE()

Different example? Be specific..

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..