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 the I2C bus available for writing and reading data to and from. The bus is configured at 400kbits/sec by default.

All data written to the transmit buffer is decoded by this module, and will generally instruct data to be written, or read from a I2C slave node. An ASCII text based message protocol is used. The protocol format is:

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 Wed Feb 3 12:45:34 2010 for SBC65EC Web Server by  doxygen 1.5.8