/** * @brief SPI MSP Init. * @param hspi: SPI handle * @retval None */ static void SPIx_MspInit(void) { GPIO_InitTypeDef GPIO_InitStructure; /* Enable the SPI peripheral */ DISCOVERY_SPIx_CLK_ENABLE(); /* Enable SCK, MOSI and MISO GPIO clocks */ DISCOVERY_SPIx_GPIO_CLK_ENABLE(); /* SPI SCK, MOSI, MISO pin configuration */ GPIO_InitStructure.Pin = (DISCOVERY_SPIx_SCK_PIN | DISCOVERY_SPIx_MISO_PIN | DISCOVERY_SPIx_MOSI_PIN); GPIO_InitStructure.Mode = GPIO_MODE_AF_PP; GPIO_InitStructure.Pull = GPIO_PULLDOWN; GPIO_InitStructure.Speed = GPIO_SPEED_MEDIUM; GPIO_InitStructure.Alternate = DISCOVERY_SPIx_AF; HAL_GPIO_Init(DISCOVERY_SPIx_GPIO_PORT, &GPIO_InitStructure); }
/** * @brief SPI MSP Init. * @param hspi: SPI handle */ static void SPIx_MspInit(SPI_HandleTypeDef *hspi) { GPIO_InitTypeDef GPIO_InitStructure; /* Enable SPIx clock */ DISCOVERY_SPIx_CLK_ENABLE(); /* Enable DISCOVERY_SPI GPIO clock */ DISCOVERY_SPIx_GPIO_CLK_ENABLE(); /* configure SPI SCK, MOSI and MISO */ GPIO_InitStructure.Pin = (DISCOVERY_SPIx_SCK_PIN | DISCOVERY_SPIx_MOSI_PIN | DISCOVERY_SPIx_MISO_PIN); GPIO_InitStructure.Mode = GPIO_MODE_AF_PP; GPIO_InitStructure.Pull = GPIO_PULLDOWN; GPIO_InitStructure.Speed = GPIO_SPEED_MEDIUM; GPIO_InitStructure.Alternate = DISCOVERY_SPIx_AF; HAL_GPIO_Init(DISCOVERY_SPIx_GPIO_PORT, &GPIO_InitStructure); }
/** * @brief SPI MSP Init * @param hspi: SPI handle * @retval None */ static void SPIx_MspInit(SPI_HandleTypeDef *hspi) { GPIO_InitTypeDef GPIO_InitStructure; (void) hspi; /* Enable SPI1 clock */ DISCOVERY_SPIx_CLK_ENABLE(); /* enable SPI1 gpio clock */ DISCOVERY_SPIx_GPIO_CLK_ENABLE(); /* configure SPI1 SCK, MOSI and MISO */ GPIO_InitStructure.Pin = (DISCOVERY_SPIx_SCK_PIN | DISCOVERY_SPIx_MOSI_PIN | DISCOVERY_SPIx_MISO_PIN); GPIO_InitStructure.Mode = GPIO_MODE_AF_PP; GPIO_InitStructure.Pull = GPIO_NOPULL; /* or GPIO_PULLDOWN */ GPIO_InitStructure.Speed = GPIO_SPEED_HIGH; GPIO_InitStructure.Alternate = DISCOVERY_SPIx_AF; HAL_GPIO_Init(DISCOVERY_SPIx_GPIO_PORT, &GPIO_InitStructure); }