busi2c.h File Reference

Part of the Modtronix Configurable Buses. This modules uses buffers from the buses module for it's transmit and receive buffers. More...

#include "buses.h"

Defines

#define I2C1_RXBUF_OVERRUN   0x10
#define I2C1_TXBUF_OVERRUN   0x01
#define i2c1BusIsGetReady()   busRxBufHasData(BUSID_I2C1)
#define i2c1BusRxBufEmpty()   busIsRxBufEmpty(BUSID_I2C1)
#define I2C_RXING   0x80
#define I2C_TXING   0x08

Functions

BYTE i2c1BusGetByte (void)
void i2c1BusPutByte (BYTE c)
void i2c1BusPutByteHex (BYTE c)
void i2c1BusPutRomString (ROM char *str)
void i2c1BusPutString (BYTE *s)
void i2c1BusReset (void)
void i2cBusInit (void)
void i2cBusService (void)

Variables

BYTE i2c1Stat


Detailed Description

Part of the Modtronix Configurable Buses. This modules uses buffers from the buses module for it's transmit and receive buffers.

Author:
Modtronix Engineering
Dependencies:
Compiler:
MPLAB C18 v3.21 or higher

Description

This module makes a I2C master bus available for writing and reading data to and from. The bus is configured at 400kbits/sec.

All data written to the transmit buffer is transmitted. A special escape character 0xFA is used for sending commands. To send an actual 0xFA byte, two 0xFA bytes are send after each other. The commands are:

Configuration

The following defines are used to configure this module, and should be placed in the projdefs.h (or similar) file. For details, see Project Configuration. To configure the module, the required defines should be uncommended, and the rest commented out.
 //*********************************************************************
 //-------------- BusI2C1 Configuration --------------------
 //*********************************************************************

Define Documentation

#define I2C1_RXBUF_OVERRUN   0x10

#define I2C1_TXBUF_OVERRUN   0x01

 
#define i2c1BusIsGetReady (  )     busRxBufHasData(BUSID_I2C1)

Are there any bytes in the I2C1 Bus receive buffer.

Returns:
1 if true, else 0

 
#define i2c1BusRxBufEmpty (  )     busIsRxBufEmpty(BUSID_I2C1)

Are there any bytes in the receive buffer.

Returns:
0 if not empty, 1 if empty

#define I2C_RXING   0x80

#define I2C_TXING   0x08


Function Documentation

BYTE i2c1BusGetByte ( void   ) 

Get the next byte in the RX buffer. Before calling this function, the i2c1IsGetReady() function should be called to check if there is any data available.

Returns:
Returns next byte in receive buffer.

void i2c1BusPutByte ( BYTE  c  ) 

Add a byte to the TX buffer.

Parameters:
c Byte to write out on the serial port

void i2c1BusPutByteHex ( BYTE  c  ) 

Send the ASCII hex value of the given byte to the BUS. It is added to the transmit buffer, and asynchronously transmitted. For example, if c=11, then "0B" will be sent to the Bus

Parameters:
c Byte to write out on the bus

void i2c1BusPutRomString ( ROM char *  str  ) 

Transmit a NULL terminated string. It is added to the transmit buffer, and asynchronously transmitted. The NULL is NOT sent!

Parameters:
str Null terminated string to write out on the bus.

void i2c1BusPutString ( BYTE s  ) 

Transmit a NULL terminated string. It is added to the transmit buffer, and asynchronously transmitted. The NULL is NOT sent!

Parameters:
s Null terminated string to write out on the bus.

void i2c1BusReset ( void   ) 

Resets this module, and empties all buffers.

void i2cBusInit ( void   ) 

Initialize all I2C modules

void i2cBusService ( void   ) 

Service all I2C modules


Variable Documentation


Generated on Mon Jul 6 15:42:32 2009 for SBC68EC Web Server by  doxygen 1.5.8