common/pic24_i2c.c File Reference

#include "pic24_all.h"
#include <stdio.h>

Go to the source code of this file.

Functions

void configI2C1 (uint16 u16_FkHZ)
void startI2C1 (void)
void rstartI2C1 (void)
void stopI2C1 (void)
void putI2C1 (uint8 u8_val)
uint8 putNoAckCheckI2C1 (uint8 u8_val)
uint8 getI2C1 (uint8 u8_ack2Send)
void write1I2C1 (uint8 u8_addr, uint8 u8_d1)
void write2I2C1 (uint8 u8_addr, uint8 u8_d1, uint8 u8_d2)
void writeNI2C1 (uint8 u8_addr, uint8 *pu8_data, uint16 u16_cnt)
void read1I2C1 (uint8 u8_addr, uint8 *pu8_d1)
void read2I2C1 (uint8 u8_addr, uint8 *pu8_d1, uint8 *pu8_d2)
void readNI2C1 (uint8 u8_addr, uint8 *pu8_data, uint16 u16_cnt)


Detailed Description

I2C support functions.
See also:
pic24_i2c.h for details.

Definition in file pic24_i2c.c.


Function Documentation

void configI2C1 ( uint16  u16_FkHZ  ) 

Configure and enable the I2C1 module for operation at u16_FkHZ kHZ clock speed.

Parameters:
u16_FkHZ specifies clock speed in kHZ

Definition at line 49 of file pic24_i2c.c.

uint8 getI2C1 ( uint8  u8_ack2Send  ) 

Operation: Wait for a byte byte on the I2C bus, send u8_ack2Send as the acknowledgement bit to send back to the slave.

Parameters:
u8_ack2Send ack bit to send back to slave after byte is read
Returns:
byte read from slave

Definition at line 150 of file pic24_i2c.c.

void putI2C1 ( uint8  u8_val  ) 

Operation: Send one byte (u8_val), if NAK is returned use reportError() function to save error and do software reset.

Parameters:
u8_val byte to send

Definition at line 110 of file pic24_i2c.c.

uint8 putNoAckCheckI2C1 ( uint8  u8_val  ) 

Operation: Send one byte (u8_val), return the acknowledgement bit that comes back from the slave. This function does not error out if a NAK is returned.

Parameters:
u8_val byte to send
Returns:
Ack bit value returned from slave.

Definition at line 132 of file pic24_i2c.c.

void read1I2C1 ( uint8  u8_addr,
uint8 pu8_d1 
)

Transaction: Read one byte from I2C slave at address u8_addr, save to *pu8_d1. As per the I2C standard, a NAK is returned for the last byte read from the slave, ACKs are returned for the other bytes.

Parameters:
u8_addr Slave I2C address
pu8_d1 Pointer to location to store byte read from slave

Definition at line 218 of file pic24_i2c.c.

void read2I2C1 ( uint8  u8_addr,
uint8 pu8_d1,
uint8 pu8_d2 
)

Transaction: Read two bytes from I2C slave at address u8_addr, save to *pu8_d1, *pu8_d2. As per the I2C standard, a NAK is returned for the last byte read from the slave, ACKs are returned for the other bytes.

Parameters:
u8_addr Slave I2C address
pu8_d1 Pointer to location to store first byte read from slave
pu8_d2 Pointer to location to store second byte read from slave

Definition at line 231 of file pic24_i2c.c.

void readNI2C1 ( uint8  u8_addr,
uint8 pu8_data,
uint16  u16_cnt 
)

Transaction: Read u16_cnt bytes from I2C slave at address u8_addr, save to buffer *pu8_data. As per the I2C standard, a NAK is returned for the last byte read from the slave, ACKs are returned for the other bytes.

Parameters:
u8_addr Slave I2C address
pu8_data Pointer to buffer for storing bytes read from slave
u16_cnt Number of bytes read from slave.

Definition at line 245 of file pic24_i2c.c.

void rstartI2C1 ( void   ) 

Operation: Perform an I2C repeated start operation.

Definition at line 77 of file pic24_i2c.c.

void startI2C1 ( void   ) 

Operation: Perform an I2C start operation.

Definition at line 61 of file pic24_i2c.c.

void stopI2C1 ( void   ) 

Operation: Perform an I2C stop operation.

Definition at line 93 of file pic24_i2c.c.

void write1I2C1 ( uint8  u8_addr,
uint8  u8_d1 
)

Transaction: Write 1 byte (u8_d1) to I2C slave at address u8_addr.

Parameters:
u8_addr Slave I2C address
u8_d1 Byte to send

Definition at line 176 of file pic24_i2c.c.

void write2I2C1 ( uint8  u8_addr,
uint8  u8_d1,
uint8  u8_d2 
)

Transaction: Write 2 bytes (u8_d1, u8_d2) to I2C slave at address u8_addr.

Parameters:
u8_addr Slave I2C address
u8_d1 First byte to send
u8_d2 Second byte to send

Definition at line 188 of file pic24_i2c.c.

void writeNI2C1 ( uint8  u8_addr,
uint8 pu8_data,
uint16  u16_cnt 
)

Transaction: Write u16_cnt bytes stored in buffer *pu8_data to I2C slave at address u8_addr.

Parameters:
u8_addr Slave I2C address
pu8_data Pointer to buffer containing bytes to send
u16_cnt Number of bytes to send

Definition at line 202 of file pic24_i2c.c.


Generated on Sun Mar 15 11:14:22 2009 for PIC24 Support Libraries by  doxygen 1.5.8