![]() |
nanoI2CSlaveExpander
ARDUINO Nano v3 used as I2C slace digital and analog io expander for ESP8266 and others...
|
Go to the source code of this file.
Functions | |
void | setup () |
ARDUINO setup function. More... | |
void | loop () |
ARDUINO loop, cyclicly update analog registers and digital. More... | |
void | receiveEvent (int howMany) |
i2c receiver handler More... | |
void | requestEvent () |
I2C transmit handler for Read request. More... | |
void | regInit () |
initialisation of the register bank More... | |
int | i2cBuildAddress () |
Build i2c slave address with base ored with D12..D10 pin state. More... | |
void | updateAnalogs () |
as its name tells us update analog registers with analog inputs values More... | |
void | updateDigitals () |
update digital registers and digital outputs More... | |
Variables | |
byte | registers [MAXREG] |
Main registers bank. See config.h MAXREG macro for full mapping;. More... | |
int | octetsRec = 0 |
number of i2C received bytes More... | |
int | reg = 1 |
global variable to track the registers address for i2c requests More... | |
int i2cBuildAddress | ( | ) |
Build i2c slave address with base ored with D12..D10 pin state.
Definition at line 205 of file nanoI2CIOExpander.ino.
void loop | ( | ) |
ARDUINO loop, cyclicly update analog registers and digital.
The cyclical update of the registers is not very fast. We could do this in a better way
Definition at line 111 of file nanoI2CIOExpander.ino.
void receiveEvent | ( | int | howMany | ) |
i2c receiver handler
howMany | : nomber of received bytes (dosen't work if there is a Serial.print in the handler) |
Definition at line 133 of file nanoI2CIOExpander.ino.
void regInit | ( | ) |
initialisation of the register bank
Works on global registers array.
Definition at line 178 of file nanoI2CIOExpander.ino.
void requestEvent | ( | ) |
I2C transmit handler for Read request.
Definition at line 167 of file nanoI2CIOExpander.ino.
void setup | ( | ) |
ARDUINO setup function.
Prepare i2c slave address
Set debug port speed if DEBUG is enabled in the config.handler
Display Startup screen with build i2c add
Register 2 i2c event functions
Initialize registers
Display initialized registers
Definition at line 73 of file nanoI2CIOExpander.ino.
void updateAnalogs | ( | ) |
as its name tells us update analog registers with analog inputs values
Works on global registers arrays
Definition at line 227 of file nanoI2CIOExpander.ino.
void updateDigitals | ( | ) |
update digital registers and digital outputs
Works on global registers arrays
Definition at line 246 of file nanoI2CIOExpander.ino.
int octetsRec = 0 |
number of i2C received bytes
Definition at line 97 of file nanoI2CIOExpander.ino.
int reg = 1 |
global variable to track the registers address for i2c requests
Definition at line 98 of file nanoI2CIOExpander.ino.
registers |
Main registers bank. See config.h MAXREG macro for full mapping;.
Definition at line 54 of file nanoI2CIOExpander.ino.