Prusa MINI Firmware overview
SPI_Exported_Functions_Group1
Collaboration diagram for SPI_Exported_Functions_Group1:

Functions

HAL_StatusTypeDef HAL_SPI_Init (SPI_HandleTypeDef *hspi)
 
HAL_StatusTypeDef HAL_SPI_DeInit (SPI_HandleTypeDef *hspi)
 
void HAL_SPI_MspInit (SPI_HandleTypeDef *hspi)
 SPI MSP Initialization This function configures the hardware resources used in this example. More...
 
void HAL_SPI_MspDeInit (SPI_HandleTypeDef *hspi)
 SPI MSP De-Initialization This function freeze the hardware resources used in this example. More...
 

Detailed Description

Function Documentation

◆ HAL_SPI_Init()

HAL_StatusTypeDef HAL_SPI_Init ( SPI_HandleTypeDef hspi)
Here is the caller graph for this function:

◆ HAL_SPI_DeInit()

HAL_StatusTypeDef HAL_SPI_DeInit ( SPI_HandleTypeDef hspi)
Here is the caller graph for this function:

◆ HAL_SPI_MspInit()

void HAL_SPI_MspInit ( SPI_HandleTypeDef hspi)

SPI MSP Initialization This function configures the hardware resources used in this example.

Parameters
hspiSPI handle pointer
Return values
None

SPI2 GPIO Configuration PC2 ---—> SPI2_MISO PC3 ---—> SPI2_MOSI PB10 ---—> SPI2_SCK

SPI3 GPIO Configuration PC10 ---—> SPI3_SCK PC11 ---—> SPI3_MISO PC12 ---—> SPI3_MOSI

252  {
253 
254  GPIO_InitTypeDef GPIO_InitStruct = { 0 };
255  if (hspi->Instance == SPI2) {
256  /* USER CODE BEGIN SPI2_MspInit 0 */
257 
258  /* USER CODE END SPI2_MspInit 0 */
259  /* Peripheral clock enable */
261 
264  /**SPI2 GPIO Configuration
265  PC2 ------> SPI2_MISO
266  PC3 ------> SPI2_MOSI
267  PB10 ------> SPI2_SCK
268  */
269  GPIO_InitStruct.Pin = GPIO_PIN_2 | GPIO_PIN_3;
270  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
271  GPIO_InitStruct.Pull = GPIO_NOPULL;
272  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
273  GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
274  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
275 
276  GPIO_InitStruct.Pin = GPIO_PIN_10;
277  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
278  GPIO_InitStruct.Pull = GPIO_NOPULL;
279  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
280  GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
281  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
282 
283  /* SPI2 DMA Init */
284  /* SPI2_TX Init */
285  hdma_spi2_tx.Instance = DMA1_Stream4;
295  if (HAL_DMA_Init(&hdma_spi2_tx) != HAL_OK) {
296  Error_Handler();
297  }
298 
299  __HAL_LINKDMA(hspi, hdmatx, hdma_spi2_tx);
300 
301  /* USER CODE BEGIN SPI2_MspInit 1 */
302 
303  /* USER CODE END SPI2_MspInit 1 */
304  } else if (hspi->Instance == SPI3) {
305  /* USER CODE BEGIN SPI3_MspInit 0 */
306 
307  /* USER CODE END SPI3_MspInit 0 */
308  /* Peripheral clock enable */
309  __HAL_RCC_SPI3_CLK_ENABLE();
310 
312  /**SPI3 GPIO Configuration
313  PC10 ------> SPI3_SCK
314  PC11 ------> SPI3_MISO
315  PC12 ------> SPI3_MOSI
316  */
317  GPIO_InitStruct.Pin = FLASH_SCK_Pin | FLASH_MISO_Pin | FLASH_MOSI_Pin;
318  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
319  GPIO_InitStruct.Pull = GPIO_NOPULL;
320  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
321  GPIO_InitStruct.Alternate = GPIO_AF6_SPI3;
322  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
323 
324  /* USER CODE BEGIN SPI3_MspInit 1 */
325 
326  /* USER CODE END SPI3_MspInit 1 */
327  }
328 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HAL_SPI_MspDeInit()

void HAL_SPI_MspDeInit ( SPI_HandleTypeDef hspi)

SPI MSP De-Initialization This function freeze the hardware resources used in this example.

Parameters
hspiSPI handle pointer
Return values
None

SPI2 GPIO Configuration PC2 ---—> SPI2_MISO PC3 ---—> SPI2_MOSI PB10 ---—> SPI2_SCK

SPI3 GPIO Configuration PC10 ---—> SPI3_SCK PC11 ---—> SPI3_MISO PC12 ---—> SPI3_MOSI

337  {
338 
339  if (hspi->Instance == SPI2) {
340  /* USER CODE BEGIN SPI2_MspDeInit 0 */
341 
342  /* USER CODE END SPI2_MspDeInit 0 */
343  /* Peripheral clock disable */
345 
346  /**SPI2 GPIO Configuration
347  PC2 ------> SPI2_MISO
348  PC3 ------> SPI2_MOSI
349  PB10 ------> SPI2_SCK
350  */
352 
354 
355  /* SPI2 DMA DeInit */
356  HAL_DMA_DeInit(hspi->hdmatx);
357  /* USER CODE BEGIN SPI2_MspDeInit 1 */
358 
359  /* USER CODE END SPI2_MspDeInit 1 */
360  } else if (hspi->Instance == SPI3) {
361  /* USER CODE BEGIN SPI3_MspDeInit 0 */
362 
363  /* USER CODE END SPI3_MspDeInit 0 */
364  /* Peripheral clock disable */
365  __HAL_RCC_SPI3_CLK_DISABLE();
366 
367  /**SPI3 GPIO Configuration
368  PC10 ------> SPI3_SCK
369  PC11 ------> SPI3_MISO
370  PC12 ------> SPI3_MOSI
371  */
373 
374  /* USER CODE BEGIN SPI3_MspDeInit 1 */
375 
376  /* USER CODE END SPI3_MspDeInit 1 */
377  }
378 }
Here is the call graph for this function:
Here is the caller graph for this function:
DMA_InitTypeDef::PeriphDataAlignment
uint32_t PeriphDataAlignment
Definition: stm32f4xx_hal_dma.h:80
GPIO_MODE_AF_PP
#define GPIO_MODE_AF_PP
Definition: stm32f4xx_hal_gpio.h:138
HAL_DMA_DeInit
HAL_StatusTypeDef HAL_DMA_DeInit(DMA_HandleTypeDef *hdma)
DMA_CHANNEL_0
#define DMA_CHANNEL_0
Definition: stm32f4xx_hal_dma.h:218
DMA_InitTypeDef::PeriphInc
uint32_t PeriphInc
Definition: stm32f4xx_hal_dma.h:74
DMA_InitTypeDef::FIFOMode
uint32_t FIFOMode
Definition: stm32f4xx_hal_dma.h:94
DMA_PRIORITY_MEDIUM
#define DMA_PRIORITY_MEDIUM
Definition: stm32f4xx_hal_dma.h:309
HAL_OK
Definition: stm32f4xx_hal_def.h:57
__DMA_HandleTypeDef::Instance
DMA_Stream_TypeDef * Instance
Definition: stm32f4xx_hal_dma.h:157
__SPI_HandleTypeDef::Instance
SPI_TypeDef * Instance
Definition: stm32f4xx_hal_spi.h:122
GPIO_InitTypeDef::Mode
uint32_t Mode
Definition: stm32f4xx_hal_gpio.h:68
__HAL_RCC_GPIOB_CLK_ENABLE
#define __HAL_RCC_GPIOB_CLK_ENABLE()
Definition: stm32f4xx_hal_rcc.h:409
GPIO_PIN_2
#define GPIO_PIN_2
Definition: stm32f4xx_hal_gpio.h:104
GPIO_InitTypeDef::Alternate
uint32_t Alternate
Definition: stm32f4xx_hal_gpio.h:77
GPIO_InitTypeDef::Pull
uint32_t Pull
Definition: stm32f4xx_hal_gpio.h:71
FLASH_MOSI_Pin
#define FLASH_MOSI_Pin
Definition: main.h:175
HAL_GPIO_DeInit
void HAL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin)
__DMA_HandleTypeDef::Init
DMA_InitTypeDef Init
Definition: stm32f4xx_hal_dma.h:159
DMA_InitTypeDef::Direction
uint32_t Direction
Definition: stm32f4xx_hal_dma.h:70
DMA_InitTypeDef::Priority
uint32_t Priority
Definition: stm32f4xx_hal_dma.h:91
GPIO_PIN_10
#define GPIO_PIN_10
Definition: stm32f4xx_hal_gpio.h:112
DMA_PINC_DISABLE
#define DMA_PINC_DISABLE
Definition: stm32f4xx_hal_dma.h:256
FLASH_MISO_Pin
#define FLASH_MISO_Pin
Definition: main.h:173
DMA_MINC_ENABLE
#define DMA_MINC_ENABLE
Definition: stm32f4xx_hal_dma.h:265
FLASH_SCK_Pin
#define FLASH_SCK_Pin
Definition: main.h:171
DMA_InitTypeDef::MemInc
uint32_t MemInc
Definition: stm32f4xx_hal_dma.h:77
__HAL_RCC_SPI2_CLK_ENABLE
#define __HAL_RCC_SPI2_CLK_ENABLE()
Definition: stm32f4xx_hal_rcc.h:500
GPIO_PIN_3
#define GPIO_PIN_3
Definition: stm32f4xx_hal_gpio.h:105
HAL_GPIO_Init
void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init)
DMA_InitTypeDef::Channel
uint32_t Channel
Definition: stm32f4xx_hal_dma.h:67
GPIO_NOPULL
#define GPIO_NOPULL
Definition: stm32f4xx_hal_gpio.h:170
GPIO_SPEED_FREQ_VERY_HIGH
#define GPIO_SPEED_FREQ_VERY_HIGH
Definition: stm32f4xx_hal_gpio.h:161
DMA_InitTypeDef::Mode
uint32_t Mode
Definition: stm32f4xx_hal_dma.h:86
DMA_MDATAALIGN_BYTE
#define DMA_MDATAALIGN_BYTE
Definition: stm32f4xx_hal_dma.h:286
DMA_FIFOMODE_DISABLE
#define DMA_FIFOMODE_DISABLE
Definition: stm32f4xx_hal_dma.h:320
__HAL_RCC_GPIOC_CLK_ENABLE
#define __HAL_RCC_GPIOC_CLK_ENABLE()
Definition: stm32f4xx_hal_rcc.h:416
Error_Handler
void Error_Handler(void)
This function is executed in case of error occurrence.
Definition: main.c:1057
hdma_spi2_tx
DMA_HandleTypeDef hdma_spi2_tx
Definition: main.c:83
GPIO_InitTypeDef::Pin
uint32_t Pin
Definition: stm32f4xx_hal_gpio.h:65
GPIO_InitTypeDef::Speed
uint32_t Speed
Definition: stm32f4xx_hal_gpio.h:74
DMA_NORMAL
#define DMA_NORMAL
Definition: stm32f4xx_hal_dma.h:297
DMA_PDATAALIGN_BYTE
#define DMA_PDATAALIGN_BYTE
Definition: stm32f4xx_hal_dma.h:275
__SPI_HandleTypeDef::hdmatx
DMA_HandleTypeDef * hdmatx
Definition: stm32f4xx_hal_spi.h:142
DMA_InitTypeDef::MemDataAlignment
uint32_t MemDataAlignment
Definition: stm32f4xx_hal_dma.h:83
__HAL_LINKDMA
#define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__)
Definition: stm32f4xx_hal_def.h:81
DMA_MEMORY_TO_PERIPH
#define DMA_MEMORY_TO_PERIPH
Definition: stm32f4xx_hal_dma.h:245
HAL_DMA_Init
HAL_StatusTypeDef HAL_DMA_Init(DMA_HandleTypeDef *hdma)
__HAL_RCC_SPI2_CLK_DISABLE
#define __HAL_RCC_SPI2_CLK_DISABLE()
Definition: stm32f4xx_hal_rcc.h:538
GPIO_InitTypeDef
GPIO Init structure definition.
Definition: stm32f4xx_hal_gpio.h:63