Main Page | Data Structures | File List | Data Fields | Globals | Related Pages

twi_lib.h File Reference

#include "twi_drv.h"

Go to the source code of this file.

Data Structures

struct  TWI_message

Defines

#define TWI_NB_SLAVE_DATA   100
#define TWI_MASTER
#define TWI_SLAVE
#define TWI_OK   0
 This constant is used as return value for the functions to.

#define TWI_BUS_ERROR   1
#define TWI_HOST_ADR_NACK   2
#define TWI_HOST_DATA_NACK   3
#define TWI_ARBITRATION_LOST   4
#define TWI_UNKNOWN   5
#define TWI_NOT_FREE   6
#define TWI_READ   1
 This constant is used as parameter value for the functions twi_send_message_xxx to select read operation.

#define TWI_WRITE   0
 This constant is used as parameter value for the functions twi_send_message_xxx to select write operation.

#define TWI_CONFIG   MSK_TWCR_TWEN

Typedefs

typedef unsigned char Length_TWI_frame

Functions

unsigned char twi_send_message_polling (unsigned char slave_addr, bit rw, Length_TWI_frame nbytes, Uchar *info)
 This function sends TWI message to a slave.
This transmition is managed in polling fashion.

unsigned char twi_send_message_interrupt (unsigned char slave_addr, bit rw, Length_TWI_frame nbytes, Uchar *info)
 This function sends TWI message to a slave.
This transmition is managed in interruption fashion.

unsigned char twi_slave_polling (void)
 This function can be called to be able to answer another master request in polling fashion.

void twi_slave_interrupt (void)
 This function can be called to be able to answer another master request in interruption fashion.

void twi_lib_init (void)
 This function allows to init the TWI controller.

Byte twi_putchar (Byte addr, Byte b)
 This function can be used to send an byte to a slave in polling fashion.

Uint16 twi_getchar (Byte addr)
 * This function can be used to receive an byte from a slave in polling fashion.


Variables

volatile TWI_message xdata twi_message
volatile bit twi_busy
volatile unsigned char twi_err
volatile unsigned char xdata twi_slave_data [100]


Define Documentation

#define TWI_ARBITRATION_LOST   4
 

Definition at line 56 of file twi_lib.h.

#define TWI_BUS_ERROR   1
 

Definition at line 53 of file twi_lib.h.

#define TWI_CONFIG   MSK_TWCR_TWEN
 

Definition at line 73 of file twi_lib.h.

#define TWI_HOST_ADR_NACK   2
 

Definition at line 54 of file twi_lib.h.

#define TWI_HOST_DATA_NACK   3
 

Definition at line 55 of file twi_lib.h.

#define TWI_MASTER
 

Definition at line 23 of file twi_lib.h.

#define TWI_NB_SLAVE_DATA   100
 

Definition at line 22 of file twi_lib.h.

#define TWI_NOT_FREE   6
 

Definition at line 58 of file twi_lib.h.

#define TWI_OK   0
 

This constant is used as return value for the functions to.

Definition at line 52 of file twi_lib.h.

#define TWI_READ   1
 

This constant is used as parameter value for the functions twi_send_message_xxx to select read operation.

Definition at line 65 of file twi_lib.h.

#define TWI_SLAVE
 

Definition at line 24 of file twi_lib.h.

#define TWI_UNKNOWN   5
 

Definition at line 57 of file twi_lib.h.

#define TWI_WRITE   0
 

This constant is used as parameter value for the functions twi_send_message_xxx to select write operation.

Definition at line 70 of file twi_lib.h.


Typedef Documentation

typedef unsigned char Length_TWI_frame
 

Definition at line 29 of file twi_lib.h.


Function Documentation

Uint16 twi_getchar Byte  addr  ) 
 

* This function can be used to receive an byte from a slave in polling fashion.

Parameters:
addr: slave to address with this message.
Returns:
byte received

void twi_lib_init void   ) 
 

This function allows to init the TWI controller.

Byte twi_putchar Byte  addr,
Byte  b
 

This function can be used to send an byte to a slave in polling fashion.

Parameters:
addr: slave to address with this message.
byte: byte to transmit.
Returns:
TWI error code state:
  • TWI_OK
  • TWI_BUS_ERROR
  • TWI_HOST_ADR_NACK
  • TWI_HOST_DATA_NACK
  • TWI_ARBITRATION_LOST
  • TWI_UNKNOWN
  • TWI_NOT_FREE

unsigned char twi_send_message_interrupt unsigned char  slave_addr,
bit  rw,
Length_TWI_frame  nbytes,
Uchar *  info
 

This function sends TWI message to a slave.
This transmition is managed in interruption fashion.

Parameters:
slave_addr: slave to address with this message.
rw: This field allows to indicate a read or write message
  • TWI_READ
  • TWI_WRITE
nb_byte: This field gives the byte number to read or write.
*info: pointer to the data to be processed.
Returns:
TWI error code state:
  • TWI_OK
  • TWI_BUS_ERROR
  • TWI_HOST_ADR_NACK
  • TWI_HOST_DATA_NACK
  • TWI_ARBITRATION_LOST
  • TWI_UNKNOWN
  • TWI_NOT_FREE
Precondition:
this function is available only if TWI_MASTER is defined in config.h and DO_NOT_USE_TWI_INTERRUPT is not defined.

unsigned char twi_send_message_polling unsigned char  slave_addr,
bit  rw,
Length_TWI_frame  nbytes,
Uchar *  info
 

This function sends TWI message to a slave.
This transmition is managed in polling fashion.

Parameters:
slave_addr: slave to address with this message.
rw: This field allows to indicate a read or write message
  • TWI_READ
  • TWI_WRITE
nb_byte: This field gives the byte number to read or write.
*info: pointer to the data to be processed.
Returns:
TWI error code state:
  • TWI_OK
  • TWI_BUS_ERROR
  • TWI_HOST_ADR_NACK
  • TWI_HOST_DATA_NACK
  • TWI_ARBITRATION_LOST
  • TWI_UNKNOWN
  • TWI_NOT_FREE
Precondition:
this function is available only if TWI_MASTER is define in config.h

void twi_slave_interrupt void   ) 
 

This function can be called to be able to answer another master request in interruption fashion.

Returns:
TWI error code state:
  • TWI_OK
  • TWI_BUS_ERROR
  • TWI_HOST_ADR_NACK
  • TWI_HOST_DATA_NACK
  • TWI_ARBITRATION_LOST
  • TWI_UNKNOWN
  • TWI_NOT_FREE
Precondition:
this function is available only if TWI_SLAVE is defined in config.h

unsigned char twi_slave_polling void   ) 
 

This function can be called to be able to answer another master request in polling fashion.

Returns:
TWI error code state:
  • TWI_OK
  • TWI_BUS_ERROR
  • TWI_HOST_ADR_NACK
  • TWI_HOST_DATA_NACK
  • TWI_ARBITRATION_LOST
  • TWI_UNKNOWN
  • TWI_NOT_FREE
Precondition:
this function is available only if TWI_SLAVE is defined in config.h


Variable Documentation

volatile bit twi_busy
 

Definition at line 42 of file twi_lib.h.

volatile unsigned char twi_err
 

Definition at line 43 of file twi_lib.h.

volatile TWI_message xdata twi_message
 

Definition at line 41 of file twi_lib.h.

volatile unsigned char xdata twi_slave_data[ 100 ]
 

Definition at line 44 of file twi_lib.h.


Generated on Thu Apr 1 15:50:37 2004 for TWI Library by doxygen 1.3.6