libsle4442  0.2-5
Functions
sle_bbg.c File Reference

Bit banging driver to SLE4442. More...

#include <stdint.h>
#include <stdlib.h>
#include <avr/io.h>
#include <util/delay.h>
#include "sle_bbg.h"
Include dependency graph for sle_bbg.c:

Functions

void ck_pulse (void)
 
void set_io (const uint8_t io)
 
void send_start (void)
 
void send_stop (void)
 
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.

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.

◆ send_start()

void send_start ( void  )

Send the START sequence.

Warning
IO line will be set to OUT.

◆ send_stop()

void send_stop ( void  )

Send the STOP sequence.

Warning
IO line will be set to IN.

◆ 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