Skip to content

HydraFW binary SMARTCARD mode guide

Benjamin Vernoux edited this page Mar 18, 2023 · 13 revisions

HydraFW binary SMARTCARD mode guide

This guide is updated towards firmware [release HydraFW master commit e93be6c or more]

This mode allows to control SMARTCARD

  • SMARTCARD pins: /VCC=PA5, RST=PA6, CD=PA7, CLK=PA8, TX=PB6

For more details see https://github.com/hydrabus/hydrafw/wiki/HydraFW-SMARTCARD-guide

Commands

Once the SMARTCARD mode has been selected, the following commands are available :

  • 0b00000000 Return to main mode. Returns BBIO1
  • 0b00000001 Mode identification. Returns CRD1
  • 0b00000010 RST low. Returns 0x01
  • 0b00000011 RST high. Returns 0x01
  • 0b00000100 Write-then-read (see below)
  • 0b00000110 Set CLK prescaler (see below)
  • 0b00000111 Set Guard Time (see below)
  • 0b01100000 Set SMARTCARD speed
  • 0b10000xyz Configure SMARTCARD port
  • 0b11xxxxxx Binary Auxiliary pins

Command details

Set SMARTCARD speed (0b01100000)

This command sets the SMARTCARD device bitrate. It must be followed by 4 bytes, representing the speed in bauds (little-endian). This commands returns 0x01 if successful, 0x00 in case of error.

Write-then-read operation (0b00000100)

This command is used to send at most 4096 bytes and will read at most 4096 bytes of data. Format :

Byte 1           2          3          4          5         6        ...
|----------|----------|----------|----------|----------|----------|------...
 [command]    [Bytes to write]      [Bytes to read]       [Data to write

The bytes to read/write are in big-endian format. All data will be buffered before being sent to the SMARTCARD. Read data will also be buffered on the Hydrabus. A 0x01 is sent before sending values back to the user.

Set CLK prescaler (0b00000110)

This commands reads one byte, and sets the prescaler accordingly. The following formula allows to calculate the final CLK frequency :

fclk = 42000000/<prescaler_value>

This commands returns 0x01 if successful, 0x00 in case of error.

Set Guard Time (0b00000111)

This commands reads one byte, and sets the guard time value accordingly.

This commands returns 0x01 if successful, 0x00 in case of error.

Configure SMARTCARD port (0b10000xyz)

This allows to set the following parameters :

  • x sets the parity bit (0 = even, 1 = odd)
  • y sets the stop bits (0 (for 0.5 stop bits) or 1 (for 1.5 stop bits))
  • z sets the clock polarity value (0 or 1)

This commands returns 0x01 if successful, 0x00 in case of error.

See https://github.com/hydrabus/hydrafw/wiki/HydraFW-SMARTCARD-guide for more explanation.

How to Flash/Use HydraFW

How to Build/Flash/Use HydraFW

Developer Getting-Started with HydraBus and STM32CubeIDE

Hardware

Firmware (hydrafw) performances

Firmware (hydrafw) Application guides

Firmware (hydrafw) guides

How to Help

Clone this wiki locally