LTlib LaurTec Library
4.0.1
Open Source C Library for Microchip Microcontrollers based on XC8 Compiler
|
#include "module_I2C.h"
Go to the source code of this file.
Functions | |
void | I2C1_open (unsigned char device_type) |
void | I2C1_baud_rate (unsigned int bus_baud_rate_KHZ) |
void | I2C1_set_slave_address (unsigned int device_address) |
void | I2C1_start_bit (void) |
void | I2C1_stop_bit (void) |
signed char | I2C1_write_byte (unsigned char byte_to_send) |
void | I2C1_reset_write_collision_flag (void) |
signed char | I2C1_write_byte_to_external_device (unsigned char control_byte, unsigned char register_address, unsigned char data) |
signed char | I2C1_read_byte_from_external_device (unsigned char control_byte, unsigned char register_address) |
void I2C1_baud_rate | ( | unsigned int | bus_baud_rate_KHZ | ) |
This function sets the bus baudrate in case the device is a Master device.
bus_baud_rate_KHZ | Baud Rate espressed in KHz [min: 1, max:400] |
You must not set the buadrate for a slave device. Doing so may change the slave address.
Definition at line 107 of file module_I2C.c.
References I2C_CLOCK.
void I2C1_open | ( | unsigned char | device_type | ) |
This function Opens the I2C module enabling SCL and SDA lines.
device_type | It specifies if the device is a Master or a Slave [I2C_MASTER, I2C_SLAVE_7_BIT_ADDRESS, I2C_SLAVE_10_BIT_ADDRESS] |
You must use the constants I2C_MASTER, I2C_SLAVE_7_BIT_ADDRESS, I2C_SLAVE_10_BIT_ADDRESS. By default the slew rate is turned on to support communications up to 400KHz.
Definition at line 47 of file module_I2C.c.
References I2C1_read_byte, I2C_SLEW_ON, and PIN_AS_INPUT.
signed char I2C1_read_byte_from_external_device | ( | unsigned char | control_byte, |
unsigned char | register_address | ||
) |
This function read a byte from an external device made of 1 control byte, 1 addres byte.
Definition at line 399 of file module_I2C.c.
References I2C1_negative_ACK, I2C1_restart_communication, I2C1_start_bit(), I2C1_stop_bit(), I2C1_wait_bus_IDLE, and I2C1_write_byte().
void I2C1_reset_write_collision_flag | ( | void | ) |
This function resets the write collision bit.
void |
Definition at line 280 of file module_I2C.c.
void I2C1_set_slave_address | ( | unsigned int | device_address | ) |
This function sets I2C slave address.
device_address | Slave Address |
Definition at line 121 of file module_I2C.c.
void I2C1_start_bit | ( | void | ) |
This function releases the start bit and waits until Start bit is out (idle).
void |
This is a blocking function.
Definition at line 139 of file module_I2C.c.
void I2C1_stop_bit | ( | void | ) |
This function releases the stop bit and waits until Stop bit is out (idle).
void |
This is a blocking function.
Definition at line 160 of file module_I2C.c.
signed char I2C1_write_byte | ( | unsigned char | byte_to_send | ) |
This function writes a byte to the output buffer and performs several error tests.
byte_to_send | Byte to be sent out |
Definition at line 177 of file module_I2C.c.
References I2C1_wait_bus_IDLE.
signed char I2C1_write_byte_to_external_device | ( | unsigned char | control_byte, |
unsigned char | register_address, | ||
unsigned char | data | ||
) |
This function write a byte to an external device made of 1 control byte, 1 addres byte and 1 byte data.
control_byte | Control byte of the external device register_address Address to be written within the external device data Data to be wirtten within the pointed address |
Definition at line 294 of file module_I2C.c.
References I2C1_start_bit(), I2C1_stop_bit(), I2C1_wait_bus_IDLE, and I2C1_write_byte().