libsle4442  0.2-5
Macros | Functions
sle_bbg.h File Reference

Bit banging driver to SLE4442. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SLE_PORT   PORTA
 
#define SLE_PIN   PINA
 
#define SLE_DDR   DDRA
 
#define SLE_PRESENT   3
 
#define SLE_RST   0
 
#define SLE_CK   1
 
#define SLE_IO   2
 
#define OUT   2
 
#define IN   3
 
#define ck_delay()   _delay_us(25)
 
#define ck_delay_front()   _delay_us(4)
 
#define ck_delay_reset()   _delay_us(50)
 
#define set_ck_1   SLE_PORT |= (1<<SLE_CK)
 
#define set_ck_0   SLE_PORT &= ~(1<<SLE_CK)
 
#define set_rst_1   SLE_PORT |= (1<<SLE_RST)
 
#define set_rst_0   SLE_PORT &= ~(1<<SLE_RST)
 

Functions

void ck_pulse (void)
 
void set_io (const uint8_t io)
 
uint8_t read_byte (void)
 
void send_byte (uint8_t byte)
 
void send_rst (uint8_t *atr)
 
void send_cmd (const uint8_t control, const uint8_t address, const uint8_t data)
 
uint8_t processing (void)
 

Detailed Description

Bit banging driver to SLE4442.

Low level bit banging driver to read and write to Sle4442 card.

Macro Definition Documentation

◆ ck_delay

#define ck_delay ( )    _delay_us(25)

The delay in usec for half of the wave.

example:

10Khz = 100usec.

20Khz = 50usec, half wave = 25 usec.

Remeber delay is only HALF of the freq. 20Khz total

◆ ck_delay_front

#define ck_delay_front ( )    _delay_us(4)

The MIN delay for a front phase between fronts of ck and/or rst and/or IO.

◆ ck_delay_reset

#define ck_delay_reset ( )    _delay_us(50)

delay reset = 1.

◆ IN

#define IN   3

a simple macro to define IN as 3.

◆ OUT

#define OUT   2

a simple macro to define OUT as 2.

◆ set_ck_0

#define set_ck_0   SLE_PORT &= ~(1<<SLE_CK)

CK line to 0.

◆ set_ck_1

#define set_ck_1   SLE_PORT |= (1<<SLE_CK)

CK line to 1.

◆ set_rst_0

#define set_rst_0   SLE_PORT &= ~(1<<SLE_RST)

RST line to 0.

◆ set_rst_1

#define set_rst_1   SLE_PORT |= (1<<SLE_RST)

RST line to 1.

◆ SLE_CK

#define SLE_CK   1

clock pin of the card.

◆ SLE_DDR

#define SLE_DDR   DDRA

The data direction register to handle the port's line direction.

◆ SLE_IO

#define SLE_IO   2

I/O pin of the card.

◆ SLE_PIN

#define SLE_PIN   PINA

The input port definition where the card is connected to.

◆ SLE_PORT

#define SLE_PORT   PORTA

Port the card's reader is conneted to.

◆ SLE_PRESENT

#define SLE_PRESENT   3

PIN connected to the present card switch.

◆ SLE_RST

#define SLE_RST   0

PIN connected to the reset pin of the card.

Function Documentation

◆ ck_pulse()

void ck_pulse ( void  )

Single clock pulse.

This function generates a single clock cycle onto the clock line.

◆ processing()

uint8_t processing ( void  )

Wait for the card to process the command.

Returns
the number of clock cycle waited.
Warning
if the card has problem and no bit comes from the IO line, the system hangs here.

◆ read_byte()

uint8_t read_byte ( void  )

Read a byte from IO line.

The function geneates 8 clock pulse cycle and on each of them a bit is read from the IO line.

Returns
The byte read.
Note
The IO line have to be already set to INPUT.

◆ send_byte()

void send_byte ( uint8_t  byte)

Write a byte to the IO line.

The function write a byte a singe bit at a time, the bit is written on the 0 phase of the ck line, see datasheet.

Parameters
bytethe byte to be sent.
Note
the IO line should be already set to output.

◆ send_cmd()

void send_cmd ( const uint8_t  control,
const uint8_t  address,
const uint8_t  data 
)

Send a complete command sequence.

Parameters
controlthe control byte.
addressthe address byte.
datathe data byte.
Warning
After the command sequence, IO line is left in IN mode.

◆ send_rst()

void send_rst ( uint8_t *  atr)

Send the reset (rst) sequence to the card.

See datasheet for details on the RST sequence.

Parameters
*atrptr to mem area where this function stores the 4 byte ATR returned after the RST.
Warning
The 4 byte ATR have to be already allocated.

◆ set_io()

void set_io ( const uint8_t  io)

Set's I/O line to one of: IN, OUT, 0 or 1.

IN: The port is in input, the subsequent call with: 0 - Disable internal pull-up resistor. 1 - Enable internal pull-up resistor.

OUT: The port in in output mode, the subsequent call with: 0 - Line is logic 0 (GND). 1 - Line is logic 1 (+5V).

Parameters
iocan be 0, 1, IN, OUT