STM8L15x Standard Peripherals Drivers
|
Initialization and Configuration functions. More...
Functions | |
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_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_SendBreak (USART_TypeDef *USARTx) |
Transmits break characters. | |
void | USART_SetPrescaler (USART_TypeDef *USARTx, uint8_t USART_Prescaler) |
Sets the system clock prescaler. |
Detailed Description
Initialization and Configuration functions.
=============================================================================== Initialization and Configuration functions =============================================================================== This subsection provides a set of functions allowing to initialize the USART in asynchronous and in synchronous modes. - For the asynchronous mode only these parameters can be configured: - Baud Rate - Word Length - Stop Bit - Parity: If the parity is enabled, then the MSB bit of the data written in the data register is transmitted but is changed by the parity bit. Depending on the frame length defined by the M bit (8-bits or 9-bits), the possible USART frame formats are as listed in the following table: +-------------------------------------------------------------+ | M bit | PCE bit | USART frame | |---------------------|---------------------------------------| | 0 | 0 | | SB | 8 bit data | STB | | |---------|-----------|---------------------------------------| | 0 | 1 | | SB | 7 bit data | PB | STB | | |---------|-----------|---------------------------------------| | 1 | 0 | | SB | 9 bit data | STB | | |---------|-----------|---------------------------------------| | 1 | 1 | | SB | 8 bit data | PB | STB | | +-------------------------------------------------------------+ - Receiver/transmitter modes The USART_Init() function follows the USART asynchronous configuration procedure (details for the procedure are available in reference manual (RM0031)). - For the synchronous mode in addition to the asynchronous mode parameters these parameters should be also configured: - USART Clock Enabled - USART polarity - USART phase - USART LastBit These parameters can be configured using the USART_ClockInit() function.
Function Documentation
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_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_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_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.