void spi_free(spi_t *obj) { // Reset SPI and disable clock switch(obj->spi.module) { case 0: __SPI1_FORCE_RESET(); __SPI1_RELEASE_RESET(); __SPI1_CLK_DISABLE(); break; case 1: __SPI2_FORCE_RESET(); __SPI2_RELEASE_RESET(); __SPI2_CLK_DISABLE(); break; case 2: __SPI3_FORCE_RESET(); __SPI3_RELEASE_RESET(); __SPI3_CLK_DISABLE(); break; #if MODULES_SIZE_SPI > 3 case 3: __SPI4_FORCE_RESET(); __SPI4_RELEASE_RESET(); __SPI4_CLK_DISABLE(); break; #endif #if MODULES_SIZE_SPI > 4 case 4: __SPI5_FORCE_RESET(); __SPI5_RELEASE_RESET(); __SPI5_CLK_DISABLE(); break; #endif #if MODULES_SIZE_SPI > 5 case 5: __SPI6_FORCE_RESET(); __SPI6_RELEASE_RESET(); __SPI6_CLK_DISABLE(); break; #endif default: break; } // Configure GPIOs pin_function(obj->spi.pin_miso, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0)); pin_function(obj->spi.pin_mosi, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0)); pin_function(obj->spi.pin_sclk, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0)); DEBUG_PRINTF("SPI%u: Free\n", obj->spi.module+1); }
void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) { if(hspi->Instance==SPI5) { /* USER CODE BEGIN SPI5_MspDeInit 0 */ /* USER CODE END SPI5_MspDeInit 0 */ /* Peripheral clock disable */ __SPI5_CLK_DISABLE(); /**SPI5 GPIO Configuration PF7 ------> SPI5_SCK PF8 ------> SPI5_MISO PF9 ------> SPI5_MOSI */ HAL_GPIO_DeInit(GPIOF, GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9); /* USER CODE BEGIN SPI5_MspDeInit 1 */ /* USER CODE END SPI5_MspDeInit 1 */ } }
void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) { if(hspi->Instance==SPI1) { /* USER CODE BEGIN SPI1_MspDeInit 0 */ /* USER CODE END SPI1_MspDeInit 0 */ /* Peripheral clock disable */ __SPI1_CLK_DISABLE(); /**SPI1 GPIO Configuration PA5 ------> SPI1_SCK PB4 ------> SPI1_MISO PB5 ------> SPI1_MOSI */ HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5); HAL_GPIO_DeInit(GPIOB, GPIO_PIN_4|GPIO_PIN_5); /* USER CODE BEGIN SPI1_MspDeInit 1 */ /* USER CODE END SPI1_MspDeInit 1 */ } else if(hspi->Instance==SPI4) { /* USER CODE BEGIN SPI4_MspDeInit 0 */ /* USER CODE END SPI4_MspDeInit 0 */ /* Peripheral clock disable */ __SPI4_CLK_DISABLE(); /**SPI4 GPIO Configuration PE2 ------> SPI4_SCK PE13 ------> SPI4_MISO PE14 ------> SPI4_MOSI */ HAL_GPIO_DeInit(GPIOE, GPIO_PIN_2|GPIO_PIN_13|GPIO_PIN_14); /* USER CODE BEGIN SPI4_MspDeInit 1 */ /* USER CODE END SPI4_MspDeInit 1 */ } else if(hspi->Instance==SPI5) { /* USER CODE BEGIN SPI5_MspDeInit 0 */ /* USER CODE END SPI5_MspDeInit 0 */ /* Peripheral clock disable */ __SPI5_CLK_DISABLE(); /**SPI5 GPIO Configuration PF7 ------> SPI5_SCK PF8 ------> SPI5_MISO PF9 ------> SPI5_MOSI */ HAL_GPIO_DeInit(GPIOF, GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9); /* USER CODE BEGIN SPI5_MspDeInit 1 */ /* USER CODE END SPI5_MspDeInit 1 */ } }