-
Notifications
You must be signed in to change notification settings - Fork 7
i2c_init
gicking edited this page Feb 6, 2018
·
4 revisions
back to Command Reference / I2C
Initialize the I2C module of the controller. Currently, only a fixed setting is used, namely:
- I2C standard mode with 7b addresses
- fixed speed of 100kBaud
- no clock stretching
- broadcast receive disabled
- defined in
i2c.h
-
not loaded by
main_general.h
- for custom I2C interrupts set set
#define USE_I2C_ISR
inconfig.h
. The corresponding interrupt function name isI2C_ISR
i2c_init()
-
input:
- none
-
output:
- none
- Nothing
The below function controls a digital potentiometer AD5280. Specifically it
sets the resistance between terminal A and washer to R=Rmax/255*res
#include "i2c.h"
...
void setAD5280(uint8_t addr, uint8_t res) {
uint8_t buf[2] = {0x00, res};
i2c_start();
i2c_send(addr,2,buf);
i2c_stop();
}
setup() {
...
i2c_init();
...
}
To avoid damage
- do not expose I/Os to voltages outside [-0.3V; Vdd+0.3V], else limit injection currents to the specificied limits
- for
OUTPUT
pins assert that sink and source currents are below the specificied limits - do not directly connect two
OUTPUT
pins. If e.g. half-duplex is required, use a pull-up andOUTPUT_OPENDRAIN
, instead
-
Getting Started
-
- General Commands
- Libraries
- LCD BTHQ21605V
- poti AD5280
- poti AD5282
- freemodbus
- PetitFS SD-card (min)
- FatFS: SD card (full)
- Board Specific
-
- Universal
- Board Specific