STM8L15x Standard Peripherals Drivers
|
USART driver modules. More...
Modules | |
USART_Exported_Types | |
USART_Private_Functions | |
Functions | |
void | USART_ClearFlag (USART_TypeDef *USARTx, USART_FLAG_TypeDef USART_FLAG) |
Clears the USARTx's pending flags. | |
void | USART_ClearITPendingBit (USART_TypeDef *USARTx, USART_IT_TypeDef USART_IT) |
Clears the USARTx�s interrupt pending bits. | |
void | USART_ClockInit (USART_TypeDef *USARTx, USART_Clock_TypeDef USART_Clock, USART_CPOL_TypeDef USART_CPOL, USART_CPHA_TypeDef USART_CPHA, USART_LastBit_TypeDef USART_LastBit) |
Initializes the USART Clock according to the specified parameters. | |
void | USART_Cmd (USART_TypeDef *USARTx, FunctionalState NewState) |
Enable the USART peripheral. | |
void | USART_DeInit (USART_TypeDef *USARTx) |
Deinitializes the USART peripheral. | |
void | USART_DMACmd (USART_TypeDef *USARTx, USART_DMAReq_TypeDef USART_DMAReq, FunctionalState NewState) |
Enables or disables the USART DMA interface. | |
FlagStatus | USART_GetFlagStatus (USART_TypeDef *USARTx, USART_FLAG_TypeDef USART_FLAG) |
Checks whether the specified USART flag is set or not. | |
ITStatus | USART_GetITStatus (USART_TypeDef *USARTx, USART_IT_TypeDef USART_IT) |
Checks whether the specified USART interrupt has occurred or not. | |
void | USART_HalfDuplexCmd (USART_TypeDef *USARTx, FunctionalState NewState) |
Enables or disables the USART�s Half Duplex communication. | |
void | USART_Init (USART_TypeDef *USARTx, uint32_t BaudRate, USART_WordLength_TypeDef USART_WordLength, USART_StopBits_TypeDef USART_StopBits, USART_Parity_TypeDef USART_Parity, USART_Mode_TypeDef USART_Mode) |
Initializes the USART according to the specified parameters. | |
void | USART_IrDACmd (USART_TypeDef *USARTx, FunctionalState NewState) |
Enables or disables the USART�s IrDA interface. | |
void | USART_IrDAConfig (USART_TypeDef *USARTx, USART_IrDAMode_TypeDef USART_IrDAMode) |
Configures the USART�s IrDA interface. | |
void | USART_ITConfig (USART_TypeDef *USARTx, USART_IT_TypeDef USART_IT, FunctionalState NewState) |
Enables or disables the specified USART interrupts. | |
uint8_t | USART_ReceiveData8 (USART_TypeDef *USARTx) |
Returns the most recent received data by the USART peripheral. | |
uint16_t | USART_ReceiveData9 (USART_TypeDef *USARTx) |
Returns the most recent received data by the USART peripheral. | |
void | USART_ReceiverWakeUpCmd (USART_TypeDef *USARTx, FunctionalState NewState) |
Determines if the USART is in mute mode or not. | |
void | USART_SendBreak (USART_TypeDef *USARTx) |
Transmits break characters. | |
void | USART_SendData8 (USART_TypeDef *USARTx, uint8_t Data) |
Transmits 8 bit data through the USART peripheral. | |
void | USART_SendData9 (USART_TypeDef *USARTx, uint16_t Data) |
Transmits 9 bit data through the USART peripheral. | |
void | USART_SetAddress (USART_TypeDef *USARTx, uint8_t USART_Address) |
Sets the address of the USART node. | |
void | USART_SetGuardTime (USART_TypeDef *USARTx, uint8_t USART_GuardTime) |
Sets the specified USART guard time. | |
void | USART_SetPrescaler (USART_TypeDef *USARTx, uint8_t USART_Prescaler) |
Sets the system clock prescaler. | |
void | USART_SmartCardCmd (USART_TypeDef *USARTx, FunctionalState NewState) |
Enables or disables the USART Smart Card mode. | |
void | USART_SmartCardNACKCmd (USART_TypeDef *USARTx, FunctionalState NewState) |
Enables or disables NACK transmission. | |
void | USART_WakeUpConfig (USART_TypeDef *USARTx, USART_WakeUp_TypeDef USART_WakeUp) |
Selects the USART WakeUp method. | |
#define | IS_USART_BAUDRATE(NUM) ((NUM) <= (uint32_t)625000) |
| |
#define | USART_ADDRESS_MAX ((uint8_t)16) |
#define | IS_USART_ADDRESS(address) ((address) < USART_ADDRESS_MAX) |
#define | USART_DATA_9BITS_MAX ((uint16_t)0x1FF) |
#define | IS_USART_DATA_9BITS(DATA) ((DATA) < USART_DATA_9BITS_MAX) |
Detailed Description
USART driver modules.
Define Documentation
#define IS_USART_ADDRESS | ( | address | ) | ((address) < USART_ADDRESS_MAX) |
Definition at line 317 of file stm8l15x_usart.h.
Referenced by USART_SetAddress().
#define IS_USART_BAUDRATE | ( | NUM | ) | ((NUM) <= (uint32_t)625000) |
Definition at line 314 of file stm8l15x_usart.h.
Referenced by USART_Init().
#define IS_USART_DATA_9BITS | ( | DATA | ) | ((DATA) < USART_DATA_9BITS_MAX) |
Definition at line 320 of file stm8l15x_usart.h.
Referenced by USART_SendData9().
#define USART_ADDRESS_MAX ((uint8_t)16) |
Definition at line 316 of file stm8l15x_usart.h.
#define USART_DATA_9BITS_MAX ((uint16_t)0x1FF) |
Definition at line 319 of file stm8l15x_usart.h.
Function Documentation
void USART_ClearFlag | ( | USART_TypeDef * | USARTx, |
USART_FLAG_TypeDef | USART_FLAG | ||
) |
Clears the USARTx's pending flags.
- 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 USART_SR register (USART_GetFlagStatus())followed by a read operation to USART_DR register(USART_ReceiveData8() or USART_ReceiveData9()).
- RXNE flag can be also cleared by a read to the USART_DR register (USART_ReceiveData8()or USART_ReceiveData9()).
- TC flag can be also cleared by software sequence: a read operation to USART_SR register (USART_GetFlagStatus()) followed by a write operation to USART_DR register (USART_SendData8() or USART_SendData9()).
- TXE flag is cleared only by a write to the USART_DR register (USART_SendData8() or USART_SendData9()).
- SBK flag is cleared during the stop bit of break.
Definition at line 1054 of file stm8l15x_usart.c.
References IS_USART_CLEAR_FLAG, and USART_struct::SR.
void USART_ClearITPendingBit | ( | USART_TypeDef * | USARTx, |
USART_IT_TypeDef | USART_IT | ||
) |
Clears the USARTx�s interrupt pending bits.
- 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 USART_SR register (USART_GetITStatus()) followed by a read operation to USART_DR register (USART_ReceiveData8() or USART_ReceiveData9()).
- RXNE pending bit can be also cleared by a read to the USART_DR register (USART_ReceiveData8() or USART_ReceiveData9()).
- TC (Transmit complete) pending bit can be also cleared by software sequence: a read operation to USART_SR register (USART_GetITStatus()) followed by a write operation to USART_DR register (USART_SendData8() or USART_SendData9()).
- TXE pending bit is cleared only by a write to the USART_DR register (USART_SendData8() or USART_SendData9()).
Definition at line 1178 of file stm8l15x_usart.c.
References IS_USART_CLEAR_IT, and USART_struct::SR.
void USART_ClockInit | ( | USART_TypeDef * | USARTx, |
USART_Clock_TypeDef | USART_Clock, | ||
USART_CPOL_TypeDef | USART_CPOL, | ||
USART_CPHA_TypeDef | USART_CPHA, | ||
USART_LastBit_TypeDef | USART_LastBit | ||
) |
Initializes the USART Clock according to the specified parameters.
Definition at line 258 of file stm8l15x_usart.c.
References USART_struct::CR3, IS_USART_CLOCK, IS_USART_CPHA, IS_USART_CPOL, IS_USART_LASTBIT, USART_Clock_Disable, USART_CR3_CLKEN, USART_CR3_CPHA, USART_CR3_CPOL, and USART_CR3_LBCL.
void USART_Cmd | ( | USART_TypeDef * | USARTx, |
FunctionalState | NewState | ||
) |
Enable the USART peripheral.
< USART Enable
< USART Disable (for low power consumption)
Definition at line 290 of file stm8l15x_usart.c.
References USART_struct::CR1, DISABLE, and USART_CR1_USARTD.
void USART_DeInit | ( | USART_TypeDef * | USARTx | ) |
Deinitializes the USART peripheral.
Definition at line 142 of file stm8l15x_usart.c.
References USART_struct::BRR1, USART_struct::BRR2, USART_struct::CR1, USART_struct::CR2, USART_struct::CR3, USART_struct::CR4, USART_struct::DR, USART_struct::SR, USART_BRR1_RESET_VALUE, USART_BRR2_RESET_VALUE, USART_CR1_RESET_VALUE, USART_CR2_RESET_VALUE, USART_CR3_RESET_VALUE, and USART_CR4_RESET_VALUE.
void USART_DMACmd | ( | USART_TypeDef * | USARTx, |
USART_DMAReq_TypeDef | USART_DMAReq, | ||
FunctionalState | NewState | ||
) |
Enables or disables the USART DMA interface.
Definition at line 812 of file stm8l15x_usart.c.
References USART_struct::CR5, DISABLE, IS_FUNCTIONAL_STATE, and IS_USART_DMAREQ.
FlagStatus USART_GetFlagStatus | ( | USART_TypeDef * | USARTx, |
USART_FLAG_TypeDef | USART_FLAG | ||
) |
Checks whether the specified USART flag is set or not.
Definition at line 996 of file stm8l15x_usart.c.
References USART_struct::CR2, IS_USART_FLAG, RESET, SET, USART_struct::SR, and USART_FLAG_SBK.
ITStatus USART_GetITStatus | ( | USART_TypeDef * | USARTx, |
USART_IT_TypeDef | USART_IT | ||
) |
Checks whether the specified USART interrupt has occurred or not.
Definition at line 1077 of file stm8l15x_usart.c.
References USART_struct::CR1, USART_struct::CR2, USART_struct::CR5, IS_USART_GET_IT, RESET, SET, USART_struct::SR, USART_CR5_EIE, USART_IT_OR, and USART_IT_PE.
void USART_HalfDuplexCmd | ( | USART_TypeDef * | USARTx, |
FunctionalState | NewState | ||
) |
Enables or disables the USART�s Half Duplex communication.
< USART Half Duplex Enable
< USART Half Duplex Disable
Definition at line 560 of file stm8l15x_usart.c.
References USART_struct::CR5, DISABLE, IS_FUNCTIONAL_STATE, and USART_CR5_HDSEL.
void USART_Init | ( | USART_TypeDef * | USARTx, |
uint32_t | BaudRate, | ||
USART_WordLength_TypeDef | USART_WordLength, | ||
USART_StopBits_TypeDef | USART_StopBits, | ||
USART_Parity_TypeDef | USART_Parity, | ||
USART_Mode_TypeDef | USART_Mode | ||
) |
Initializes the USART 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
Definition at line 186 of file stm8l15x_usart.c.
References USART_struct::BRR1, USART_struct::BRR2, CLK_GetClockFreq(), USART_struct::CR1, USART_struct::CR2, USART_struct::CR3, IS_USART_BAUDRATE, IS_USART_MODE, IS_USART_PARITY, IS_USART_STOPBITS, IS_USART_WORDLENGTH, USART_BRR1_DIVM, USART_BRR2_DIVF, USART_BRR2_DIVM, USART_CR1_M, USART_CR1_PCEN, USART_CR1_PS, USART_CR2_REN, USART_CR2_TEN, and USART_CR3_STOP.
void USART_IrDACmd | ( | USART_TypeDef * | USARTx, |
FunctionalState | NewState | ||
) |
Enables or disables the USART�s IrDA interface.
Definition at line 766 of file stm8l15x_usart.c.
References USART_struct::CR5, DISABLE, IS_FUNCTIONAL_STATE, and USART_CR5_IREN.
void USART_IrDAConfig | ( | USART_TypeDef * | USARTx, |
USART_IrDAMode_TypeDef | USART_IrDAMode | ||
) |
Configures the USART�s IrDA interface.
Definition at line 745 of file stm8l15x_usart.c.
References USART_struct::CR5, IS_USART_IRDAMODE, USART_CR5_IRLP, and USART_IrDAMode_Normal.
void USART_ITConfig | ( | USART_TypeDef * | USARTx, |
USART_IT_TypeDef | USART_IT, | ||
FunctionalState | NewState | ||
) |
Enables or disables the specified USART interrupts.
< Enable the Interrupt bits according to USART_IT mask
< Disable the interrupt bits according to USART_IT mask
Definition at line 933 of file stm8l15x_usart.c.
References USART_struct::CR1, USART_struct::CR2, USART_struct::CR5, DISABLE, IS_FUNCTIONAL_STATE, and IS_USART_CONFIG_IT.
uint8_t USART_ReceiveData8 | ( | USART_TypeDef * | USARTx | ) |
Returns the most recent received data by the USART peripheral.
Definition at line 376 of file stm8l15x_usart.c.
References USART_struct::DR.
uint16_t USART_ReceiveData9 | ( | USART_TypeDef * | USARTx | ) |
Returns the most recent received data by the USART peripheral.
Definition at line 386 of file stm8l15x_usart.c.
References USART_struct::CR1, USART_struct::DR, and USART_CR1_R8.
void USART_ReceiverWakeUpCmd | ( | USART_TypeDef * | USARTx, |
FunctionalState | NewState | ||
) |
Determines if the USART is in mute mode or not.
Definition at line 467 of file stm8l15x_usart.c.
References USART_struct::CR2, DISABLE, IS_FUNCTIONAL_STATE, and USART_CR2_RWU.
void USART_SendBreak | ( | USART_TypeDef * | USARTx | ) |
Transmits break characters.
Definition at line 334 of file stm8l15x_usart.c.
References USART_struct::CR2, and USART_CR2_SBK.
void USART_SendData8 | ( | USART_TypeDef * | USARTx, |
uint8_t | Data | ||
) |
Transmits 8 bit data through the USART peripheral.
Definition at line 399 of file stm8l15x_usart.c.
References USART_struct::DR.
void USART_SendData9 | ( | USART_TypeDef * | USARTx, |
uint16_t | Data | ||
) |
Transmits 9 bit data through the USART peripheral.
Definition at line 412 of file stm8l15x_usart.c.
References USART_struct::CR1, USART_struct::DR, IS_USART_DATA_9BITS, and USART_CR1_T8.
void USART_SetAddress | ( | USART_TypeDef * | USARTx, |
uint8_t | USART_Address | ||
) |
Sets the address of the USART node.
Definition at line 490 of file stm8l15x_usart.c.
References USART_struct::CR4, IS_USART_ADDRESS, and USART_CR4_ADD.
void USART_SetGuardTime | ( | USART_TypeDef * | USARTx, |
uint8_t | USART_GuardTime | ||
) |
Sets the specified USART guard time.
- Note:
- SmartCard Mode should be Enabled
Definition at line 684 of file stm8l15x_usart.c.
References USART_struct::GTR.
void USART_SetPrescaler | ( | USART_TypeDef * | USARTx, |
uint8_t | USART_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.
- Note:
- In 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
- ...
-
In 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
- ...
Definition at line 323 of file stm8l15x_usart.c.
References USART_struct::PSCR.
void USART_SmartCardCmd | ( | USART_TypeDef * | USARTx, |
FunctionalState | NewState | ||
) |
Enables or disables the USART Smart Card mode.
Definition at line 638 of file stm8l15x_usart.c.
References USART_struct::CR5, DISABLE, IS_FUNCTIONAL_STATE, and USART_CR5_SCEN.
void USART_SmartCardNACKCmd | ( | USART_TypeDef * | USARTx, |
FunctionalState | NewState | ||
) |
Enables or disables NACK transmission.
Definition at line 661 of file stm8l15x_usart.c.
References USART_struct::CR5, DISABLE, IS_FUNCTIONAL_STATE, and USART_CR5_NACK.
void USART_WakeUpConfig | ( | USART_TypeDef * | USARTx, |
USART_WakeUp_TypeDef | USART_WakeUp | ||
) |
Selects the USART WakeUp method.
Definition at line 509 of file stm8l15x_usart.c.
References USART_struct::CR1, IS_USART_WAKEUP, and USART_CR1_WAKE.