STM8S/A Standard Peripherals Firmware Library: UART2_Exported_Functions

STM8S/A

STM8S/A Standard Peripherals Firmware Library
UART2_Exported_Functions

Functions

void UART2_ClearFlag (UART2_Flag_TypeDef UART2_FLAG)
 Clears the UART2 flags.
void UART2_ClearITPendingBit (UART2_IT_TypeDef UART2_IT)
 Clears the UART2 pending flags.
void UART2_Cmd (FunctionalState NewState)
 Enable the UART2 peripheral.
void UART2_DeInit (void)
 Deinitializes the UART peripheral.
FlagStatus UART2_GetFlagStatus (UART2_Flag_TypeDef UART2_FLAG)
 Checks whether the specified UART2 flag is set or not.
ITStatus UART2_GetITStatus (UART2_IT_TypeDef UART2_IT)
 Checks whether the specified UART2 interrupt has occurred or not.
void UART2_HalfDuplexCmd (FunctionalState NewState)
void UART2_Init (uint32_t BaudRate, UART2_WordLength_TypeDef WordLength, UART2_StopBits_TypeDef StopBits, UART2_Parity_TypeDef Parity, UART2_SyncMode_TypeDef SyncMode, UART2_Mode_TypeDef Mode)
 Initializes the UART2 according to the specified parameters.
void UART2_IrDACmd (FunctionalState NewState)
 Enables or disables the UART2�s IrDA interface.
void UART2_IrDAConfig (UART2_IrDAMode_TypeDef UART2_IrDAMode)
 Configures the UART2�s IrDA interface.
void UART2_ITConfig (UART2_IT_TypeDef UART2_IT, FunctionalState NewState)
 Enables or disables the specified UART2 interrupts.
void UART2_LINBreakDetectionConfig (UART2_LINBreakDetectionLength_TypeDef UART2_LINBreakDetectionLength)
 Sets the UART2 LIN Break detection length.
void UART2_LINCmd (FunctionalState NewState)
 Enables or disables the UART2 LIN mode.
void UART2_LINConfig (UART2_LinMode_TypeDef UART2_Mode, UART2_LinAutosync_TypeDef UART2_Autosync, UART2_LinDivUp_TypeDef UART2_DivUp)
 Configure the UART2 peripheral.
uint8_t UART2_ReceiveData8 (void)
 Returns the most recent received data by the UART2 peripheral.
uint16_t UART2_ReceiveData9 (void)
 Returns the most recent received data by the UART2 peripheral.
void UART2_ReceiverWakeUpCmd (FunctionalState NewState)
 Determines if the UART2 is in mute mode or not.
void UART2_SendBreak (void)
 Transmits break characters.
void UART2_SendData8 (uint8_t Data)
 Transmits 8 bit data through the UART2 peripheral.
void UART2_SendData9 (uint16_t Data)
 Transmits 9 bit data through the UART2 peripheral.
void UART2_SetAddress (uint8_t UART2_Address)
 Sets the address of the UART2 node.
void UART2_SetGuardTime (uint8_t UART2_GuardTime)
 Sets the specified UART2 guard time.
void UART2_SetPrescaler (uint8_t UART2_Prescaler)
 Sets the system clock prescaler.
void UART2_SmartCardCmd (FunctionalState NewState)
 Enables or disables the UART2 Smart Card mode.
void UART2_SmartCardNACKCmd (FunctionalState NewState)
 Enables or disables NACK transmission.
void UART2_WakeUpConfig (UART2_WakeUp_TypeDef UART2_WakeUp)
 Selects the UART2 WakeUp method.

Function Documentation

void UART2_ClearFlag ( UART2_Flag_TypeDef  UART2_FLAG)

Clears the UART2 flags.

Parameters:
UART2_FLAGspecifies the flag to clear This parameter can be any combination of the following values:
  • UART2_FLAG_LBDF: LIN Break detection flag.
  • UART2_FLAG_LHDF: LIN Header detection flag.
  • UART2_FLAG_LSF: LIN synchrone field flag.
  • UART2_FLAG_RXNE: Receive data register not empty flag.
Note:
:
  • PE (Parity error), FE (Framing error), NE (Noise error), OR (OverRun error) and IDLE (Idle line detected) flags are cleared by software sequence: a read operation to UART2_SR register (UART2_GetFlagStatus())followed by a read operation to UART2_DR register(UART2_ReceiveData8() or UART2_ReceiveData9()).
  • SBK flag is cleared during the stop bit of break.
    Return values:
    None

Definition at line 699 of file stm8s_uart2.c.

References assert_param, IS_UART2_CLEAR_FLAG_OK, UART2_CR4_LBDF, UART2_CR6_LHDF, UART2_CR6_LSF, UART2_FLAG_LBDF, UART2_FLAG_LHDF, UART2_FLAG_RXNE, and UART2_SR_RXNE.

void UART2_ClearITPendingBit ( UART2_IT_TypeDef  UART2_IT)

Clears the UART2 pending flags.

Parameters:
UART2_ITspecifies the pending bit to clear This parameter can be one of the following values:
  • UART2_IT_LBDF: LIN Break detection interrupt
  • UART2_IT_LHDF: LIN Header detection interrupt
  • UART2_IT_RXNE: Receive Data register not empty interrupt.
Note:
  • PE (Parity error), FE (Framing error), NE (Noise error), OR (OverRun error) and IDLE (Idle line detected) pending bits are cleared by software sequence: a read operation to UART2_SR register (UART2_GetITStatus()) followed by a read operation to UART2_DR register (UART2_ReceiveData8() or UART2_ReceiveData9()).

Definition at line 852 of file stm8s_uart2.c.

References assert_param, IS_UART2_CLEAR_IT_OK, UART2_CR4_LBDF, UART2_CR6_LHDF, UART2_IT_LBDF, UART2_IT_RXNE, and UART2_SR_RXNE.

void UART2_Cmd ( FunctionalState  NewState)

Enable the UART2 peripheral.

Parameters:
NewState: The new state of the UART Communication. This parameter can be any of the FunctionalState enumeration.
Return values:
None

Definition at line 181 of file stm8s_uart2.c.

References DISABLE, and UART2_CR1_UARTD.

void UART2_DeInit ( void  )

Deinitializes the UART peripheral.

Parameters:
None
Return values:
None

Definition at line 53 of file stm8s_uart2.c.

References UART2_BRR1_RESET_VALUE, UART2_BRR2_RESET_VALUE, UART2_CR1_RESET_VALUE, UART2_CR2_RESET_VALUE, UART2_CR3_RESET_VALUE, UART2_CR4_RESET_VALUE, UART2_CR5_RESET_VALUE, and UART2_CR6_RESET_VALUE.

FlagStatus UART2_GetFlagStatus ( UART2_Flag_TypeDef  UART2_FLAG)

Checks whether the specified UART2 flag is set or not.

Parameters:
UART2_FLAGspecifies the flag to check. This parameter can be any of the UART2_Flag_TypeDef enumeration.
Return values:
FlagStatus(SET or RESET)

Definition at line 606 of file stm8s_uart2.c.

References assert_param, IS_UART2_FLAG_OK, RESET, SET, UART2_FLAG_LBDF, UART2_FLAG_LHDF, UART2_FLAG_LSF, and UART2_FLAG_SBK.

ITStatus UART2_GetITStatus ( UART2_IT_TypeDef  UART2_IT)

Checks whether the specified UART2 interrupt has occurred or not.

Parameters:
UART2_IT,:Specifies the UART2 interrupt pending bit to check. This parameter can be one of the following values:
  • UART2_IT_LBDF: LIN Break detection interrupt
  • UART2_IT_TXE: Tansmit Data Register empty interrupt
  • UART2_IT_TC: Transmission complete interrupt
  • UART2_IT_RXNE: Receive Data register not empty interrupt
  • UART2_IT_IDLE: Idle line detection interrupt
  • UART2_IT_OR: OverRun Error interrupt
  • UART2_IT_PE: Parity Error interrupt
Return values:
Thestate of UART2_IT (SET or RESET).

Definition at line 738 of file stm8s_uart2.c.

References assert_param, IS_UART2_GET_IT_OK, RESET, SET, UART2_IT_LBDF, UART2_IT_LHDF, and UART2_IT_PE.

void UART2_HalfDuplexCmd ( FunctionalState  NewState)
void UART2_Init ( uint32_t  BaudRate,
UART2_WordLength_TypeDef  WordLength,
UART2_StopBits_TypeDef  StopBits,
UART2_Parity_TypeDef  Parity,
UART2_SyncMode_TypeDef  SyncMode,
UART2_Mode_TypeDef  Mode 
)

Initializes the UART2 according to the specified parameters.

Parameters:
BaudRate,:The baudrate.
WordLength: This parameter can be any of the UART2_WordLength_TypeDef enumeration.
StopBits,:This parameter can be any of the UART2_StopBits_TypeDef enumeration.
Parity,:This parameter can be any of the UART2_Parity_TypeDef enumeration.
SyncMode,:This parameter can be any of the UART2_SyncMode_TypeDef values.
Mode,:This parameter can be any of the UART2_Mode_TypeDef values
Return values:
None

Definition at line 85 of file stm8s_uart2.c.

References assert_param, CLK_GetClockFreq(), IS_UART2_BAUDRATE_OK, IS_UART2_MODE_OK, IS_UART2_PARITY_OK, IS_UART2_STOPBITS_OK, IS_UART2_SYNCMODE_OK, IS_UART2_WORDLENGTH_OK, UART2_BRR1_DIVM, UART2_BRR2_DIVF, UART2_BRR2_DIVM, UART2_CR1_M, UART2_CR1_PCEN, UART2_CR1_PS, UART2_CR2_REN, UART2_CR2_TEN, UART2_CR3_CKEN, UART2_CR3_CPHA, UART2_CR3_CPOL, UART2_CR3_LBCL, UART2_CR3_STOP, UART2_MODE_RX_ENABLE, UART2_MODE_TX_ENABLE, and UART2_SYNCMODE_CLOCK_DISABLE.

void UART2_IrDACmd ( FunctionalState  NewState)

Enables or disables the UART2�s IrDA interface.

Parameters:
NewStatenew state of the IrDA mode. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 292 of file stm8s_uart2.c.

References assert_param, DISABLE, IS_FUNCTIONALSTATE_OK, and UART2_CR5_IREN.

void UART2_IrDAConfig ( UART2_IrDAMode_TypeDef  UART2_IrDAMode)

Configures the UART2�s IrDA interface.

Parameters:
UART2_IrDAModespecifies the IrDA mode. This parameter can be any of the UART2_IrDAMode_TypeDef values.
Return values:
None

Definition at line 272 of file stm8s_uart2.c.

References assert_param, IS_UART2_IRDAMODE_OK, UART2_CR5_IRLP, and UART2_IRDAMODE_NORMAL.

void UART2_ITConfig ( UART2_IT_TypeDef  UART2_IT,
FunctionalState  NewState 
)

Enables or disables the specified UART2 interrupts.

Parameters:
UART2_ITspecifies the UART2 interrupt sources to be enabled or disabled. This parameter can be one of the following values:
  • UART2_IT_LBDF: LIN Break detection interrupt
  • UART2_IT_LHDF: LIN Break detection interrupt
  • UART2_IT_TXE: Tansmit Data Register empty interrupt
  • UART2_IT_TC: Transmission complete interrupt
  • UART2_IT_RXNE_OR: Receive Data register not empty/Over run error interrupt
  • UART2_IT_IDLE: Idle line detection interrupt
  • UART2_IT_PE: Parity Error interrupt
NewStatenew state of the specified UART2 interrupts. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 210 of file stm8s_uart2.c.

References assert_param, DISABLE, IS_FUNCTIONALSTATE_OK, and IS_UART2_CONFIG_IT_OK.

void UART2_LINBreakDetectionConfig ( UART2_LINBreakDetectionLength_TypeDef  UART2_LINBreakDetectionLength)

Sets the UART2 LIN Break detection length.

Parameters:
UART2_LINBreakDetectionLengthspecifies the LIN break detection length. This parameter can be any of the UART2_LINBreakDetectionLength_TypeDef values.
Return values:
None

Definition at line 316 of file stm8s_uart2.c.

References assert_param, IS_UART2_LINBREAKDETECTIONLENGTH_OK, UART2_CR4_LBDL, and UART2_LINBREAKDETECTIONLENGTH_10BITS.

void UART2_LINCmd ( FunctionalState  NewState)

Enables or disables the UART2 LIN mode.

Parameters:
NewStateis new state of the UART2 LIN mode. This parameter can be ENABLE or DISABLE
Return values:
None

Definition at line 384 of file stm8s_uart2.c.

References assert_param, DISABLE, IS_FUNCTIONALSTATE_OK, and UART2_CR3_LINEN.

void UART2_LINConfig ( UART2_LinMode_TypeDef  UART2_Mode,
UART2_LinAutosync_TypeDef  UART2_Autosync,
UART2_LinDivUp_TypeDef  UART2_DivUp 
)

Configure the UART2 peripheral.

Parameters:
UART2_Modespecifies the LIN mode. This parameter can be any of the UART2_LinMode_TypeDef values.
UART2_Autosyncspecifies the LIN automatic resynchronization mode. This parameter can be any of the UART2_LinAutosync_TypeDef values.
UART2_DivUpspecifies the LIN divider update method. This parameter can be any of the UART2_LinDivUp_TypeDef values.
Return values:
None

Definition at line 341 of file stm8s_uart2.c.

References assert_param, IS_UART2_AUTOSYNC_OK, IS_UART2_DIVUP_OK, IS_UART2_SLAVE_OK, UART2_CR6_LASE, UART2_CR6_LDUM, UART2_CR6_LSLV, UART2_LIN_AUTOSYNC_DISABLE, UART2_LIN_DIVUP_LBRR1, and UART2_LIN_MODE_MASTER.

uint8_t UART2_ReceiveData8 ( void  )

Returns the most recent received data by the UART2 peripheral.

Parameters:
None
Return values:
ReceivedData

Definition at line 487 of file stm8s_uart2.c.

uint16_t UART2_ReceiveData9 ( void  )

Returns the most recent received data by the UART2 peripheral.

Parameters:
None
Return values:
ReceivedData

Definition at line 497 of file stm8s_uart2.c.

References UART2_CR1_R8.

void UART2_ReceiverWakeUpCmd ( FunctionalState  NewState)

Determines if the UART2 is in mute mode or not.

Parameters:
NewState,:new state of the UART2 mode. This parameter can be ENABLE or DISABLE
Return values:
None

Definition at line 466 of file stm8s_uart2.c.

References assert_param, DISABLE, IS_FUNCTIONALSTATE_OK, and UART2_CR2_RWU.

void UART2_SendBreak ( void  )

Transmits break characters.

Parameters:
None
Return values:
None

Definition at line 539 of file stm8s_uart2.c.

References UART2_CR2_SBK.

void UART2_SendData8 ( uint8_t  Data)

Transmits 8 bit data through the UART2 peripheral.

Parameters:
Data,:the data to transmit.
Return values:
None

Definition at line 511 of file stm8s_uart2.c.

void UART2_SendData9 ( uint16_t  Data)

Transmits 9 bit data through the UART2 peripheral.

Parameters:
Data,:the data to transmit.
Return values:
None

Definition at line 522 of file stm8s_uart2.c.

References UART2_CR1_T8.

void UART2_SetAddress ( uint8_t  UART2_Address)

Sets the address of the UART2 node.

Parameters:
UART2_Address,:Indicates the address of the UART2 node.
Return values:
None

Definition at line 549 of file stm8s_uart2.c.

References assert_param, IS_UART2_ADDRESS_OK, and UART2_CR4_ADD.

void UART2_SetGuardTime ( uint8_t  UART2_GuardTime)

Sets the specified UART2 guard time.

Note:
SmartCard Mode should be Enabled
Parameters:
UART2_GuardTime,:specifies the guard time.
Return values:
None

Definition at line 566 of file stm8s_uart2.c.

void UART2_SetPrescaler ( uint8_t  UART2_Prescaler)

Sets the system clock prescaler.

Note:
IrDA Low Power mode or smartcard mode should be enabled
This function is related to SmartCard and IrDa mode.
Parameters:
UART2_Prescaler,:specifies the prescaler clock. This parameter can be one of the following values:
IrDA Low Power Mode
The clock source is divided by the value given in the register (8 bits)
  • 0000 0000 Reserved
  • 0000 0001 divides the clock source by 1
  • 0000 0010 divides the clock source by 2
  • ...
Smart Card Mode
The clock source is divided by the value given in the register (5 significant bits) multiped by 2
  • 0 0000 Reserved
  • 0 0001 divides the clock source by 2
  • 0 0010 divides the clock source by 4
  • 0 0011 divides the clock source by 6
  • ...
Return values:
None

Definition at line 594 of file stm8s_uart2.c.

void UART2_SmartCardCmd ( FunctionalState  NewState)

Enables or disables the UART2 Smart Card mode.

Parameters:
NewState,:new state of the Smart Card mode. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 406 of file stm8s_uart2.c.

References assert_param, DISABLE, IS_FUNCTIONALSTATE_OK, and UART2_CR5_SCEN.

void UART2_SmartCardNACKCmd ( FunctionalState  NewState)

Enables or disables NACK transmission.

Parameters:
NewState,:new state of the Smart Card mode. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 429 of file stm8s_uart2.c.

References assert_param, DISABLE, IS_FUNCTIONALSTATE_OK, and UART2_CR5_NACK.

void UART2_WakeUpConfig ( UART2_WakeUp_TypeDef  UART2_WakeUp)

Selects the UART2 WakeUp method.

Parameters:
UART2_WakeUp,:specifies the UART2 wakeup method. This parameter can be any of the UART2_WakeUp_TypeDef values.
Return values:
None

Definition at line 452 of file stm8s_uart2.c.

References assert_param, IS_UART2_WAKEUP_OK, and UART2_CR1_WAKE.

STM8 Standard Peripherals Library: Footer

 

 

 

      For complete documentation on STM8 8-bit Microcontrollers platform visit www.st.com