STM8L15x Standard Peripherals Drivers: Smartcard mode functions

STM8L15x/16x Standard Peripherals Drivers

STM8L15x Standard Peripherals Drivers

Smartcard mode functions

Smartcard mode functions. More...

Functions

void USART_SetGuardTime (USART_TypeDef *USARTx, uint8_t USART_GuardTime)
 Sets the specified USART guard time.
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.

Detailed Description

Smartcard mode functions.

 ===============================================================================
                               Smartcard mode functions
 ===============================================================================  

  This subsection provides a set of functions allowing to manage the USART 
  Smartcard communication.
  
  The Smartcard interface is designed to support asynchronous protocol Smartcards as
  defined in the ISO 7816-3 standard.

  The USART can provide a clock to the smartcard through the SCLK output.
  In smartcard mode, SCLK is not associated to the communication but is simply derived 
  from the internal peripheral input clock through a 5-bit prescaler.

  Smartcard communication is possible through the following procedure:
     1. Configures the Smartcard Prsecaler using the USART_SetPrescaler() function.
     2. Configures the Smartcard Guard Time using the USART_SetGuardTime() function.
     3. Program the USART clock using the USART_ClockInit() function as following:
        - USART Clock enabled
        - USART CPOL Low
        - USART CPHA on first edge
        - USART Last Bit Clock Enabled
     4. Program the Smartcard interface using the USART_Init() function as following:
        - Word Length = 9 Bits
        - 1.5 Stop Bit
        - Even parity
        - BaudRate = 12096 baud
        - Hardware flow control disabled (RTS and CTS signals)
        - Tx and Rx enabled
     5. Optionally you can enable the parity error interrupt using the USART_ITConfig()
        function
     6. Enable the USART using the USART_Cmd() function.
     7. Enable the Smartcard NACK using the USART_SmartCardNACKCmd() function.
     8. Enable the Smartcard interface using the USART_SmartCardCmd() function.

  Please refer to the ISO 7816-3 specification for more details.

Note: 
-----
  1.  It is also possible to choose 0.5 stop bit for receiving but it is recommended 
      to use 1.5 stop bits for both transmitting and receiving to avoid switching 
      between the two configurations.
  2. In smartcard mode, the following bits must be kept cleared:
     - HDSEL and IREN bits in the USART_CR5 register.


Function Documentation

void USART_SetGuardTime ( USART_TypeDef USARTx,
uint8_t  USART_GuardTime 
)

Sets the specified USART guard time.

Note:
SmartCard Mode should be Enabled
Parameters:
USARTx,:where x can be 1 to select the specified USART peripheral.
USART_GuardTime,:specifies the guard time.
Return values:
None

Definition at line 684 of file stm8l15x_usart.c.

References USART_struct::GTR.

void USART_SmartCardCmd ( USART_TypeDef USARTx,
FunctionalState  NewState 
)

Enables or disables the USART Smart Card mode.

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

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.

Parameters:
USARTx,:where x can be 1 to select the specified USART peripheral.
NewState,:new state of the Smart Card mode. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 661 of file stm8l15x_usart.c.

References USART_struct::CR5, DISABLE, IS_FUNCTIONAL_STATE, and USART_CR5_NACK.

STM8S Firmware Library: Overview

 

 

 

For complete documentation on STM8L15x 8-bit microcontrollers platform visit www.st.com