bf0_hal_uart.h

Header file of UART HAL module.

Author

Sifli software development team

Attention

Defines

USART_CR1_FIFOEN
HAL_UART_ERROR_NONE

No error

HAL_UART_ERROR_PE

Parity error

HAL_UART_ERROR_NE

Noise error

HAL_UART_ERROR_FE

Frame error

HAL_UART_ERROR_ORE

Overrun error

HAL_UART_ERROR_DMA

DMA transfer error

USART_CR1_M0
USART_CR1_M1
UART_WORDLENGTH_6B

6-bit long UART frame

UART_WORDLENGTH_7B

7-bit long UART frame

UART_WORDLENGTH_8B

8-bit long UART frame

UART_WORDLENGTH_9B

9-bit long UART frame

UART_STOPBITS_0_5

UART frame with 0.5 stop bit

UART_STOPBITS_1

UART frame with 1 stop bit

UART_STOPBITS_1_5

UART frame with 1.5 stop bits

UART_STOPBITS_2

UART frame with 2 stop bits

UART_PARITY_NONE

No parity

UART_PARITY_EVEN

Even parity

UART_PARITY_ODD

Odd parity

UART_HWCONTROL_NONE

No hardware control

UART_HWCONTROL_RTS

Request To Send

UART_HWCONTROL_CTS

Clear To Send

UART_HWCONTROL_RTS_CTS

Request and Clear To Send

UART_MODE_RX

RX mode

UART_MODE_TX

TX mode

UART_MODE_TX_RX

RX and TX mode

UART_STATE_DISABLE

UART disabled

UART_STATE_ENABLE

UART enabled

UART_OVERSAMPLING_16

Oversampling by 16

UART_OVERSAMPLING_8

Oversampling by 8

UART_ONE_BIT_SAMPLE_DISABLE

One-bit sampling disable

UART_ONE_BIT_SAMPLE_ENABLE

One-bit sampling enable

UART_ADVFEATURE_AUTOBAUDRATE_ONSTARTBIT

Auto Baud rate detection on start bit

UART_ADVFEATURE_AUTOBAUDRATE_ONFALLINGEDGE

Auto Baud rate detection on falling edge

UART_ADVFEATURE_AUTOBAUDRATE_ON0X7FFRAME

Auto Baud rate detection on 0x7F frame detection

UART_ADVFEATURE_AUTOBAUDRATE_ON0X55FRAME

Auto Baud rate detection on 0x55 frame detection

UART_RECEIVER_TIMEOUT_DISABLE

UART receiver timeout disable

UART_RECEIVER_TIMEOUT_ENABLE

UART receiver timeout enable

UART_LIN_DISABLE

Local Interconnect Network disable

UART_LIN_ENABLE

Local Interconnect Network enable

UART_LINBREAKDETECTLENGTH_10B

LIN 10-bit break detection length

UART_LINBREAKDETECTLENGTH_11B

LIN 11-bit break detection length

UART_DMA_TX_DISABLE

UART DMA TX disabled

UART_DMA_TX_ENABLE

UART DMA TX enabled

UART_DMA_RX_DISABLE

UART DMA RX disabled

UART_DMA_RX_ENABLE

UART DMA RX enabled

UART_HALF_DUPLEX_DISABLE

UART half-duplex disabled

UART_HALF_DUPLEX_ENABLE

UART half-duplex enabled

UART_WAKEUPMETHOD_IDLELINE

UART wake-up on idle line

UART_WAKEUPMETHOD_ADDRESSMARK

UART wake-up on address mark

UART_AUTOBAUD_REQUEST

Auto-Baud Rate Request

UART_SENDBREAK_REQUEST

Send Break Request

UART_MUTE_MODE_REQUEST

Mute Mode Request

UART_RXDATA_FLUSH_REQUEST

Receive Data flush Request

UART_TXDATA_FLUSH_REQUEST

Transmit data flush Request

UART_ADVFEATURE_NO_INIT

No advanced feature initialization

UART_ADVFEATURE_TXINVERT_INIT

TX pin active level inversion

UART_ADVFEATURE_RXINVERT_INIT

RX pin active level inversion

UART_ADVFEATURE_DATAINVERT_INIT

Binary data inversion

UART_ADVFEATURE_SWAP_INIT

TX/RX pins swap

UART_ADVFEATURE_RXOVERRUNDISABLE_INIT

RX overrun disable

UART_ADVFEATURE_DMADISABLEONERROR_INIT

DMA disable on Reception Error

UART_ADVFEATURE_AUTOBAUDRATE_INIT

Auto Baud rate detection initialization

UART_ADVFEATURE_MSBFIRST_INIT

Most significant bit sent/received first

UART_ADVFEATURE_TXINV_DISABLE

TX pin active level inversion disable

UART_ADVFEATURE_TXINV_ENABLE

TX pin active level inversion enable

UART_ADVFEATURE_RXINV_DISABLE

RX pin active level inversion disable

UART_ADVFEATURE_RXINV_ENABLE

RX pin active level inversion enable

UART_ADVFEATURE_DATAINV_DISABLE

Binary data inversion disable

UART_ADVFEATURE_DATAINV_ENABLE

Binary data inversion enable

UART_ADVFEATURE_SWAP_DISABLE

TX/RX pins swap disable

UART_ADVFEATURE_SWAP_ENABLE

TX/RX pins swap enable

UART_ADVFEATURE_OVERRUN_ENABLE

RX overrun enable

UART_ADVFEATURE_OVERRUN_DISABLE

RX overrun disable

UART_ADVFEATURE_AUTOBAUDRATE_DISABLE

RX Auto Baud rate detection enable

UART_ADVFEATURE_AUTOBAUDRATE_ENABLE

RX Auto Baud rate detection disable

UART_ADVFEATURE_DMA_ENABLEONRXERROR

DMA enable on Reception Error

UART_ADVFEATURE_DMA_DISABLEONRXERROR

DMA disable on Reception Error

UART_ADVFEATURE_MSBFIRST_DISABLE

Most significant bit sent/received first disable

UART_ADVFEATURE_MSBFIRST_ENABLE

Most significant bit sent/received first enable

UART_ADVFEATURE_STOPMODE_DISABLE

UART stop mode disable

UART_ADVFEATURE_STOPMODE_ENABLE

UART stop mode enable

UART_ADVFEATURE_MUTEMODE_DISABLE

UART mute mode disable

UART_ADVFEATURE_MUTEMODE_ENABLE

UART mute mode enable

UART_CR2_ADDRESS_LSB_POS

UART address-matching LSB position in CR2 register

UART_WAKEUP_ON_ADDRESS

UART wake-up on address

UART_WAKEUP_ON_STARTBIT

UART wake-up on start bit

UART_WAKEUP_ON_READDATA_NONEMPTY

UART wake-up on receive data register not empty or RXFIFO is not empty

UART_DE_POLARITY_HIGH

Driver enable signal is active high

UART_DE_POLARITY_LOW

Driver enable signal is active low

UART_CR1_DEAT_ADDRESS_LSB_POS

UART Driver Enable assertion time LSB position in CR1 register

UART_CR1_DEDT_ADDRESS_LSB_POS

UART Driver Enable de-assertion time LSB position in CR1 register

UART_IT_MASK

UART interruptions flags mask

HAL_UART_TIMEOUT_VALUE

UART polling-based communications time-out value

UART_FLAG_TXFT

UART TXFIFO threshold flag

UART_FLAG_RXFT

UART RXFIFO threshold flag

UART_FLAG_RXFF

UART RXFIFO Full flag

UART_FLAG_TXFE

UART TXFIFO Empty flag

UART_FLAG_REACK

UART receive enable acknowledge flag

UART_FLAG_TEACK

UART transmit enable acknowledge flag

UART_FLAG_WUF

UART wake-up from stop mode flag

UART_FLAG_RWU

UART receiver wake-up from mute mode flag

UART_FLAG_SBKF

UART send break flag

UART_FLAG_CMF

UART character match flag

UART_FLAG_BUSY

UART busy flag

UART_FLAG_ABRF

UART auto Baud rate flag

UART_FLAG_ABRE

UART auto Baud rate error

UART_FLAG_CTS

UART clear to send flag

UART_FLAG_CTSIF

UART clear to send interrupt flag

UART_FLAG_LBDF

UART LIN break detection flag

UART_FLAG_TXE

UART transmit data register empty

UART_FLAG_TXFNF

UART TXFIFO not full

UART_FLAG_TC

UART transmission complete

UART_FLAG_RXNE

UART read data register not empty

UART_FLAG_RXFNE

UART RXFIFO not empty

UART_FLAG_IDLE

UART idle flag

UART_FLAG_ORE

UART overrun error

UART_FLAG_NE

UART noise error

UART_FLAG_FE

UART frame error

UART_FLAG_PE

UART parity error

UART_IT_PE

UART parity error interruption

UART_IT_TXE

UART transmit data register empty interruption

UART_IT_TXFNF

UART TX FIFO not full interruption

UART_IT_TC

UART transmission complete interruption

UART_IT_RXNE

UART read data register not empty interruption

UART_IT_RXFNE

UART RXFIFO not empty interruption

UART_IT_IDLE

UART idle interruption

UART_IT_LBD

UART LIN break detection interruption

UART_IT_CTS

UART CTS interruption

UART_IT_CM

UART character match interruption

UART_IT_WUF

UART wake-up from stop mode interruption

UART_IT_RXFF

UART RXFIFO full interruption

UART_IT_TXFE

UART TXFIFO empty interruption

UART_IT_RXFT

UART RXFIFO threshold reached interruption

UART_IT_TXFT

UART TXFIFO threshold reached interruption

UART_IT_ERR

UART error interruption

UART_IT_ORE

UART overrun error interruption

UART_IT_NE

UART noise error interruption

UART_IT_FE

UART frame error interruption

UART_CLEAR_PEF

Parity Error Clear Flag

UART_CLEAR_FEF

Framing Error Clear Flag

UART_CLEAR_NEF

Noise Error detected Clear Flag

UART_CLEAR_OREF

Overrun Error Clear Flag

UART_CLEAR_IDLEF

IDLE line detected Clear Flag

UART_CLEAR_TXFECF

TXFIFO empty clear flag

UART_CLEAR_TCF

Transmission Complete Clear Flag

UART_CLEAR_LBDF

LIN Break Detection Clear Flag

UART_CLEAR_CTSF

CTS Interrupt Clear Flag

UART_CLEAR_CMF

Character Match Clear Flag

UART_CLEAR_WUF

Wake Up from stop mode Clear Flag

__HAL_UART_RESET_HANDLE_STATE(__HANDLE__)

Reset UART handle states.

参数:
  • __HANDLE__ – UART handle.

返回值:

None

__HAL_UART_FLUSH_DRREGISTER(__HANDLE__)

Flush the UART Data registers.

参数:
  • __HANDLE__ – specifies the UART Handle.

返回值:

None

__HAL_UART_CLEAR_FLAG(__HANDLE__, __FLAG__)

Clear the specified UART pending flag.

参数:
返回值:

None

__HAL_UART_CLEAR_PEFLAG(__HANDLE__)

Clear the UART PE pending flag.

参数:
  • __HANDLE__ – specifies the UART Handle.

返回值:

None

__HAL_UART_CLEAR_FEFLAG(__HANDLE__)

Clear the UART FE pending flag.

参数:
  • __HANDLE__ – specifies the UART Handle.

返回值:

None

__HAL_UART_CLEAR_NEFLAG(__HANDLE__)

Clear the UART NE pending flag.

参数:
  • __HANDLE__ – specifies the UART Handle.

返回值:

None

__HAL_UART_CLEAR_OREFLAG(__HANDLE__)

Clear the UART ORE pending flag.

参数:
  • __HANDLE__ – specifies the UART Handle.

返回值:

None

__HAL_UART_CLEAR_IDLEFLAG(__HANDLE__)

Clear the UART IDLE pending flag.

参数:
  • __HANDLE__ – specifies the UART Handle.

返回值:

None

__HAL_UART_CLEAR_TXFECF(__HANDLE__)

Clear the UART TX FIFO empty clear flag.

参数:
  • __HANDLE__ – specifies the UART Handle.

返回值:

None

__HAL_UART_GET_FLAG(__HANDLE__, __FLAG__)

Check whether the specified UART flag is set or not.

参数:
返回值:

The – new state of FLAG (TRUE or FALSE).

__HAL_UART_ENABLE_IT(__HANDLE__, __INTERRUPT__)

Enable the specified UART interrupt.

参数:
返回值:

None

__HAL_UART_DISABLE_IT(__HANDLE__, __INTERRUPT__)

Disable the specified UART interrupt.

参数:
返回值:

None

__HAL_UART_GET_IT(__HANDLE__, __INTERRUPT__)

Check whether the specified UART interrupt has occurred or not.

参数:
返回值:

The – new state of INTERRUPT (SET or RESET).

__HAL_UART_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)

Check whether the specified UART interrupt source is enabled or not.

参数:
返回值:

The – new state of INTERRUPT (SET or RESET).

__HAL_UART_CLEAR_IT(__HANDLE__, __IT_CLEAR__)

Clear the specified UART ISR flag, in setting the proper ICR register flag.

参数:
返回值:

None

__HAL_UART_SEND_REQ(__HANDLE__, __REQ__)

Set a specific UART request flag.

参数:
返回值:

None

__HAL_UART_ONE_BIT_SAMPLE_ENABLE(__HANDLE__)

Enable the UART one bit sample method.

参数:
  • __HANDLE__ – specifies the UART Handle.

返回值:

None

__HAL_UART_ONE_BIT_SAMPLE_DISABLE(__HANDLE__)

Disable the UART one bit sample method.

参数:
  • __HANDLE__ – specifies the UART Handle.

返回值:

None

__HAL_UART_ENABLE(__HANDLE__)

Enable UART.

参数:
  • __HANDLE__ – specifies the UART Handle.

返回值:

None

__HAL_UART_DISABLE(__HANDLE__)

Disable UART.

参数:
  • __HANDLE__ – specifies the UART Handle.

返回值:

None

__HAL_UART_HWCONTROL_CTS_ENABLE(__HANDLE__)

Enable CTS flow control.

备注

This macro allows to enable CTS hardware flow control for a given UART instance, without need to call HAL_UART_Init() function. As involving direct access to UART registers, usage of this macro should be fully endorsed by user.

备注

As macro is expected to be used for modifying CTS Hw flow control feature activation, without need for USART instance Deinit/Init, following conditions for macro call should be fulfilled :

  • UART instance should have already been initialised (through call of HAL_UART_Init() )

  • macro could only be called when corresponding UART instance is disabled (i.e. HAL_UART_DISABLE(__HANDLE)) and should be followed by an Enable macro (i.e. HAL_UART_ENABLE(__HANDLE)).

参数:
  • __HANDLE__ – specifies the UART Handle.

返回值:

None

__HAL_UART_HWCONTROL_CTS_DISABLE(__HANDLE__)

Disable CTS flow control.

备注

This macro allows to disable CTS hardware flow control for a given UART instance, without need to call HAL_UART_Init() function. As involving direct access to UART registers, usage of this macro should be fully endorsed by user.

备注

As macro is expected to be used for modifying CTS Hw flow control feature activation, without need for USART instance Deinit/Init, following conditions for macro call should be fulfilled :

  • UART instance should have already been initialised (through call of HAL_UART_Init() )

  • macro could only be called when corresponding UART instance is disabled (i.e. HAL_UART_DISABLE(__HANDLE)) and should be followed by an Enable macro (i.e. HAL_UART_ENABLE(__HANDLE)).

参数:
  • __HANDLE__ – specifies the UART Handle.

返回值:

None

__HAL_UART_HWCONTROL_RTS_ENABLE(__HANDLE__)

Enable RTS flow control.

备注

This macro allows to enable RTS hardware flow control for a given UART instance, without need to call HAL_UART_Init() function. As involving direct access to UART registers, usage of this macro should be fully endorsed by user.

备注

As macro is expected to be used for modifying RTS Hw flow control feature activation, without need for USART instance Deinit/Init, following conditions for macro call should be fulfilled :

  • UART instance should have already been initialised (through call of HAL_UART_Init() )

  • macro could only be called when corresponding UART instance is disabled (i.e. HAL_UART_DISABLE(__HANDLE)) and should be followed by an Enable macro (i.e. HAL_UART_ENABLE(__HANDLE)).

参数:
  • __HANDLE__ – specifies the UART Handle.

返回值:

None

__HAL_UART_HWCONTROL_RTS_DISABLE(__HANDLE__)

Disable RTS flow control.

备注

This macro allows to disable RTS hardware flow control for a given UART instance, without need to call HAL_UART_Init() function. As involving direct access to UART registers, usage of this macro should be fully endorsed by user.

备注

As macro is expected to be used for modifying RTS Hw flow control feature activation, without need for USART instance Deinit/Init, following conditions for macro call should be fulfilled :

  • UART instance should have already been initialised (through call of HAL_UART_Init() )

  • macro could only be called when corresponding UART instance is disabled (i.e. HAL_UART_DISABLE(__HANDLE)) and should be followed by an Enable macro (i.e. HAL_UART_ENABLE(__HANDLE)).

参数:
  • __HANDLE__ – specifies the UART Handle.

返回值:

None

__HAL_UART_GETC(__HANDLE__)

Get byte in FIFO.

参数:
  • __HANDLE__ – specifies the UART Handle.

返回值:

Byte – in FIFO

__HAL_UART_PUTC(__HANDLE__, ch)

Put byte in FIFO for RX.

参数:
  • __HANDLE__ – specifies the UART Handle.

  • ch – Byte to put into FIFO

返回值:

Byte – in FIFO

UART_MASK_COMPUTATION(__HANDLE__)

Report the UART mask to apply to retrieve the received data according to the word length and to the parity bits activation.

备注

If PCE = 1, the parity bit is not included in the data extracted by the reception API(). This masking operation is not carried out in the case of DMA transfers.

参数:
  • __HANDLE__ – specifies the UART Handle.

返回值:

None, the – mask to apply to UART RDR register is stored in (HANDLE)->Mask field.

UART_DIV_LPUART(__PCLK__, __BAUD__)

BRR division operation to set BRR register with LPUART.

参数:
  • __PCLK__ – LPUART clock.

  • __BAUD__ – Baud rate set by the user.

返回值:

Division – result

UART_DIV_SAMPLING8(__PCLK__, __BAUD__)

BRR division operation to set BRR register in 8-bit oversampling mode.

参数:
  • __PCLK__ – UART clock.

  • __BAUD__ – Baud rate set by the user.

返回值:

Division – result

UART_DIV_SAMPLING16(__PCLK__, __BAUD__)

BRR division operation to set BRR register in 16-bit oversampling mode.

参数:
  • __PCLK__ – UART clock.

  • __BAUD__ – Baud rate set by the user.

返回值:

Division – result

UART_INSTANCE_LOWPOWER(__HANDLE__)

Check whether or not UART instance is Low Power UART.

参数:
  • __HANDLE__ – specifies the UART Handle.

返回值:

SET – (instance is LPUART) or RESET (instance isn’t LPUART)

IS_UART_WORD_LENGTH(LENGTH)
IS_UART_BAUDRATE(__BAUDRATE__)

Check UART Baud rate.

参数:
  • __BAUDRATE__ – Baudrate specified by the user. The maximum Baud Rate is derived from the maximum clock on L4 divided by the smallest oversampling used on the USART (i.e. 8)

返回值:

SET – (BAUDRATE is valid) or RESET (BAUDRATE is invalid)

IS_UART_ASSERTIONTIME(__TIME__)

Check UART assertion time.

参数:
  • __TIME__ – 5-bit value assertion time.

返回值:

Test – result (TRUE or FALSE).

IS_UART_DEASSERTIONTIME(__TIME__)

Check UART deassertion time.

参数:
  • __TIME__ – 5-bit value deassertion time.

返回值:

Test – result (TRUE or FALSE).

IS_UART_STOPBITS(__STOPBITS__)

Ensure that UART frame number of stop bits is valid.

参数:
  • __STOPBITS__ – UART frame number of stop bits.

返回值:

SET – (STOPBITS is valid) or RESET (STOPBITS is invalid)

IS_LPUART_STOPBITS(__STOPBITS__)

Ensure that LPUART frame number of stop bits is valid.

参数:
  • __STOPBITS__ – LPUART frame number of stop bits.

返回值:

SET – (STOPBITS is valid) or RESET (STOPBITS is invalid)

IS_UART_PARITY(__PARITY__)

Ensure that UART frame parity is valid.

参数:
  • __PARITY__ – UART frame parity.

返回值:

SET – (PARITY is valid) or RESET (PARITY is invalid)

IS_UART_HARDWARE_FLOW_CONTROL(__CONTROL__)

Ensure that UART hardware flow control is valid.

参数:
  • __CONTROL__ – UART hardware flow control.

返回值:

SET – (CONTROL is valid) or RESET (CONTROL is invalid)

IS_UART_MODE(__MODE__)

Ensure that UART communication mode is valid.

参数:
  • __MODE__ – UART communication mode.

返回值:

SET – (MODE is valid) or RESET (MODE is invalid)

IS_UART_STATE(__STATE__)

Ensure that UART state is valid.

参数:
  • __STATE__ – UART state.

返回值:

SET – (STATE is valid) or RESET (STATE is invalid)

IS_UART_OVERSAMPLING(__SAMPLING__)

Ensure that UART oversampling is valid.

参数:
  • __SAMPLING__ – UART oversampling.

返回值:

SET – (SAMPLING is valid) or RESET (SAMPLING is invalid)

IS_UART_ONE_BIT_SAMPLE(__ONEBIT__)

Ensure that UART frame sampling is valid.

参数:
  • __ONEBIT__ – UART frame sampling.

返回值:

SET – (ONEBIT is valid) or RESET (ONEBIT is invalid)

IS_UART_ADVFEATURE_AUTOBAUDRATEMODE(__MODE__)

Ensure that UART auto Baud rate detection mode is valid.

参数:
  • __MODE__ – UART auto Baud rate detection mode.

返回值:

SET – (MODE is valid) or RESET (MODE is invalid)

IS_UART_RECEIVER_TIMEOUT(__TIMEOUT__)

Ensure that UART receiver timeout setting is valid.

参数:
  • __TIMEOUT__ – UART receiver timeout setting.

返回值:

SET – (TIMEOUT is valid) or RESET (TIMEOUT is invalid)

IS_UART_LIN(__LIN__)

Ensure that UART LIN state is valid.

参数:
  • __LIN__ – UART LIN state.

返回值:

SET – (LIN is valid) or RESET (LIN is invalid)

IS_UART_LIN_BREAK_DETECT_LENGTH(__LENGTH__)

Ensure that UART LIN break detection length is valid.

参数:
  • __LENGTH__ – UART LIN break detection length.

返回值:

SET – (LENGTH is valid) or RESET (LENGTH is invalid)

IS_UART_DMA_TX(__DMATX__)

Ensure that UART DMA TX state is valid.

参数:
  • __DMATX__ – UART DMA TX state.

返回值:

SET – (DMATX is valid) or RESET (DMATX is invalid)

IS_UART_DMA_RX(__DMARX__)

Ensure that UART DMA RX state is valid.

参数:
  • __DMARX__ – UART DMA RX state.

返回值:

SET – (DMARX is valid) or RESET (DMARX is invalid)

IS_UART_HALF_DUPLEX(__HDSEL__)

Ensure that UART half-duplex state is valid.

参数:
  • __HDSEL__ – UART half-duplex state.

返回值:

SET – (HDSEL is valid) or RESET (HDSEL is invalid)

IS_UART_WAKEUPMETHOD(__WAKEUP__)

Ensure that UART wake-up method is valid.

参数:
  • __WAKEUP__ – UART wake-up method .

返回值:

SET – (WAKEUP is valid) or RESET (WAKEUP is invalid)

IS_UART_REQUEST_PARAMETER(__PARAM__)

Ensure that UART request parameter is valid.

参数:
  • __PARAM__ – UART request parameter.

返回值:

SET – (PARAM is valid) or RESET (PARAM is invalid)

IS_UART_ADVFEATURE_INIT(__INIT__)

Ensure that UART advanced features initialization is valid.

参数:
  • __INIT__ – UART advanced features initialization.

返回值:

SET – (INIT is valid) or RESET (INIT is invalid)

IS_UART_ADVFEATURE_TXINV(__TXINV__)

Ensure that UART frame TX inversion setting is valid.

参数:
  • __TXINV__ – UART frame TX inversion setting.

返回值:

SET – (TXINV is valid) or RESET (TXINV is invalid)

IS_UART_ADVFEATURE_RXINV(__RXINV__)

Ensure that UART frame RX inversion setting is valid.

参数:
  • __RXINV__ – UART frame RX inversion setting.

返回值:

SET – (RXINV is valid) or RESET (RXINV is invalid)

IS_UART_ADVFEATURE_DATAINV(__DATAINV__)

Ensure that UART frame data inversion setting is valid.

参数:
  • __DATAINV__ – UART frame data inversion setting.

返回值:

SET – (DATAINV is valid) or RESET (DATAINV is invalid)

IS_UART_ADVFEATURE_SWAP(__SWAP__)

Ensure that UART frame RX/TX pins swap setting is valid.

参数:
  • __SWAP__ – UART frame RX/TX pins swap setting.

返回值:

SET – (SWAP is valid) or RESET (SWAP is invalid)

IS_UART_OVERRUN(__OVERRUN__)

Ensure that UART frame overrun setting is valid.

参数:
  • __OVERRUN__ – UART frame overrun setting.

返回值:

SET – (OVERRUN is valid) or RESET (OVERRUN is invalid)

IS_UART_ADVFEATURE_AUTOBAUDRATE(__AUTOBAUDRATE__)

Ensure that UART auto Baud rate state is valid.

参数:
  • __AUTOBAUDRATE__ – UART auto Baud rate state.

返回值:

SET – (AUTOBAUDRATE is valid) or RESET (AUTOBAUDRATE is invalid)

IS_UART_ADVFEATURE_DMAONRXERROR(__DMA__)

Ensure that UART DMA enabling or disabling on error setting is valid.

参数:
  • __DMA__ – UART DMA enabling or disabling on error setting.

返回值:

SET – (DMA is valid) or RESET (DMA is invalid)

IS_UART_ADVFEATURE_MSBFIRST(__MSBFIRST__)

Ensure that UART frame MSB first setting is valid.

参数:
  • __MSBFIRST__ – UART frame MSB first setting.

返回值:

SET – (MSBFIRST is valid) or RESET (MSBFIRST is invalid)

IS_UART_ADVFEATURE_STOPMODE(__STOPMODE__)

Ensure that UART stop mode state is valid.

参数:
  • __STOPMODE__ – UART stop mode state.

返回值:

SET – (STOPMODE is valid) or RESET (STOPMODE is invalid)

IS_UART_MUTE_MODE(__MUTE__)

Ensure that UART mute mode state is valid.

参数:
  • __MUTE__ – UART mute mode state.

返回值:

SET – (MUTE is valid) or RESET (MUTE is invalid)

IS_UART_WAKEUP_SELECTION(__WAKE__)

Ensure that UART wake-up selection is valid.

参数:
  • __WAKE__ – UART wake-up selection.

返回值:

SET – (WAKE is valid) or RESET (WAKE is invalid)

IS_UART_DE_POLARITY(__POLARITY__)

Ensure that UART driver enable polarity is valid.

参数:
  • __POLARITY__ – UART driver enable polarity.

返回值:

SET – (POLARITY is valid) or RESET (POLARITY is invalid)

IS_UART_HWFLOW_INSTANCE(__INSTANCE__)
IS_UART_INSTANCE(__INSTANCE__)
IS_UART_HALFDUPLEX_INSTANCE(__INSTANCE__)
IS_UART_LIN_INSTANCE(__INSTANCE__)
IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(__INSTANCE__)
HAL_UART_LOCK_DEF()
HAL_UART_LOCK(__HANDLE__)
HAL_UART_UNLOCK(__HANDLE__)

Typedefs

typedef struct __UART_HandleTypeDef UART_HandleTypeDef

UART handle Structure definition.

Enums

enum HAL_UART_StateTypeDef

HAL UART State structures definition.

备注

HAL UART State value is a combination of 2 different substates: gState and RxState.

  • gState contains UART state information related to global Handle management and also information related to Tx operations. gState value coding follow below described bitmap : b7-b6 Error information 00 : No Error 01 : (Not Used) 10 : Timeout 11 : Error b5 IP initilisation status 0 : Reset (IP not initialized) 1 : Init done (IP not initialized. HAL UART Init function already called) b4-b3 (not used) xx : Should be set to 00 b2 Intrinsic process state 0 : Ready 1 : Busy (IP busy with some configuration or internal operations) b1 (not used) x : Should be set to 0 b0 Tx state 0 : Ready (no Tx operation ongoing) 1 : Busy (Tx operation ongoing)

  • RxState contains information related to Rx operations. RxState value coding follow below described bitmap : b7-b6 (not used) xx : Should be set to 00 b5 IP initilisation status 0 : Reset (IP not initialized) 1 : Init done (IP not initialized) b4-b2 (not used) xxx : Should be set to 000 b1 Rx state 0 : Ready (no Rx operation ongoing) 1 : Busy (Rx operation ongoing) b0 (not used) x : Should be set to 0.

Values:

enumerator HAL_UART_STATE_RESET

Peripheral is not initialized Value is allowed for gState and RxState

enumerator HAL_UART_STATE_READY

Peripheral Initialized and ready for use Value is allowed for gState and RxState

enumerator HAL_UART_STATE_BUSY

an internal process is ongoing Value is allowed for gState only

enumerator HAL_UART_STATE_BUSY_TX

Data Transmission process is ongoing Value is allowed for gState only

enumerator HAL_UART_STATE_BUSY_RX

Data Reception process is ongoing Value is allowed for RxState only

enumerator HAL_UART_STATE_BUSY_TX_RX

Data Transmission and Reception process is ongoing Not to be used for neither gState nor RxState. Value is result of combination (Or) between gState and RxState values

enumerator HAL_UART_STATE_TIMEOUT

Timeout state Value is allowed for gState only

enumerator HAL_UART_STATE_ERROR

Error Value is allowed for gState only

Functions

HAL_StatusTypeDef HAL_UART_Init(UART_HandleTypeDef *huart)

Initialize the UART mode according to the specified parameters in the UART_InitTypeDef and initialize the associated handle.

参数:
  • huart – UART handle.

返回值:

HAL – status

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)

DeInitialize the UART peripheral.

参数:
  • huart – UART handle.

返回值:

HAL – status

void HAL_UART_MspInit(UART_HandleTypeDef *huart)
void HAL_UART_MspDeInit(UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout)

Send an amount of data in blocking mode.

备注

When FIFO mode is enabled, writing a data in the TDR register adds one data to the TXFIFO. Write operations to the TDR register are performed when TXFNF flag is set. From hardware perspective, TXFNF flag and TXE are mapped on the same bit-field.

参数:
  • huart – UART handle.

  • pData – Pointer to data buffer.

  • Size – Amount of data to be sent.

  • Timeout – Timeout duration.

返回值:

HAL – status

HAL_StatusTypeDef HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout)

Receive an amount of data in blocking mode.

备注

When FIFO mode is enabled, the RXFNE flag is set as long as the RXFIFO is not empty. Read operations from the RDR register are performed when RXFNE flag is set. From hardware perspective, RXFNE flag and RXNE are mapped on the same bit-field.

参数:
  • huart – UART handle.

  • pData – Pointer to data buffer.

  • Size – Amount of data to be received.

  • Timeout – Timeout duration.

返回值:

HAL – status

HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)

Send an amount of data in interrupt mode.

参数:
  • huart – UART handle.

  • pData – Pointer to data buffer.

  • Size – Amount of data to be sent.

返回值:

HAL – status

HAL_StatusTypeDef HAL_UART_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)

Receive an amount of data in interrupt mode.

参数:
  • huart – UART handle.

  • pData – Pointer to data buffer.

  • Size – Amount of data to be received.

返回值:

HAL – status

HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)

Send an amount of data in DMA mode.

参数:
  • huart – UART handle.

  • pData – Pointer to data buffer.

  • Size – Amount of data to be sent.

返回值:

HAL – status

HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)

Receive an amount of data in DMA mode.

备注

When the UART parity is enabled (PCE = 1), the received data contain the parity bit (MSB position).

参数:
  • huart – UART handle.

  • pData – Pointer to data buffer.

  • Size – Amount of data to be received.

返回值:

HAL – status

HAL_StatusTypeDef HAL_UART_DmaTransmit(UART_HandleTypeDef *huart, uint8_t *buf, uint32_t size, int direction)

Start UART DMA transfer.

参数:
  • huart – UART handle.

  • buf – Buffer to receive/send from/to UART.

  • size – Size of buf.

  • direction – DMA_PERIPH_TO_MEMORY for uart rX, DMA_MEMORY_TO_PERIPH for uart tx.

返回值:

HAL – status

HAL_StatusTypeDef HAL_UART_DMAPause(UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_UART_DMAResume(UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_UART_DMAStop(UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_UART_Abort(UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_UART_AbortTransmit(UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_UART_AbortReceive(UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_UART_Abort_IT(UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_UART_AbortTransmit_IT(UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_UART_AbortReceive_IT(UART_HandleTypeDef *huart)
void HAL_UART_IRQHandler(UART_HandleTypeDef *huart)

Handle UART interrupt request.

参数:
  • huart – UART handle.

返回值:

None

void HAL_UART_TxHalfCpltCallback(UART_HandleTypeDef *huart)
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart)
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart)
void HAL_UART_AbortCpltCallback(UART_HandleTypeDef *huart)
void HAL_UART_AbortTransmitCpltCallback(UART_HandleTypeDef *huart)
void HAL_UART_AbortReceiveCpltCallback(UART_HandleTypeDef *huart)
void HAL_UART_WakeupCallback(UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_LIN_SendBreak(UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_HalfDuplex_EnableTransmitter(UART_HandleTypeDef *huart)
HAL_StatusTypeDef HAL_HalfDuplex_EnableReceiver(UART_HandleTypeDef *huart)
HAL_UART_StateTypeDef HAL_UART_GetState(UART_HandleTypeDef *huart)
uint32_t HAL_UART_GetError(UART_HandleTypeDef *huart)
HAL_StatusTypeDef UART_SetConfig(UART_HandleTypeDef *huart)

Configure the UART peripheral.

参数:
  • huart – UART handle.

返回值:

HAL – status

HAL_StatusTypeDef UART_CheckIdleState(UART_HandleTypeDef *huart)
HAL_StatusTypeDef UART_WaitOnFlagUntilTimeout(UART_HandleTypeDef *huart, uint32_t Flag, FlagStatus Status, uint32_t Tickstart, uint32_t Timeout)
void UART_AdvFeatureConfig(UART_HandleTypeDef *huart)
struct UART_InitTypeDef
#include <bf0_hal_uart.h>

UART Init Structure definition.

Public Members

uint32_t BaudRate

This member configures the UART communication baud rate. The baud rate register is computed using the following formula:

UART:

  • If oversampling is 16 or in LIN mode, Baud Rate Register = ((uart_ker_ckpres) / ((huart->Init.BaudRate)))

  • If oversampling is 8, Baud Rate Register[15:4] = ((2 * uart_ker_ckpres) / ((huart->Init.BaudRate)))[15:4] Baud Rate Register[3] = 0 Baud Rate Register[2:0] = (((2 * uart_ker_ckpres) / ((huart->Init.BaudRate)))[3:0]) >> 1

LPUART:

Baud Rate Register = ((256 * lpuart_ker_ckpres) / ((huart->Init.BaudRate)))

where (uart/lpuart)_ker_ck_pres is the UART input clock divided by a prescaler

uint32_t WordLength

Specifies the number of data bits transmitted or received in a frame. This parameter can be a value of UART Word Length.

uint32_t StopBits

Specifies the number of stop bits transmitted. This parameter can be a value of UART Number of Stop Bits.

uint32_t Parity

Specifies the parity mode. This parameter can be a value of UART Parity

备注

When parity is enabled, the computed parity is inserted at the MSB position of the transmitted data (9th bit when the word length is set to 9 data bits; 8th bit when the word length is set to 8 data bits).

uint32_t Mode

Specifies whether the Receive or Transmit mode is enabled or disabled. This parameter can be a value of UART Transfer Mode.

uint32_t HwFlowCtl

Specifies whether the hardware flow control mode is enabled or disabled. This parameter can be a value of UART Hardware Flow Control.

uint32_t OverSampling

Specifies whether the Over sampling 8 is enabled or disabled, to achieve higher speed (up to f_PCLK/8). This parameter can be a value of UART Over Sampling.

uint32_t OneBitSampling

Specifies whether a single sample or three samples’ majority vote is selected. Selecting the single sample method increases the receiver tolerance to clock deviations. This parameter can be a value of UART One Bit Sampling Method.

struct UART_AdvFeatureInitTypeDef
#include <bf0_hal_uart.h>

UART Advanced Features initalization structure definition.

Public Members

uint32_t AdvFeatureInit

Specifies which advanced UART features is initialized. Several Advanced Features may be initialized at the same time . This parameter can be a value of UART Advanced Feature Initialization Type.

uint32_t TxPinLevelInvert

Specifies whether the TX pin active level is inverted. This parameter can be a value of UART Advanced Feature TX Pin Active Level Inversion.

uint32_t RxPinLevelInvert

Specifies whether the RX pin active level is inverted. This parameter can be a value of UART Advanced Feature RX Pin Active Level Inversion.

uint32_t DataInvert

Specifies whether data are inverted (positive/direct logic vs negative/inverted logic). This parameter can be a value of UART Advanced Feature Binary Data Inversion.

uint32_t Swap

Specifies whether TX and RX pins are swapped. This parameter can be a value of UART Advanced Feature RX TX Pins Swap.

uint32_t OverrunDisable

Specifies whether the reception overrun detection is disabled. This parameter can be a value of UART Advanced Feature Overrun Disable.

uint32_t DMADisableonRxError

Specifies whether the DMA is disabled in case of reception error. This parameter can be a value of UART Advanced Feature DMA Disable On Rx Error.

uint32_t AutoBaudRateEnable

Specifies whether auto Baud rate detection is enabled. This parameter can be a value of UART Advanced Feature Auto BaudRate Enable

uint32_t AutoBaudRateMode

If auto Baud rate detection is enabled, specifies how the rate detection is carried out. This parameter can be a value of UART Advanced Feature AutoBaud Rate Mode.

uint32_t MSBFirst

Specifies whether MSB is sent first on UART line. This parameter can be a value of UART Advanced Feature MSB First.

struct __UART_HandleTypeDef
#include <bf0_hal_uart.h>

UART handle Structure definition.

Public Members

USART_TypeDef *Instance

UART registers base address

UART_InitTypeDef Init

UART communication parameters

UART_AdvFeatureInitTypeDef AdvancedInit

UART Advanced Features initialization parameters

uint8_t *pTxBuffPtr

Pointer to UART Tx transfer Buffer

uint16_t TxXferSize

UART Tx Transfer size

uint16_t TxXferCount

UART Tx Transfer Counter

uint8_t *pRxBuffPtr

Pointer to UART Rx transfer Buffer

uint16_t RxXferSize

UART Rx Transfer size

uint16_t RxXferCount

UART Rx Transfer Counter

uint16_t Mask

UART Rx RDR register mask

uint32_t FifoMode

Specifies if the FIFO mode is being used. This parameter can be a value of 1: enabled, 0: disabled

uint16_t NbRxDataToProcess

Number of data to process during RX ISR execution

uint16_t NbTxDataToProcess

Number of data to process during TX ISR execution

void (*RxISR)(struct __UART_HandleTypeDef *huart)

Function pointer on Rx IRQ handler

void (*TxISR)(struct __UART_HandleTypeDef *huart)

Function pointer on Tx IRQ handler

DMA_HandleTypeDef *hdmatx

UART Tx DMA Handle parameters

DMA_HandleTypeDef *hdmarx

UART Rx DMA Handle parameters

HAL_LockTypeDef Lock

Locking object

HAL_UART_StateTypeDef gState

UART state information related to global Handle management and also related to Tx operations. This parameter can be a value of HAL_UART_StateTypeDef

HAL_UART_StateTypeDef RxState

UART state information related to Rx operations. This parameter can be a value of HAL_UART_StateTypeDef

uint32_t ErrorCode

UART Error code