Wixel SDK
|
#include <cc2511_types.h>
Go to the source code of this file.
Functions | |
void | i2cSetFrequency (uint16 freqKHz) |
void | i2cSetTimeout (uint16 timeoutMs) |
void | i2cStart (void) |
void | i2cStop (void) |
BIT | i2cWriteByte (uint8 byte) |
uint8 | i2cReadByte (BIT nack) |
Variables | |
uint8 DATA | i2cPinScl |
uint8 DATA | i2cPinSda |
BIT | i2cTimeoutOccurred |
The i2c.lib
library provides a basic software (bit-banging) implementation of a master node for I2C communication (the CC2511 does not have a hardware I2C module). This library does not support multi-master I2C buses.
By default, the SCL pin is assigned to P1_0, the SDA pin is assigned to P1_1, and the bus frequency is 100 kHz with a 10 ms timeout.
Definition in file i2c.h.
Reads a byte from the I2C bus (performs a master receive).
nack | If 1, a NACK will be sent to the slave device instead of an ACK after this byte is received. (This is used to signal conclusion of a transfer from the slave to the master.) |
void i2cSetFrequency | ( | uint16 | freqKHz | ) |
Sets the I2C bus clock frequency. This implementation limits the range of possible frequencies to 2-500 kHz; because of rounding inaccuracies and timing constraints, the actual frequency might be lower than the selected frequency, but it is guaranteed never to be higher. The default frequency is 100 kHz. Common I2C speeds are 10 kHz (low speed), 100 kHz (standard), and 400 kHz (high speed).
freqKHz | Frequency in kHz. |
void i2cSetTimeout | ( | uint16 | timeoutMs | ) |
Sets the allowed delay before a low SCL line causes an I2C bus timeout, which aborts the I2C transaction and sets the i2cTimeoutOccurred flag. The default timeout is 10 ms.
timeoutMs | Timeout in milliseconds. |
Writes a byte to the I2C bus (performs a master transmit).
byte | The byte to be transmitted. |
BIT i2cTimeoutOccurred |
This bit is a flag that is set whenever a timeout occurs on the I2C bus waiting for the SCL line to go high. The flag must be manually cleared after being read. The i2cSetTimeout() function can be used to specify the timeout delay.