Martin Johnson / STM32F3-Discovery

Dependents:   Space_Invaders_Demo neopixels gpio_test_stm32f3_discovery gpio_test_systimer ... more

Embed: (wiki syntax)

« Back to documentation index

Initialization and Configuration functions

Initialization and Configuration functions
[USART_Private_Functions]

Initialization and Configuration functions. More...

Functions

void USART_DeInit (USART_TypeDef *USARTx)
 Deinitializes the USARTx peripheral registers to their default reset values.
void USART_Init (USART_TypeDef *USARTx, USART_InitTypeDef *USART_InitStruct)
 Initializes the USARTx peripheral according to the specified parameters in the USART_InitStruct .
void USART_StructInit (USART_InitTypeDef *USART_InitStruct)
 Fills each USART_InitStruct member with its default value.
void USART_ClockInit (USART_TypeDef *USARTx, USART_ClockInitTypeDef *USART_ClockInitStruct)
 Initializes the USARTx peripheral Clock according to the specified parameters in the USART_ClockInitStruct.
void USART_ClockStructInit (USART_ClockInitTypeDef *USART_ClockInitStruct)
 Fills each USART_ClockInitStruct member with its default value.
void USART_Cmd (USART_TypeDef *USARTx, FunctionalState NewState)
 Enables or disables the specified USART peripheral.
void USART_DirectionModeCmd (USART_TypeDef *USARTx, uint32_t USART_DirectionMode, FunctionalState NewState)
 Enables or disables the USART's transmitter or receiver.
void USART_OverSampling8Cmd (USART_TypeDef *USARTx, FunctionalState NewState)
 Enables or disables the USART's 8x oversampling mode.
void USART_OneBitMethodCmd (USART_TypeDef *USARTx, FunctionalState NewState)
 Enables or disables the USART's one bit sampling method.
void USART_MSBFirstCmd (USART_TypeDef *USARTx, FunctionalState NewState)
 Enables or disables the USART's most significant bit first transmitted/received following the start bit.
void USART_DataInvCmd (USART_TypeDef *USARTx, FunctionalState NewState)
 Enables or disables the binary data inversion.
void USART_InvPinCmd (USART_TypeDef *USARTx, uint32_t USART_InvPin, FunctionalState NewState)
 Enables or disables the Pin(s) active level inversion.
void USART_SWAPPinCmd (USART_TypeDef *USARTx, FunctionalState NewState)
 Enables or disables the swap Tx/Rx pins.
void USART_ReceiverTimeOutCmd (USART_TypeDef *USARTx, FunctionalState NewState)
 Enables or disables the receiver Time Out feature.
void USART_SetReceiverTimeOut (USART_TypeDef *USARTx, uint32_t USART_ReceiverTimeOut)
 Sets the receiver Time Out value.
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 |     |
   +-------------------------------------------------------------+            
    [..]
           (++) Hardware flow control.
           (++) Receiver/transmitter modes.
    [..] The USART_Init() function follows the USART  asynchronous configuration 
         procedure(details for the procedure are available in reference manual.
        (+) 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_ClockInitTypeDef *  USART_ClockInitStruct 
)

Initializes the USARTx peripheral Clock according to the specified parameters in the USART_ClockInitStruct.

Parameters:
USARTx,:Select the USART peripheral. This parameter can be one of the following values: USART1 or USART2 or USART3.
USART_ClockInitStruct,:pointer to a USART_ClockInitTypeDef structure that contains the configuration information for the specified USART peripheral.
Return values:
None

Definition at line 365 of file stm32f30x_usart.c.

void USART_ClockStructInit ( USART_ClockInitTypeDef *  USART_ClockInitStruct )

Fills each USART_ClockInitStruct member with its default value.

Parameters:
USART_ClockInitStruct,:pointer to a USART_ClockInitTypeDef structure which will be initialized.
Return values:
None

Definition at line 395 of file stm32f30x_usart.c.

void USART_Cmd ( USART_TypeDef *  USARTx,
FunctionalState  NewState 
)

Enables or disables the specified USART peripheral.

Parameters:
USARTx,:Select the USART peripheral. This parameter can be one of the following values: USART1 or USART2 or USART3 or UART4 or UART5.
NewState,:new state of the USARTx peripheral. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 412 of file stm32f30x_usart.c.

void USART_DataInvCmd ( USART_TypeDef *  USARTx,
FunctionalState  NewState 
)

Enables or disables the binary data inversion.

Parameters:
USARTx,:Select the USART peripheral. This parameter can be one of the following values: USART1 or USART2 or USART3 or UART4 or UART5.
NewState,:new defined levels for the USART data. This parameter can be: ENABLE or DISABLE.

  • ENABLE: Logical data from the data register are send/received in negative logic. (1=L, 0=H). The parity bit is also inverted.
  • DISABLE: Logical data from the data register are send/received in positive logic. (1=H, 0=L)
Note:
This function has to be called before calling USART_Cmd() function.
Return values:
None

Definition at line 566 of file stm32f30x_usart.c.

void USART_DeInit ( USART_TypeDef *  USARTx )

Deinitializes the USARTx peripheral registers to their default reset values.

Parameters:
USARTx,:Select the USART peripheral. This parameter can be one of the following values: USART1 or USART2 or USART3 or UART4 or UART5.
Return values:
None

Definition at line 179 of file stm32f30x_usart.c.

void USART_DirectionModeCmd ( USART_TypeDef *  USARTx,
uint32_t  USART_DirectionMode,
FunctionalState  NewState 
)

Enables or disables the USART's transmitter or receiver.

Parameters:
USARTx,:Select the USART peripheral. This parameter can be one of the following values: USART1 or USART2 or USART3 or UART4 or UART5.
USART_Direction,:specifies the USART direction. This parameter can be any combination of the following values:

  • USART_Mode_Tx: USART Transmitter
  • USART_Mode_Rx: USART Receiver
NewState,:new state of the USART transfer direction. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 442 of file stm32f30x_usart.c.

void USART_Init ( USART_TypeDef *  USARTx,
USART_InitTypeDef *  USART_InitStruct 
)

Initializes the USARTx peripheral according to the specified parameters in the USART_InitStruct .

Parameters:
USARTx,:Select the USART peripheral. This parameter can be one of the following values: USART1 or USART2 or USART3 or UART4 or UART5.
USART_InitStruct,:pointer to a USART_InitTypeDef structure that contains the configuration information for the specified USART peripheral.
Return values:
None

Definition at line 223 of file stm32f30x_usart.c.

void USART_InvPinCmd ( USART_TypeDef *  USARTx,
uint32_t  USART_InvPin,
FunctionalState  NewState 
)

Enables or disables the Pin(s) active level inversion.

Parameters:
USARTx,:Select the USART peripheral. This parameter can be one of the following values: USART1 or USART2 or USART3 or UART4 or UART5.
USART_InvPin,:specifies the USART pin(s) to invert. This parameter can be any combination of the following values:

  • USART_InvPin_Tx: USART Tx pin active level inversion.
  • USART_InvPin_Rx: USART Rx pin active level inversion.
NewState,:new active level status for the USART pin(s). This parameter can be: ENABLE or DISABLE.

  • ENABLE: pin(s) signal values are inverted (Vdd =0, Gnd =1).
  • DISABLE: pin(s) signal works using the standard logic levels (Vdd =1, Gnd =0).
Note:
This function has to be called before calling USART_Cmd() function.
Return values:
None

Definition at line 602 of file stm32f30x_usart.c.

void USART_MSBFirstCmd ( USART_TypeDef *  USARTx,
FunctionalState  NewState 
)

Enables or disables the USART's most significant bit first transmitted/received following the start bit.

Parameters:
USARTx,:Select the USART peripheral. This parameter can be one of the following values: USART1 or USART2 or USART3 or UART4 or UART5.
NewState,:new state of the USART most significant bit first transmitted/received following the start bit. This parameter can be: ENABLE or DISABLE.
Note:
This function has to be called before calling USART_Cmd() function.
Return values:
None

Definition at line 532 of file stm32f30x_usart.c.

void USART_OneBitMethodCmd ( USART_TypeDef *  USARTx,
FunctionalState  NewState 
)

Enables or disables the USART's one bit sampling method.

Parameters:
USARTx,:Select the USART peripheral. This parameter can be one of the following values: USART1 or USART2 or USART3 or UART4 or UART5.
NewState,:new state of the USART one bit sampling method. This parameter can be: ENABLE or DISABLE.
Note:
This function has to be called before calling USART_Cmd() function.
Return values:
None

Definition at line 502 of file stm32f30x_usart.c.

void USART_OverSampling8Cmd ( USART_TypeDef *  USARTx,
FunctionalState  NewState 
)

Enables or disables the USART's 8x oversampling mode.

Parameters:
USARTx,:Select the USART peripheral. This parameter can be one of the following values: USART1 or USART2 or USART3 or UART4 or UART5.
NewState,:new state of the USART 8x oversampling mode. This parameter can be: ENABLE or DISABLE.
Note:
This function has to be called before calling USART_Init() function in order to have correct baudrate Divider value.
Return values:
None

Definition at line 474 of file stm32f30x_usart.c.

void USART_ReceiverTimeOutCmd ( USART_TypeDef *  USARTx,
FunctionalState  NewState 
)

Enables or disables the receiver Time Out feature.

Parameters:
USARTx,:Select the USART peripheral. This parameter can be one of the following values: USART1 or USART2 or USART3 or UART4 or UART5.
NewState,:new state of the USARTx receiver Time Out. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 661 of file stm32f30x_usart.c.

void USART_SetPrescaler ( USART_TypeDef *  USARTx,
uint8_t  USART_Prescaler 
)

Sets the system clock prescaler.

Parameters:
USARTx,:Select the USART peripheral. This parameter can be one of the following values: USART1 or USART2 or USART3 or UART4 or UART5.
USART_Prescaler,:specifies the prescaler clock.
Note:
This function has to be called before calling USART_Cmd() function.
Return values:
None

Definition at line 711 of file stm32f30x_usart.c.

void USART_SetReceiverTimeOut ( USART_TypeDef *  USARTx,
uint32_t  USART_ReceiverTimeOut 
)

Sets the receiver Time Out value.

Parameters:
USARTx,:Select the USART peripheral. This parameter can be one of the following values: USART1 or USART2 or USART3 or UART4 or UART5.
USART_ReceiverTimeOut,:specifies the Receiver Time Out value.
Return values:
None

Definition at line 688 of file stm32f30x_usart.c.

void USART_StructInit ( USART_InitTypeDef *  USART_InitStruct )

Fills each USART_InitStruct member with its default value.

Parameters:
USART_InitStruct,:pointer to a USART_InitTypeDef structure which will be initialized.
Return values:
None

Definition at line 344 of file stm32f30x_usart.c.

void USART_SWAPPinCmd ( USART_TypeDef *  USARTx,
FunctionalState  NewState 
)

Enables or disables the swap Tx/Rx pins.

Parameters:
USARTx,:Select the USART peripheral. This parameter can be one of the following values: USART1 or USART2 or USART3 or UART4 or UART5.
NewState,:new state of the USARTx TX/RX pins pinout. This parameter can be: ENABLE or DISABLE.

  • ENABLE: The TX and RX pins functions are swapped.
  • DISABLE: TX/RX pins are used as defined in standard pinout
Note:
This function has to be called before calling USART_Cmd() function.
Return values:
None

Definition at line 635 of file stm32f30x_usart.c.