Main Page   Data Structures   File List   Data Fields   Globals   Related Pages  

hal.c File Reference

HAL (Hardware Abstraction Layer). More...

#include <config.h>
#include <crypt.h>
#include <hal.h>
#include <avr/eeprom.h>
#include <avr/io.h>
#include <log.h>
#include <string.h>
#include <tools.h>
#include <types.h>

Functions

void hal_init (void)
 Initializes the HAL. More...

iu8 xeread (iu16 addr)
void xewrt (iu16 addr, iu8 b)
bool hal_eeprom_read (iu8 *dst, iu16 src, iu8 len)
 Read data from EEPROM. More...

bool hal_eeprom_write (iu16 dst, iu8 *src, iu8 len)
 Write data to EEPROM. More...

void sendbytet0 (iu8 b)
iu8 recbytet0 (void)
void hal_io_sendByteT0 (iu8 b)
 Send a byte with T=0 error detection and recovery. More...

iu8 hal_io_recByteT0 (void)
 Receive a byte with T=0 error detection and recovery. More...

bool hal_rnd_getBlock (iu8 *dst)
 Returns 8 random bytes. More...


Detailed Description

HAL (Hardware Abstraction Layer).

Id:
hal.c,v 1.22 2003/03/30 12:42:21 m Exp


Function Documentation

bool hal_eeprom_read iu8   dst,
iu16    src,
iu8    len
 

Read data from EEPROM.

The internal EEPROM begins at address 0, the external EEPROM is located subsequently.

Parameters:
dst  Pointer to destination area.
src  EEPROM source address.
len  Length of data in bytes.
Return values:
TRUE  on success.
FALSE  on failure. Error code given in sw.

bool hal_eeprom_write iu16    dst,
iu8   src,
iu8    len
 

Write data to EEPROM.

The internal EEPROM begins at address 0, the external EEPROM is located subsequently.

Parameters:
dst  EEPROM destination address
src  Pointer to source area.
len  Length of data in bytes.
Return values:
TRUE  on success.
FALSE  on failure. Error code given in sw.

void hal_init void   
 

Initializes the HAL.

Must be called after each reset.

iu8 hal_io_recByteT0 void   
 

Receive a byte with T=0 error detection and recovery.

Currently only 9600 bps at 3.58MHz with direct convention is supported.

Returns:
This function returns a received byte. There can't be an error, because T=0 tries endlessly to receive a characters. (And if there is really an error, what should SOSSE do with it anyway?)

void hal_io_sendByteT0 iu8    b
 

Send a byte with T=0 error detection and recovery.

Currently only 9600 bps at 3.58MHz with direct convention is supported.

Parameters:
b  Byte to send.

bool hal_rnd_getBlock iu8   dst
 

Returns 8 random bytes.

The current AVR implementation does not produce real random numbers, but pseudo random numbers. These are produced by a X9.17 generator modified to use a counter instead of a timer. The state of this PRNG is held at RAND_STATE_ADDR. The start value (at least the key) at this address should be unique for every card.

Parameters:
dst  Pointer to the destination, where the 8 random bytes should be written.
Return values:
TRUE  on success.
FALSE  on failure. Error code given in sw.
Note:
There is still a simpler PRNG in the code, which uses 16 bytes RAM and 126 bytes ROM less than the X9.17 generator.

iu8 recbytet0 void   
 

void sendbytet0 iu8    b
 

iu8 xeread iu16    addr
 

void xewrt iu16    addr,
iu8    b
 


Copyright 2002 by Matthias Bruestle. This is licensed under the GNU General Public License.