STM8S/A Standard Peripherals Firmware Library
|
Functions | |
void | UART1_ClearFlag (UART1_Flag_TypeDef UART1_FLAG) |
Clears the UART1 flags. | |
void | UART1_ClearITPendingBit (UART1_IT_TypeDef UART1_IT) |
Clears the UART1 pending flags. | |
void | UART1_Cmd (FunctionalState NewState) |
Enable the UART1 peripheral. | |
void | UART1_DeInit (void) |
Deinitializes the UART peripheral. | |
FlagStatus | UART1_GetFlagStatus (UART1_Flag_TypeDef UART1_FLAG) |
Checks whether the specified UART1 flag is set or not. | |
ITStatus | UART1_GetITStatus (UART1_IT_TypeDef UART1_IT) |
Checks whether the specified UART1 interrupt has occurred or not. | |
void | UART1_HalfDuplexCmd (FunctionalState NewState) |
Enables or disables the UART�s Half Duplex communication. | |
void | UART1_Init (uint32_t BaudRate, UART1_WordLength_TypeDef WordLength, UART1_StopBits_TypeDef StopBits, UART1_Parity_TypeDef Parity, UART1_SyncMode_TypeDef SyncMode, UART1_Mode_TypeDef Mode) |
Initializes the UART1 according to the specified parameters. | |
void | UART1_IrDACmd (FunctionalState NewState) |
Enables or disables the UART�s IrDA interface. | |
void | UART1_IrDAConfig (UART1_IrDAMode_TypeDef UART1_IrDAMode) |
Configures the UART�s IrDA interface. | |
void | UART1_ITConfig (UART1_IT_TypeDef UART1_IT, FunctionalState NewState) |
Enables or disables the specified USART interrupts. | |
void | UART1_LINBreakDetectionConfig (UART1_LINBreakDetectionLength_TypeDef UART1_LINBreakDetectionLength) |
Sets the UART1 LIN Break detection length. | |
void | UART1_LINCmd (FunctionalState NewState) |
Enables or disables the UART1�s LIN mode. | |
uint8_t | UART1_ReceiveData8 (void) |
Returns the most recent received data by the UART1 peripheral. | |
uint16_t | UART1_ReceiveData9 (void) |
Returns the most recent received data by the UART1 peripheral. | |
void | UART1_ReceiverWakeUpCmd (FunctionalState NewState) |
Determines if the UART1 is in mute mode or not. | |
void | UART1_SendBreak (void) |
Transmits break characters. | |
void | UART1_SendData8 (uint8_t Data) |
Transmits 8 bit data through the UART1 peripheral. | |
void | UART1_SendData9 (uint16_t Data) |
Transmits 9 bit data through the UART peripheral. | |
void | UART1_SetAddress (uint8_t UART1_Address) |
Sets the address of the UART1 node. | |
void | UART1_SetGuardTime (uint8_t UART1_GuardTime) |
Sets the specified UART guard time. | |
void | UART1_SetPrescaler (uint8_t UART1_Prescaler) |
Sets the system clock prescaler. | |
void | UART1_SmartCardCmd (FunctionalState NewState) |
Enables or disables the UART1 Smart Card mode. | |
void | UART1_SmartCardNACKCmd (FunctionalState NewState) |
Enables or disables NACK transmission. | |
void | UART1_WakeUpConfig (UART1_WakeUp_TypeDef UART1_WakeUp) |
Selects the UART1 WakeUp method. |
Function Documentation
void UART1_ClearFlag | ( | UART1_Flag_TypeDef | UART1_FLAG | ) |
Clears the UART1 flags.
- Parameters:
-
UART1_FLAG specifies the flag to clear This parameter can be any combination of the following values: - UART1_FLAG_LBDF: LIN Break detection flag.
- UART1_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 UART1_SR register (UART1_GetFlagStatus())followed by a read operation to UART1_DR register(UART1_ReceiveData8() or UART1_ReceiveData9()).
- RXNE flag can be also cleared by a read to the UART1_DR register (UART1_ReceiveData8()or UART1_ReceiveData9()).
- TC flag can be also cleared by software sequence: a read operation to UART1_SR register (UART1_GetFlagStatus()) followed by a write operation to UART1_DR register (UART1_SendData8() or UART1_SendData9()).
- TXE flag is cleared only by a write to the UART1_DR register (UART1_SendData8() or UART1_SendData9()).
- SBK flag is cleared during the stop bit of break.
- Return values:
-
None
Definition at line 646 of file stm8s_uart1.c.
References assert_param, IS_UART1_CLEAR_FLAG_OK, UART1_CR4_LBDF, UART1_FLAG_RXNE, and UART1_SR_RXNE.
void UART1_ClearITPendingBit | ( | UART1_IT_TypeDef | UART1_IT | ) |
Clears the UART1 pending flags.
- Parameters:
-
UART1_IT specifies the pending bit to clear This parameter can be one of the following values: - UART1_IT_LBDF: LIN Break detection interrupt
- UART1_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 UART1_SR register (UART1_GetITStatus()) followed by a read operation to UART1_DR register (UART1_ReceiveData8() or UART1_ReceiveData9()).
- RXNE pending bit can be also cleared by a read to the UART1_DR register (UART1_ReceiveData8() or UART1_ReceiveData9()).
- TC (Transmit complete) pending bit can be cleared by software sequence: a read operation to UART1_SR register (UART1_GetITStatus()) followed by a write operation to UART1_DR register (UART1_SendData8() or UART1_SendData9()).
- TXE pending bit is cleared only by a write to the UART1_DR register (UART1_SendData8() or UART1_SendData9()).
- Return values:
-
None
Definition at line 775 of file stm8s_uart1.c.
References assert_param, IS_UART1_CLEAR_IT_OK, UART1_CR4_LBDF, UART1_IT_RXNE, and UART1_SR_RXNE.
void UART1_Cmd | ( | FunctionalState | NewState | ) |
Enable the UART1 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 184 of file stm8s_uart1.c.
References DISABLE, and UART1_CR1_UARTD.
Referenced by main(), and UART1_Config().
void UART1_DeInit | ( | void | ) |
Deinitializes the UART peripheral.
- Parameters:
-
None
- Return values:
-
None
Definition at line 53 of file stm8s_uart1.c.
References UART1_BRR1_RESET_VALUE, UART1_BRR2_RESET_VALUE, UART1_CR1_RESET_VALUE, UART1_CR2_RESET_VALUE, UART1_CR3_RESET_VALUE, UART1_CR4_RESET_VALUE, UART1_CR5_RESET_VALUE, UART1_GTR_RESET_VALUE, and UART1_PSCR_RESET_VALUE.
Referenced by main(), UART1_Config(), and UART_Config().
FlagStatus UART1_GetFlagStatus | ( | UART1_Flag_TypeDef | UART1_FLAG | ) |
Checks whether the specified UART1 flag is set or not.
- Parameters:
-
UART1_FLAG specifies the flag to check. This parameter can be any of the UART1_Flag_TypeDef enumeration.
- Return values:
-
FlagStatus (SET or RESET)
Definition at line 568 of file stm8s_uart1.c.
References assert_param, IS_UART1_FLAG_OK, RESET, SET, UART1_FLAG_LBDF, and UART1_FLAG_SBK.
Referenced by main().
ITStatus UART1_GetITStatus | ( | UART1_IT_TypeDef | UART1_IT | ) |
Checks whether the specified UART1 interrupt has occurred or not.
- Parameters:
-
UART1_IT,: Specifies the UART1 interrupt pending bit to check. This parameter can be one of the following values: - UART1_IT_LBDF: LIN Break detection interrupt
- UART1_IT_TXE: Tansmit Data Register empty interrupt
- UART1_IT_TC: Transmission complete interrupt
- UART1_IT_RXNE: Receive Data register not empty interrupt
- UART1_IT_IDLE: Idle line detection interrupt
- UART1_IT_OR: OverRun Error interrupt
- UART1_IT_PE: Parity Error interrupt
- Return values:
-
The new state of UART1_IT (SET or RESET).
Definition at line 675 of file stm8s_uart1.c.
References assert_param, IS_UART1_GET_IT_OK, RESET, SET, UART1_IT_LBDF, and UART1_IT_PE.
void UART1_HalfDuplexCmd | ( | FunctionalState | NewState | ) |
Enables or disables the UART�s Half Duplex communication.
- Parameters:
-
NewState new state of the UART Communication. This parameter can be: ENABLE or DISABLE.
- Return values:
-
None
< UART1 Half Duplex Enable
< UART1 Half Duplex Disable
Definition at line 265 of file stm8s_uart1.c.
References assert_param, DISABLE, IS_FUNCTIONALSTATE_OK, and UART1_CR5_HDSEL.
Referenced by UART_Config().
void UART1_Init | ( | uint32_t | BaudRate, |
UART1_WordLength_TypeDef | WordLength, | ||
UART1_StopBits_TypeDef | StopBits, | ||
UART1_Parity_TypeDef | Parity, | ||
UART1_SyncMode_TypeDef | SyncMode, | ||
UART1_Mode_TypeDef | Mode | ||
) |
Initializes the UART1 according to the specified parameters.
- Note:
- Configure in Push Pull or Open Drain mode the Tx pin by setting the correct I/O Port register according the product package and line configuration
- Parameters:
-
BaudRate,: The baudrate. WordLength : This parameter can be any of the UART1_WordLength_TypeDef enumeration. StopBits,: This parameter can be any of the UART1_StopBits_TypeDef enumeration. Parity,: This parameter can be any of the UART1_Parity_TypeDef enumeration. SyncMode,: This parameter can be any of the UART1_SyncMode_TypeDef values. Mode,: This parameter can be any of the UART1_Mode_TypeDef values
- Return values:
-
None
Definition at line 90 of file stm8s_uart1.c.
References assert_param, CLK_GetClockFreq(), IS_UART1_BAUDRATE_OK, IS_UART1_MODE_OK, IS_UART1_PARITY_OK, IS_UART1_STOPBITS_OK, IS_UART1_SYNCMODE_OK, IS_UART1_WORDLENGTH_OK, UART1_BRR1_DIVM, UART1_BRR2_DIVF, UART1_BRR2_DIVM, UART1_CR1_M, UART1_CR1_PCEN, UART1_CR1_PS, UART1_CR2_REN, UART1_CR2_TEN, UART1_CR3_CKEN, UART1_CR3_CPHA, UART1_CR3_CPOL, UART1_CR3_LBCL, UART1_CR3_STOP, UART1_MODE_RX_ENABLE, UART1_MODE_TX_ENABLE, and UART1_SYNCMODE_CLOCK_DISABLE.
Referenced by main(), UART1_Config(), and UART_Config().
void UART1_IrDACmd | ( | FunctionalState | NewState | ) |
Enables or disables the UART�s IrDA interface.
- Parameters:
-
NewState new state of the IrDA mode. This parameter can be: ENABLE or DISABLE.
- Return values:
-
None
Definition at line 305 of file stm8s_uart1.c.
References assert_param, DISABLE, IS_FUNCTIONALSTATE_OK, and UART1_CR5_IREN.
Referenced by UART1_Config().
void UART1_IrDAConfig | ( | UART1_IrDAMode_TypeDef | UART1_IrDAMode | ) |
Configures the UART�s IrDA interface.
- Parameters:
-
UART1_IrDAMode specifies the IrDA mode. This parameter can be any of the UART1_IrDAMode_TypeDef values.
- Return values:
-
None
Definition at line 285 of file stm8s_uart1.c.
References assert_param, IS_UART1_IRDAMODE_OK, UART1_CR5_IRLP, and UART1_IRDAMODE_NORMAL.
Referenced by UART1_Config().
void UART1_ITConfig | ( | UART1_IT_TypeDef | UART1_IT, |
FunctionalState | NewState | ||
) |
Enables or disables the specified USART interrupts.
- Parameters:
-
UART1_IT specifies the USART interrupt sources to be enabled or disabled. This parameter can be one of the following values: - UART1_IT_TXE: Tansmit Data Register empty interrupt
- UART1_IT_TC: Transmission complete interrupt
- UART1_IT_RXNE_OR: Receive Data register not empty and Overrun interrupt
- UART1_IT_IDLE: Idle line detection interrupt
- USRT1_IT_ERR: Error interrupt
NewState new state of the specified USART interrupts. This parameter can be: ENABLE or DISABLE.
- Return values:
-
None
< Enable the Interrupt bits according to UART1_IT mask
< Disable the interrupt bits according to UART1_IT mask
Definition at line 211 of file stm8s_uart1.c.
References assert_param, DISABLE, IS_FUNCTIONALSTATE_OK, and IS_UART1_CONFIG_IT_OK.
Referenced by main(), UART1_Config(), and UART_Config().
void UART1_LINBreakDetectionConfig | ( | UART1_LINBreakDetectionLength_TypeDef | UART1_LINBreakDetectionLength | ) |
Sets the UART1 LIN Break detection length.
- Parameters:
-
UART1_LINBreakDetectionLength specifies the LIN break detection length. This parameter can be any of the UART1_LINBreakDetectionLength_TypeDef values.
- Return values:
-
None
Definition at line 329 of file stm8s_uart1.c.
References assert_param, IS_UART1_LINBREAKDETECTIONLENGTH_OK, UART1_CR4_LBDL, and UART1_LINBREAKDETECTIONLENGTH_10BITS.
void UART1_LINCmd | ( | FunctionalState | NewState | ) |
Enables or disables the UART1�s LIN mode.
- Parameters:
-
NewState is new state of the UART1 LIN mode. This parameter can be: ENABLE or DISABLE.
- Return values:
-
None
Definition at line 349 of file stm8s_uart1.c.
References assert_param, DISABLE, IS_FUNCTIONALSTATE_OK, and UART1_CR3_LINEN.
uint8_t UART1_ReceiveData8 | ( | void | ) |
Returns the most recent received data by the UART1 peripheral.
- Parameters:
-
None
- Return values:
-
The received data.
Definition at line 451 of file stm8s_uart1.c.
Referenced by main().
uint16_t UART1_ReceiveData9 | ( | void | ) |
Returns the most recent received data by the UART1 peripheral.
- Parameters:
-
None
- Return values:
-
The received data.
Definition at line 461 of file stm8s_uart1.c.
References UART1_CR1_R8.
void UART1_ReceiverWakeUpCmd | ( | FunctionalState | NewState | ) |
Determines if the UART1 is in mute mode or not.
- Parameters:
-
NewState,: new state of the UART1 mode. This parameter can be: ENABLE or DISABLE.
- Return values:
-
None
Definition at line 430 of file stm8s_uart1.c.
References assert_param, DISABLE, IS_FUNCTIONALSTATE_OK, and UART1_CR2_RWU.
void UART1_SendBreak | ( | void | ) |
Transmits break characters.
- Parameters:
-
None
- Return values:
-
None
Definition at line 501 of file stm8s_uart1.c.
References UART1_CR2_SBK.
void UART1_SendData8 | ( | uint8_t | Data | ) |
Transmits 8 bit data through the UART1 peripheral.
- Parameters:
-
Data,: The data to transmit.
- Return values:
-
None
Definition at line 474 of file stm8s_uart1.c.
Referenced by main().
void UART1_SendData9 | ( | uint16_t | Data | ) |
Transmits 9 bit data through the UART peripheral.
- Parameters:
-
Data : The data to transmit. This parameter should be lower than 0x1FF.
- Return values:
-
None
< Clear the transmit data bit 8 [8]
< Write the transmit data bit [8]
< Write the transmit data bit [0:7]
Definition at line 486 of file stm8s_uart1.c.
References UART1_CR1_T8.
Referenced by main().
void UART1_SetAddress | ( | uint8_t | UART1_Address | ) |
Sets the address of the UART1 node.
- Parameters:
-
UART1_Address,: Indicates the address of the UART1 node.
- Return values:
-
None
Definition at line 511 of file stm8s_uart1.c.
References assert_param, IS_UART1_ADDRESS_OK, and UART1_CR4_ADD.
Referenced by UART_Config().
void UART1_SetGuardTime | ( | uint8_t | UART1_GuardTime | ) |
Sets the specified UART guard time.
- Note:
- SmartCard Mode should be Enabled
- Parameters:
-
UART1_GuardTime,: specifies the guard time.
- Return values:
-
None
Definition at line 528 of file stm8s_uart1.c.
Referenced by main().
void UART1_SetPrescaler | ( | uint8_t | UART1_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:
-
UART1_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) multiplied 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 556 of file stm8s_uart1.c.
Referenced by main(), and UART1_Config().
void UART1_SmartCardCmd | ( | FunctionalState | NewState | ) |
Enables or disables the UART1 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 371 of file stm8s_uart1.c.
References assert_param, DISABLE, IS_FUNCTIONALSTATE_OK, and UART1_CR5_SCEN.
Referenced by main().
void UART1_SmartCardNACKCmd | ( | FunctionalState | NewState | ) |
Enables or disables NACK transmission.
- Note:
- This function is valid only for UART1 because is related to SmartCard mode.
- Parameters:
-
NewState,: new state of the Smart Card mode. This parameter can be: ENABLE or DISABLE.
- Return values:
-
None
Definition at line 394 of file stm8s_uart1.c.
References assert_param, DISABLE, IS_FUNCTIONALSTATE_OK, and UART1_CR5_NACK.
Referenced by main().
void UART1_WakeUpConfig | ( | UART1_WakeUp_TypeDef | UART1_WakeUp | ) |
Selects the UART1 WakeUp method.
- Parameters:
-
UART1_WakeUp,: specifies the UART1 wakeup method. This parameter can be any of the UART1_WakeUp_TypeDef values.
- Return values:
-
None
Definition at line 416 of file stm8s_uart1.c.
References assert_param, IS_UART1_WAKEUP_OK, and UART1_CR1_WAKE.