In this configuration, myRIO will always be the master.
More...
#include <I2C.h>
|
void | close () |
| Delete (somehow violently) an I2C object. More...
|
|
I2C * | slave (uint8_t addr) |
| Set the slave address to talk to. More...
|
|
bool | write (uint8_t reg, uint8_t data) |
| Write 8 bits data to the given registry on a previously set slave. More...
|
|
bool | writeFrom (uint8_t reg, uint8_t *data, uint8_t dataSize) |
| Write any size of data starting from reg address. More...
|
|
bool | read (uint8_t reg, uint8_t *data) |
| Read a register and get that data back to data. More...
|
|
bool | readFrom (uint8_t reg, uint8_t *data, uint8_t dataSize) |
| Read multiple registers, starting to reg. More...
|
|
I2C | speed (int SPD_XXKBPS) |
| Set the I2C bus speed. More...
|
|
bool | start (bool RW, uint8_t reg, uint8_t *data, uint8_t dataSize) |
| Begin the procedure. More...
|
|
| ~I2C () |
| Close the I2C channel. More...
|
|
|
static I2C * | open () |
| You can use this to open multiple I2C channels, for exemple use I2CB. More...
|
|
|
| I2C () |
| Enable the I2C channel A on myRIO. More...
|
|
uint8_t | wait () |
| Wait for myRIO to end a frame. More...
|
|
bool | checkErrors (uint8_t state) |
| Check for errors during the previous communication. More...
|
|
In this configuration, myRIO will always be the master.
Definition at line 41 of file I2C.h.
◆ ~I2C()
Close the I2C channel.
Definition at line 245 of file I2C.cpp.
◆ I2C()
Enable the I2C channel A on myRIO.
Definition at line 10 of file I2C.cpp.
◆ checkErrors()
bool I2C::checkErrors |
( |
uint8_t |
state | ) |
|
|
private |
Check for errors during the previous communication.
Stop the communication if there was one.
- Parameters
-
state | the state of the previous communication, |
- See also
- I2C::wait
- Returns
- true if there was no error
Definition at line 224 of file I2C.cpp.
◆ close()
Delete (somehow violently) an I2C object.
Definition at line 238 of file I2C.cpp.
◆ open()
You can use this to open multiple I2C channels, for exemple use I2CB.
Definition at line 30 of file I2C.cpp.
◆ read()
bool I2C::read |
( |
uint8_t |
reg, |
|
|
uint8_t * |
data |
|
) |
| |
Read a register and get that data back to data.
- Parameters
-
reg | the register to read |
data | place to save the read data |
Definition at line 70 of file I2C.cpp.
◆ readFrom()
bool I2C::readFrom |
( |
uint8_t |
reg, |
|
|
uint8_t * |
data, |
|
|
uint8_t |
dataSize |
|
) |
| |
Read multiple registers, starting to reg.
- Parameters
-
reg | the register to start from |
data | the place to save the data. Make sure that it is already allocated. |
dataSize | the number of registers to read |
Definition at line 80 of file I2C.cpp.
◆ slave()
I2C * I2C::slave |
( |
uint8_t |
addr | ) |
|
Set the slave address to talk to.
- Parameters
-
addr | the slave address on 7 bits, starting from the MSB. |
Definition at line 41 of file I2C.cpp.
◆ speed()
I2C I2C::speed |
( |
int |
spd | ) |
|
Set the I2C bus speed.
- Parameters
-
spd | one of SPD_100KBPS, SPD_400KBPS or any value in kbps (for 150kbps, spd = 150) |
Definition at line 90 of file I2C.cpp.
◆ start()
bool I2C::start |
( |
bool |
RW, |
|
|
uint8_t |
reg, |
|
|
uint8_t * |
data, |
|
|
uint8_t |
dataSize |
|
) |
| |
Begin the procedure.
Read the source code documentation to understand what's going on.
- Parameters
-
RW | one of WRITE (0) or READ (1) |
reg | the concerned register |
data | the data to read or write |
dataSize | the ammount of data to read or write |
Definition at line 102 of file I2C.cpp.
◆ wait()
Wait for myRIO to end a frame.
- Returns
- the state of the communication, giving informations about possible errors
Definition at line 210 of file I2C.cpp.
◆ write()
bool I2C::write |
( |
uint8_t |
reg, |
|
|
uint8_t |
data |
|
) |
| |
Write 8 bits data to the given registry on a previously set slave.
- Parameters
-
reg | the register address on the slave |
data | the data to send |
Definition at line 51 of file I2C.cpp.
◆ writeFrom()
bool I2C::writeFrom |
( |
uint8_t |
reg, |
|
|
uint8_t * |
data, |
|
|
uint8_t |
dataSize |
|
) |
| |
Write any size of data starting from reg address.
- Parameters
-
reg | the register address on the slave |
data | the data to send |
dataSize | the size of the data to send |
Definition at line 61 of file I2C.cpp.
◆ cntr
Contains informations relative to the procedure to come.
Definition at line 62 of file I2C.h.
◆ nbInstance
Definition at line 55 of file I2C.h.
◆ slaveAddr
uint8_t myRIO::I2C::slaveAddr |
|
private |
Slave address.
Definition at line 61 of file I2C.h.
The documentation for this class was generated from the following files:
- C:/Users/jackb/OneDrive - etu.univ-lyon1.fr/TERi/Eclipse/workspace/APIForRIO/src/I2C.h
- C:/Users/jackb/OneDrive - etu.univ-lyon1.fr/TERi/Eclipse/workspace/APIForRIO/src/I2C.cpp