Prusa MINI Firmware overview
UART_Exported_Functions_Group1
Collaboration diagram for UART_Exported_Functions_Group1:

Functions

HAL_StatusTypeDef HAL_UART_Init (UART_HandleTypeDef *huart)
 
HAL_StatusTypeDef HAL_HalfDuplex_Init (UART_HandleTypeDef *huart)
 
HAL_StatusTypeDef HAL_LIN_Init (UART_HandleTypeDef *huart, uint32_t BreakDetectLength)
 
HAL_StatusTypeDef HAL_MultiProcessor_Init (UART_HandleTypeDef *huart, uint8_t Address, uint32_t WakeUpMethod)
 
HAL_StatusTypeDef HAL_UART_DeInit (UART_HandleTypeDef *huart)
 
void HAL_UART_MspInit (UART_HandleTypeDef *huart)
 UART MSP Initialization This function configures the hardware resources used in this example. More...
 
void HAL_UART_MspDeInit (UART_HandleTypeDef *huart)
 UART MSP De-Initialization This function freeze the hardware resources used in this example. More...
 

Detailed Description

Function Documentation

◆ HAL_UART_Init()

HAL_StatusTypeDef HAL_UART_Init ( UART_HandleTypeDef huart)
Here is the caller graph for this function:

◆ HAL_HalfDuplex_Init()

HAL_StatusTypeDef HAL_HalfDuplex_Init ( UART_HandleTypeDef huart)

◆ HAL_LIN_Init()

HAL_StatusTypeDef HAL_LIN_Init ( UART_HandleTypeDef huart,
uint32_t  BreakDetectLength 
)

◆ HAL_MultiProcessor_Init()

HAL_StatusTypeDef HAL_MultiProcessor_Init ( UART_HandleTypeDef huart,
uint8_t  Address,
uint32_t  WakeUpMethod 
)

◆ HAL_UART_DeInit()

HAL_StatusTypeDef HAL_UART_DeInit ( UART_HandleTypeDef huart)

◆ HAL_UART_MspInit()

void HAL_UART_MspInit ( UART_HandleTypeDef huart)

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

Parameters
huartUART handle pointer
Return values
None

USART1 GPIO Configuration PB6 ---—> USART1_TX PB7 ---—> USART1_RX

USART2 GPIO Configuration PD5 ---—> USART2_TX PD6 ---—> USART2_RX

USART6 GPIO Configuration PC6 ---—> USART6_TX PC7 ---—> USART6_RX

550  {
551 
552  GPIO_InitTypeDef GPIO_InitStruct = { 0 };
553  if (huart->Instance == USART1) {
554  /* USER CODE BEGIN USART1_MspInit 0 */
555 
556  /* USER CODE END USART1_MspInit 0 */
557  /* Peripheral clock enable */
559 
561  /**USART1 GPIO Configuration
562  PB6 ------> USART1_TX
563  PB7 ------> USART1_RX
564  */
565  GPIO_InitStruct.Pin = TX1_Pin | RX1_Pin;
566  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
567  GPIO_InitStruct.Pull = GPIO_PULLUP;
568  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
569  GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
570  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
571 
572  /* USART1 DMA Init */
573  /* USART1_RX Init */
574  hdma_usart1_rx.Instance = DMA2_Stream2;
585  Error_Handler();
586  }
587 
588  __HAL_LINKDMA(huart, hdmarx, hdma_usart1_rx);
589 
590  /* USER CODE BEGIN USART1_MspInit 1 */
591 
592  /* USER CODE END USART1_MspInit 1 */
593  } else if (huart->Instance == USART2) {
594  /* USER CODE BEGIN USART2_MspInit 0 */
595 
596  /* USER CODE END USART2_MspInit 0 */
597  /* Peripheral clock enable */
599 
600  __HAL_RCC_GPIOD_CLK_ENABLE();
601  /**USART2 GPIO Configuration
602  PD5 ------> USART2_TX
603  PD6 ------> USART2_RX
604  */
605  GPIO_InitStruct.Pin = GPIO_PIN_5 | GPIO_PIN_6;
606  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
607  GPIO_InitStruct.Pull = GPIO_PULLUP;
608  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
609  GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
610  HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
611 
612  /* USART2 DMA Init */
613  /* USART2_RX Init */
614  hdma_usart2_rx.Instance = DMA1_Stream5;
625  Error_Handler();
626  }
627 
628  __HAL_LINKDMA(huart, hdmarx, hdma_usart2_rx);
629 
630  /* USER CODE BEGIN USART2_MspInit 1 */
631 
632  /* USER CODE END USART2_MspInit 1 */
633  } else if (huart->Instance == USART6) {
634  /* USER CODE BEGIN USART6_MspInit 0 */
635 
636  /* USER CODE END USART6_MspInit 0 */
637  /* Peripheral clock enable */
639 
641  /**USART6 GPIO Configuration
642  PC6 ------> USART6_TX
643  PC7 ------> USART6_RX
644  */
645  GPIO_InitStruct.Pin = ESP_TX_Pin | ESP_RX_Pin;
646  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
647  GPIO_InitStruct.Pull = GPIO_PULLUP;
648  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
649  GPIO_InitStruct.Alternate = GPIO_AF8_USART6;
650  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
651 
652  /* USART6 DMA Init */
653  /* USART6_RX Init */
654  hdma_usart6_rx.Instance = DMA2_Stream1;
665  Error_Handler();
666  }
667 
668  __HAL_LINKDMA(huart, hdmarx, hdma_usart6_rx);
669 
670  /* USER CODE BEGIN USART6_MspInit 1 */
671 
672  /* USER CODE END USART6_MspInit 1 */
673  }
674 }
Here is the call graph for this function:

◆ HAL_UART_MspDeInit()

void HAL_UART_MspDeInit ( UART_HandleTypeDef huart)

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

Parameters
huartUART handle pointer
Return values
None

USART1 GPIO Configuration PB6 ---—> USART1_TX PB7 ---—> USART1_RX

USART2 GPIO Configuration PD5 ---—> USART2_TX PD6 ---—> USART2_RX

USART6 GPIO Configuration PC6 ---—> USART6_TX PC7 ---—> USART6_RX

683  {
684 
685  if (huart->Instance == USART1) {
686  /* USER CODE BEGIN USART1_MspDeInit 0 */
687 
688  /* USER CODE END USART1_MspDeInit 0 */
689  /* Peripheral clock disable */
691 
692  /**USART1 GPIO Configuration
693  PB6 ------> USART1_TX
694  PB7 ------> USART1_RX
695  */
696  HAL_GPIO_DeInit(GPIOB, TX1_Pin | RX1_Pin);
697 
698  /* USART1 DMA DeInit */
699  HAL_DMA_DeInit(huart->hdmarx);
700  /* USER CODE BEGIN USART1_MspDeInit 1 */
701 
702  /* USER CODE END USART1_MspDeInit 1 */
703  } else if (huart->Instance == USART2) {
704  /* USER CODE BEGIN USART2_MspDeInit 0 */
705 
706  /* USER CODE END USART2_MspDeInit 0 */
707  /* Peripheral clock disable */
709 
710  /**USART2 GPIO Configuration
711  PD5 ------> USART2_TX
712  PD6 ------> USART2_RX
713  */
715 
716  /* USART2 DMA DeInit */
717  HAL_DMA_DeInit(huart->hdmarx);
718  /* USER CODE BEGIN USART2_MspDeInit 1 */
719 
720  /* USER CODE END USART2_MspDeInit 1 */
721  } else if (huart->Instance == USART6) {
722  /* USER CODE BEGIN USART6_MspDeInit 0 */
723 
724  /* USER CODE END USART6_MspDeInit 0 */
725  /* Peripheral clock disable */
727 
728  /**USART6 GPIO Configuration
729  PC6 ------> USART6_TX
730  PC7 ------> USART6_RX
731  */
733 
734  /* USART6 DMA DeInit */
735  HAL_DMA_DeInit(huart->hdmarx);
736  /* USER CODE BEGIN USART6_MspDeInit 1 */
737 
738  /* USER CODE END USART6_MspDeInit 1 */
739  }
740 }
Here is the call graph for this function:
DMA_InitTypeDef::PeriphDataAlignment
uint32_t PeriphDataAlignment
Definition: stm32f4xx_hal_dma.h:80
GPIO_PIN_6
#define GPIO_PIN_6
Definition: stm32f4xx_hal_gpio.h:108
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_InitTypeDef::PeriphInc
uint32_t PeriphInc
Definition: stm32f4xx_hal_dma.h:74
__HAL_RCC_USART6_CLK_DISABLE
#define __HAL_RCC_USART6_CLK_DISABLE()
Definition: stm32f4xx_hal_rcc.h:639
DMA_InitTypeDef::FIFOMode
uint32_t FIFOMode
Definition: stm32f4xx_hal_dma.h:94
HAL_OK
Definition: stm32f4xx_hal_def.h:57
__DMA_HandleTypeDef::Instance
DMA_Stream_TypeDef * Instance
Definition: stm32f4xx_hal_dma.h:157
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_InitTypeDef::Alternate
uint32_t Alternate
Definition: stm32f4xx_hal_gpio.h:77
GPIO_InitTypeDef::Pull
uint32_t Pull
Definition: stm32f4xx_hal_gpio.h:71
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
hdma_usart2_rx
DMA_HandleTypeDef hdma_usart2_rx
Definition: main.c:94
DMA_InitTypeDef::Direction
uint32_t Direction
Definition: stm32f4xx_hal_dma.h:70
DMA_InitTypeDef::Priority
uint32_t Priority
Definition: stm32f4xx_hal_dma.h:91
DMA_PINC_DISABLE
#define DMA_PINC_DISABLE
Definition: stm32f4xx_hal_dma.h:256
TX1_Pin
#define TX1_Pin
Definition: main.h:193
GPIO_PULLUP
#define GPIO_PULLUP
Definition: stm32f4xx_hal_gpio.h:171
hdma_usart6_rx
DMA_HandleTypeDef hdma_usart6_rx
Definition: main.c:95
DMA_MINC_ENABLE
#define DMA_MINC_ENABLE
Definition: stm32f4xx_hal_dma.h:265
DMA_InitTypeDef::MemInc
uint32_t MemInc
Definition: stm32f4xx_hal_dma.h:77
__HAL_RCC_USART6_CLK_ENABLE
#define __HAL_RCC_USART6_CLK_ENABLE()
Definition: stm32f4xx_hal_rcc.h:594
DMA_CIRCULAR
#define DMA_CIRCULAR
Definition: stm32f4xx_hal_dma.h:298
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
UART_HandleTypeDef::Instance
USART_TypeDef * Instance
Definition: stm32f4xx_hal_uart.h:160
RX1_Pin
#define RX1_Pin
Definition: main.h:195
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
ESP_RX_Pin
#define ESP_RX_Pin
Definition: main.h:153
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
DMA_CHANNEL_5
#define DMA_CHANNEL_5
Definition: stm32f4xx_hal_dma.h:223
__HAL_RCC_USART1_CLK_ENABLE
#define __HAL_RCC_USART1_CLK_ENABLE()
Definition: stm32f4xx_hal_rcc.h:587
__HAL_RCC_GPIOC_CLK_ENABLE
#define __HAL_RCC_GPIOC_CLK_ENABLE()
Definition: stm32f4xx_hal_rcc.h:416
GPIO_PIN_5
#define GPIO_PIN_5
Definition: stm32f4xx_hal_gpio.h:107
Error_Handler
void Error_Handler(void)
This function is executed in case of error occurrence.
Definition: main.c:1057
DMA_PERIPH_TO_MEMORY
#define DMA_PERIPH_TO_MEMORY
Definition: stm32f4xx_hal_dma.h:244
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_PRIORITY_LOW
#define DMA_PRIORITY_LOW
Definition: stm32f4xx_hal_dma.h:308
ESP_TX_Pin
#define ESP_TX_Pin
Definition: main.h:151
__HAL_RCC_USART2_CLK_DISABLE
#define __HAL_RCC_USART2_CLK_DISABLE()
Definition: stm32f4xx_hal_rcc.h:539
DMA_NORMAL
#define DMA_NORMAL
Definition: stm32f4xx_hal_dma.h:297
DMA_PDATAALIGN_BYTE
#define DMA_PDATAALIGN_BYTE
Definition: stm32f4xx_hal_dma.h:275
hdma_usart1_rx
DMA_HandleTypeDef hdma_usart1_rx
Definition: main.c:93
DMA_CHANNEL_4
#define DMA_CHANNEL_4
Definition: stm32f4xx_hal_dma.h:222
DMA_InitTypeDef::MemDataAlignment
uint32_t MemDataAlignment
Definition: stm32f4xx_hal_dma.h:83
__HAL_RCC_USART2_CLK_ENABLE
#define __HAL_RCC_USART2_CLK_ENABLE()
Definition: stm32f4xx_hal_rcc.h:507
__HAL_LINKDMA
#define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__)
Definition: stm32f4xx_hal_def.h:81
UART_HandleTypeDef::hdmarx
DMA_HandleTypeDef * hdmarx
Definition: stm32f4xx_hal_uart.h:178
HAL_DMA_Init
HAL_StatusTypeDef HAL_DMA_Init(DMA_HandleTypeDef *hdma)
__HAL_RCC_USART1_CLK_DISABLE
#define __HAL_RCC_USART1_CLK_DISABLE()
Definition: stm32f4xx_hal_rcc.h:638
GPIO_InitTypeDef
GPIO Init structure definition.
Definition: stm32f4xx_hal_gpio.h:63