Prusa MINI Firmware overview
|
Go to the documentation of this file.
37 #ifndef __STM32F4xx_HAL_UART_H
38 #define __STM32F4xx_HAL_UART_H
205 #define HAL_UART_ERROR_NONE 0x00000000U
206 #define HAL_UART_ERROR_PE 0x00000001U
207 #define HAL_UART_ERROR_NE 0x00000002U
208 #define HAL_UART_ERROR_FE 0x00000004U
209 #define HAL_UART_ERROR_ORE 0x00000008U
210 #define HAL_UART_ERROR_DMA 0x00000010U
218 #define UART_WORDLENGTH_8B 0x00000000U
219 #define UART_WORDLENGTH_9B ((uint32_t)USART_CR1_M)
227 #define UART_STOPBITS_1 0x00000000U
228 #define UART_STOPBITS_2 ((uint32_t)USART_CR2_STOP_1)
236 #define UART_PARITY_NONE 0x00000000U
237 #define UART_PARITY_EVEN ((uint32_t)USART_CR1_PCE)
238 #define UART_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS))
246 #define UART_HWCONTROL_NONE 0x00000000U
247 #define UART_HWCONTROL_RTS ((uint32_t)USART_CR3_RTSE)
248 #define UART_HWCONTROL_CTS ((uint32_t)USART_CR3_CTSE)
249 #define UART_HWCONTROL_RTS_CTS ((uint32_t)(USART_CR3_RTSE | USART_CR3_CTSE))
257 #define UART_MODE_RX ((uint32_t)USART_CR1_RE)
258 #define UART_MODE_TX ((uint32_t)USART_CR1_TE)
259 #define UART_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE))
267 #define UART_STATE_DISABLE 0x00000000U
268 #define UART_STATE_ENABLE ((uint32_t)USART_CR1_UE)
276 #define UART_OVERSAMPLING_16 0x00000000U
277 #define UART_OVERSAMPLING_8 ((uint32_t)USART_CR1_OVER8)
285 #define UART_LINBREAKDETECTLENGTH_10B 0x00000000U
286 #define UART_LINBREAKDETECTLENGTH_11B 0x00000020U
294 #define UART_WAKEUPMETHOD_IDLELINE 0x00000000U
295 #define UART_WAKEUPMETHOD_ADDRESSMARK 0x00000800U
305 #define UART_FLAG_CTS ((uint32_t)USART_SR_CTS)
306 #define UART_FLAG_LBD ((uint32_t)USART_SR_LBD)
307 #define UART_FLAG_TXE ((uint32_t)USART_SR_TXE)
308 #define UART_FLAG_TC ((uint32_t)USART_SR_TC)
309 #define UART_FLAG_RXNE ((uint32_t)USART_SR_RXNE)
310 #define UART_FLAG_IDLE ((uint32_t)USART_SR_IDLE)
311 #define UART_FLAG_ORE ((uint32_t)USART_SR_ORE)
312 #define UART_FLAG_NE ((uint32_t)USART_SR_NE)
313 #define UART_FLAG_FE ((uint32_t)USART_SR_FE)
314 #define UART_FLAG_PE ((uint32_t)USART_SR_PE)
330 #define UART_IT_PE ((uint32_t)(UART_CR1_REG_INDEX << 28U | USART_CR1_PEIE))
331 #define UART_IT_TXE ((uint32_t)(UART_CR1_REG_INDEX << 28U | USART_CR1_TXEIE))
332 #define UART_IT_TC ((uint32_t)(UART_CR1_REG_INDEX << 28U | USART_CR1_TCIE))
333 #define UART_IT_RXNE ((uint32_t)(UART_CR1_REG_INDEX << 28U | USART_CR1_RXNEIE))
334 #define UART_IT_IDLE ((uint32_t)(UART_CR1_REG_INDEX << 28U | USART_CR1_IDLEIE))
336 #define UART_IT_LBD ((uint32_t)(UART_CR2_REG_INDEX << 28U | USART_CR2_LBDIE))
338 #define UART_IT_CTS ((uint32_t)(UART_CR3_REG_INDEX << 28U | USART_CR3_CTSIE))
339 #define UART_IT_ERR ((uint32_t)(UART_CR3_REG_INDEX << 28U | USART_CR3_EIE))
359 #define __HAL_UART_RESET_HANDLE_STATE(__HANDLE__) do{ \
360 (__HANDLE__)->gState = HAL_UART_STATE_RESET; \
361 (__HANDLE__)->RxState = HAL_UART_STATE_RESET; \
367 #define __HAL_UART_FLUSH_DRREGISTER(__HANDLE__) ((__HANDLE__)->Instance->DR)
388 #define __HAL_UART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
412 #define __HAL_UART_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__))
420 #define __HAL_UART_CLEAR_PEFLAG(__HANDLE__) \
422 __IO uint32_t tmpreg = 0x00U; \
423 tmpreg = (__HANDLE__)->Instance->SR; \
424 tmpreg = (__HANDLE__)->Instance->DR; \
434 #define __HAL_UART_CLEAR_FEFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__)
442 #define __HAL_UART_CLEAR_NEFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__)
450 #define __HAL_UART_CLEAR_OREFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__)
458 #define __HAL_UART_CLEAR_IDLEFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__)
476 #define UART_IT_MASK 0x0000FFFFU
477 #define __HAL_UART_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28U) == 1U)? ((__HANDLE__)->Instance->CR1 |= ((__INTERRUPT__) & UART_IT_MASK)): \
478 (((__INTERRUPT__) >> 28U) == 2U)? ((__HANDLE__)->Instance->CR2 |= ((__INTERRUPT__) & UART_IT_MASK)): \
479 ((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & UART_IT_MASK)))
496 #define __HAL_UART_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28U) == 1U)? ((__HANDLE__)->Instance->CR1 &= ~((__INTERRUPT__) & UART_IT_MASK)): \
497 (((__INTERRUPT__) >> 28U) == 2U)? ((__HANDLE__)->Instance->CR2 &= ~((__INTERRUPT__) & UART_IT_MASK)): \
498 ((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & UART_IT_MASK)))
515 #define __HAL_UART_GET_IT_SOURCE(__HANDLE__, __IT__) (((((__IT__) >> 28U) == 1U)? (__HANDLE__)->Instance->CR1:(((((uint32_t)(__IT__)) >> 28U) == 2U)? \
516 (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & (((uint32_t)(__IT__)) & UART_IT_MASK))
531 #define __HAL_UART_HWCONTROL_CTS_ENABLE(__HANDLE__) \
533 SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \
534 (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_CTSE; \
550 #define __HAL_UART_HWCONTROL_CTS_DISABLE(__HANDLE__) \
552 CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \
553 (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_CTSE); \
569 #define __HAL_UART_HWCONTROL_RTS_ENABLE(__HANDLE__) \
571 SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE); \
572 (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_RTSE; \
588 #define __HAL_UART_HWCONTROL_RTS_DISABLE(__HANDLE__) \
590 CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE);\
591 (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_RTSE); \
598 #define __HAL_UART_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
604 #define __HAL_UART_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint16_t)~((uint16_t)USART_CR3_ONEBIT))
610 #define __HAL_UART_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
616 #define __HAL_UART_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
710 #define UART_CR1_REG_INDEX 1U
711 #define UART_CR2_REG_INDEX 2U
712 #define UART_CR3_REG_INDEX 3U
721 #define IS_UART_WORD_LENGTH(LENGTH) (((LENGTH) == UART_WORDLENGTH_8B) || \
722 ((LENGTH) == UART_WORDLENGTH_9B))
723 #define IS_UART_LIN_WORD_LENGTH(LENGTH) (((LENGTH) == UART_WORDLENGTH_8B))
724 #define IS_UART_STOPBITS(STOPBITS) (((STOPBITS) == UART_STOPBITS_1) || \
725 ((STOPBITS) == UART_STOPBITS_2))
726 #define IS_UART_PARITY(PARITY) (((PARITY) == UART_PARITY_NONE) || \
727 ((PARITY) == UART_PARITY_EVEN) || \
728 ((PARITY) == UART_PARITY_ODD))
729 #define IS_UART_HARDWARE_FLOW_CONTROL(CONTROL)\
730 (((CONTROL) == UART_HWCONTROL_NONE) || \
731 ((CONTROL) == UART_HWCONTROL_RTS) || \
732 ((CONTROL) == UART_HWCONTROL_CTS) || \
733 ((CONTROL) == UART_HWCONTROL_RTS_CTS))
734 #define IS_UART_MODE(MODE) ((((MODE) & 0x0000FFF3U) == 0x00U) && ((MODE) != 0x00U))
735 #define IS_UART_STATE(STATE) (((STATE) == UART_STATE_DISABLE) || \
736 ((STATE) == UART_STATE_ENABLE))
737 #define IS_UART_OVERSAMPLING(SAMPLING) (((SAMPLING) == UART_OVERSAMPLING_16) || \
738 ((SAMPLING) == UART_OVERSAMPLING_8))
739 #define IS_UART_LIN_OVERSAMPLING(SAMPLING) (((SAMPLING) == UART_OVERSAMPLING_16))
740 #define IS_UART_LIN_BREAK_DETECT_LENGTH(LENGTH) (((LENGTH) == UART_LINBREAKDETECTLENGTH_10B) || \
741 ((LENGTH) == UART_LINBREAKDETECTLENGTH_11B))
742 #define IS_UART_WAKEUPMETHOD(WAKEUP) (((WAKEUP) == UART_WAKEUPMETHOD_IDLELINE) || \
743 ((WAKEUP) == UART_WAKEUPMETHOD_ADDRESSMARK))
744 #define IS_UART_BAUDRATE(BAUDRATE) ((BAUDRATE) < 10500001U)
745 #define IS_UART_ADDRESS(ADDRESS) ((ADDRESS) <= 0x0FU)
747 #define UART_DIV_SAMPLING16(_PCLK_, _BAUD_) (((_PCLK_)*25U)/(4U*(_BAUD_)))
748 #define UART_DIVMANT_SAMPLING16(_PCLK_, _BAUD_) (UART_DIV_SAMPLING16((_PCLK_), (_BAUD_))/100U)
749 #define UART_DIVFRAQ_SAMPLING16(_PCLK_, _BAUD_) (((UART_DIV_SAMPLING16((_PCLK_), (_BAUD_)) - (UART_DIVMANT_SAMPLING16((_PCLK_), (_BAUD_)) * 100U)) * 16U + 50U) / 100U)
752 #define UART_BRR_SAMPLING16(_PCLK_, _BAUD_) (((UART_DIVMANT_SAMPLING16((_PCLK_), (_BAUD_)) << 4U) + \
753 (UART_DIVFRAQ_SAMPLING16((_PCLK_), (_BAUD_)) & 0xF0U)) + \
754 (UART_DIVFRAQ_SAMPLING16((_PCLK_), (_BAUD_)) & 0x0FU))
756 #define UART_DIV_SAMPLING8(_PCLK_, _BAUD_) (((_PCLK_)*25U)/(2U*(_BAUD_)))
757 #define UART_DIVMANT_SAMPLING8(_PCLK_, _BAUD_) (UART_DIV_SAMPLING8((_PCLK_), (_BAUD_))/100U)
758 #define UART_DIVFRAQ_SAMPLING8(_PCLK_, _BAUD_) (((UART_DIV_SAMPLING8((_PCLK_), (_BAUD_)) - (UART_DIVMANT_SAMPLING8((_PCLK_), (_BAUD_)) * 100U)) * 8U + 50U) / 100U)
761 #define UART_BRR_SAMPLING8(_PCLK_, _BAUD_) (((UART_DIVMANT_SAMPLING8((_PCLK_), (_BAUD_)) << 4U) + \
762 ((UART_DIVFRAQ_SAMPLING8((_PCLK_), (_BAUD_)) & 0xF8U) << 1U)) + \
763 (UART_DIVFRAQ_SAMPLING8((_PCLK_), (_BAUD_)) & 0x07U))
Definition: stm32f4xx_hal_uart.h:151
Definition: stm32f4xx_hal_uart.h:149
HAL_StatusTypeDef HAL_HalfDuplex_EnableReceiver(UART_HandleTypeDef *huart)
void HAL_UART_AbortTransmitCpltCallback(UART_HandleTypeDef *huart)
This file contains HAL common defines, enumeration, macros and structures definitions.
void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart)
void HAL_UART_TxHalfCpltCallback(UART_HandleTypeDef *huart)
__IO uint16_t RxXferCount
Definition: stm32f4xx_hal_uart.h:174
HAL_StatusTypeDef HAL_UART_AbortReceive_IT(UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
Definition: stm32f4xx_hal_uart.h:136
void HAL_UART_AbortReceiveCpltCallback(UART_HandleTypeDef *huart)
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
Definition: main.c:922
Definition: stm32f4xx_hal_uart.h:144
HAL_StatusTypeDef HAL_MultiProcessor_Init(UART_HandleTypeDef *huart, uint8_t Address, uint32_t WakeUpMethod)
HAL_StatusTypeDef HAL_UART_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
void HAL_UART_MspInit(UART_HandleTypeDef *huart)
UART MSP Initialization This function configures the hardware resources used in this example.
Definition: stm32f4xx_hal_msp.c:550
__IO HAL_UART_StateTypeDef gState
Definition: stm32f4xx_hal_uart.h:182
HAL_StatusTypeDef HAL_UART_Abort_IT(UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_HalfDuplex_EnableTransmitter(UART_HandleTypeDef *huart)
__IO uint32_t ErrorCode
Definition: stm32f4xx_hal_uart.h:189
HAL_UART_StateTypeDef
HAL UART State structures definition.
Definition: stm32f4xx_hal_uart.h:134
HAL_StatusTypeDef HAL_LIN_SendBreak(UART_HandleTypeDef *huart)
HAL_StatusTypeDef
HAL Status structures definition.
Definition: stm32f4xx_hal_def.h:55
uint16_t TxXferSize
Definition: stm32f4xx_hal_uart.h:166
Definition: stm32f4xx_hal_uart.h:142
uint32_t HAL_UART_GetError(UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_UART_DMAResume(UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_UART_DMAStop(UART_HandleTypeDef *huart)
void HAL_UART_AbortCpltCallback(UART_HandleTypeDef *huart)
UART Init Structure definition.
Definition: stm32f4xx_hal_uart.h:63
Definition: stm32f4xx_hal_uart.h:140
uint32_t Mode
Definition: stm32f4xx_hal_uart.h:84
uint32_t BaudRate
Definition: stm32f4xx_hal_uart.h:65
HAL_StatusTypeDef HAL_UART_AbortTransmit(UART_HandleTypeDef *huart)
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
__IO uint16_t TxXferCount
Definition: stm32f4xx_hal_uart.h:168
HAL_LockTypeDef Lock
Definition: stm32f4xx_hal_uart.h:180
DMA handle Structure definition.
Definition: stm32f4xx_hal_dma.h:155
uint8_t * pRxBuffPtr
Definition: stm32f4xx_hal_uart.h:170
HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
HAL_StatusTypeDef HAL_UART_AbortReceive(UART_HandleTypeDef *huart)
__IO HAL_UART_StateTypeDef RxState
Definition: stm32f4xx_hal_uart.h:186
uint16_t RxXferSize
Definition: stm32f4xx_hal_uart.h:172
HAL_UART_StateTypeDef HAL_UART_GetState(UART_HandleTypeDef *huart)
USART_TypeDef * Instance
Definition: stm32f4xx_hal_uart.h:160
HAL_StatusTypeDef HAL_UART_Init(UART_HandleTypeDef *huart)
const uint8_t[]
Definition: 404_html.c:3
HAL_StatusTypeDef HAL_UART_DMAPause(UART_HandleTypeDef *huart)
uint32_t HwFlowCtl
Definition: stm32f4xx_hal_uart.h:87
HAL_StatusTypeDef HAL_HalfDuplex_Init(UART_HandleTypeDef *huart)
uint32_t StopBits
Definition: stm32f4xx_hal_uart.h:74
HAL_StatusTypeDef HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout)
Definition: stm32f4xx_hal_uart.h:146
Definition: stm32f4xx_hal_uart.h:138
void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart)
uint32_t Parity
Definition: stm32f4xx_hal_uart.h:77
uint32_t WordLength
Definition: stm32f4xx_hal_uart.h:71
void HAL_UART_MspDeInit(UART_HandleTypeDef *huart)
UART MSP De-Initialization This function freeze the hardware resources used in this example.
Definition: stm32f4xx_hal_msp.c:683
HAL_StatusTypeDef HAL_LIN_Init(UART_HandleTypeDef *huart, uint32_t BreakDetectLength)
HAL_StatusTypeDef HAL_MultiProcessor_EnterMuteMode(UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_UART_Abort(UART_HandleTypeDef *huart)
DMA_HandleTypeDef * hdmatx
Definition: stm32f4xx_hal_uart.h:176
HAL_StatusTypeDef HAL_UART_AbortTransmit_IT(UART_HandleTypeDef *huart)
HAL_LockTypeDef
HAL Lock structures definition.
Definition: stm32f4xx_hal_def.h:66
uint8_t * pTxBuffPtr
Definition: stm32f4xx_hal_uart.h:164
UART handle Structure definition.
Definition: stm32f4xx_hal_uart.h:158
uint32_t OverSampling
Definition: stm32f4xx_hal_uart.h:91
HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
void HAL_UART_IRQHandler(UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_MultiProcessor_ExitMuteMode(UART_HandleTypeDef *huart)
DMA_HandleTypeDef * hdmarx
Definition: stm32f4xx_hal_uart.h:178
UART_InitTypeDef Init
Definition: stm32f4xx_hal_uart.h:162
HAL_StatusTypeDef HAL_UART_DeInit(UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout)