объявляются два экземпляра wire по номеру железного I2C, по дефолту используется тот, что задан для каждой платы
This commit is contained in:
parent
54ec7ed9fe
commit
37b2788851
@ -295,7 +295,9 @@ extern "C" void __attribute__((optimize("O3"))) wire_interrupt_handler(uint8_t n
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------- Preinstantiate Objects ----------------------------- //
|
// ----------------------------- Preinstantiate Objects ----------------------------- //
|
||||||
TwoWire Wire = TwoWire(1);
|
TwoWire Wire1 = TwoWire(1); // I2C1 is always available
|
||||||
#if I2C_COMMON_QTY > 1
|
#if I2C_COMMON_QTY > 1
|
||||||
TwoWire Wire1 = TwoWire(0);
|
TwoWire Wire0 = TwoWire(0); // I2C0 is available on some boards
|
||||||
#endif
|
#endif
|
||||||
|
// default interface
|
||||||
|
TwoWire& Wire = DEFAULT_WIRE;
|
||||||
|
|||||||
@ -90,9 +90,11 @@ class TwoWire : public Stream
|
|||||||
void onRequest( void (*)(void) );
|
void onRequest( void (*)(void) );
|
||||||
};
|
};
|
||||||
|
|
||||||
extern TwoWire Wire;
|
|
||||||
#if I2C_COMMON_QTY>1
|
|
||||||
extern TwoWire Wire1;
|
extern TwoWire Wire1;
|
||||||
|
#if I2C_COMMON_QTY>1
|
||||||
|
extern TwoWire Wire0;
|
||||||
#endif
|
#endif
|
||||||
|
// default interface
|
||||||
|
extern TwoWire& Wire;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -131,9 +131,10 @@ void spi_onBegin(uint8_t spiNum);
|
|||||||
void spi_onEnd(uint8_t spiNum);
|
void spi_onEnd(uint8_t spiNum);
|
||||||
|
|
||||||
// I2C
|
// I2C
|
||||||
|
#define I2C_COMMON_QTY 1
|
||||||
|
#define DEFAULT_WIRE Wire1 // use I2C1 by default
|
||||||
#define PIN_WIRE_SDA 18
|
#define PIN_WIRE_SDA 18
|
||||||
#define PIN_WIRE_SCL 19
|
#define PIN_WIRE_SCL 19
|
||||||
#define I2C_COMMON_QTY 1
|
|
||||||
static const uint8_t SDA = PIN_WIRE_SDA;
|
static const uint8_t SDA = PIN_WIRE_SDA;
|
||||||
static const uint8_t SCL = PIN_WIRE_SCL;
|
static const uint8_t SCL = PIN_WIRE_SCL;
|
||||||
// available frequencies
|
// available frequencies
|
||||||
|
|||||||
@ -125,9 +125,10 @@ void spi_onBegin(uint8_t spiNum);
|
|||||||
void spi_onEnd(uint8_t spiNum);
|
void spi_onEnd(uint8_t spiNum);
|
||||||
|
|
||||||
// I2C
|
// I2C
|
||||||
|
#define I2C_COMMON_QTY (1)
|
||||||
|
#define DEFAULT_WIRE Wire1 // use I2C1 by default
|
||||||
#define PIN_WIRE_SDA (18)
|
#define PIN_WIRE_SDA (18)
|
||||||
#define PIN_WIRE_SCL (19)
|
#define PIN_WIRE_SCL (19)
|
||||||
#define I2C_COMMON_QTY (1)
|
|
||||||
static const uint8_t SDA = PIN_WIRE_SDA;
|
static const uint8_t SDA = PIN_WIRE_SDA;
|
||||||
static const uint8_t SCL = PIN_WIRE_SCL;
|
static const uint8_t SCL = PIN_WIRE_SCL;
|
||||||
// available frequencies
|
// available frequencies
|
||||||
|
|||||||
@ -155,12 +155,13 @@ static inline void spi_onEnd(uint8_t spiNum){}
|
|||||||
|
|
||||||
// I2C
|
// I2C
|
||||||
#define I2C_COMMON_QTY 2
|
#define I2C_COMMON_QTY 2
|
||||||
// Wire (I2C1)
|
#define DEFAULT_WIRE Wire0 // use I2C0 by default
|
||||||
|
// Wire1 (I2C1)
|
||||||
#define PIN_WIRE_SDA P1_12
|
#define PIN_WIRE_SDA P1_12
|
||||||
#define PIN_WIRE_SCL P1_13
|
#define PIN_WIRE_SCL P1_13
|
||||||
static const uint8_t SDA = PIN_WIRE_SDA;
|
static const uint8_t SDA = PIN_WIRE_SDA;
|
||||||
static const uint8_t SCL = PIN_WIRE_SCL;
|
static const uint8_t SCL = PIN_WIRE_SCL;
|
||||||
// Wire1 (I2C0)
|
// Wire0 (I2C0)
|
||||||
#define PIN_WIRE_SDA1 P0_9
|
#define PIN_WIRE_SDA1 P0_9
|
||||||
#define PIN_WIRE_SCL1 P0_10
|
#define PIN_WIRE_SCL1 P0_10
|
||||||
static const uint8_t SDA1 = PIN_WIRE_SDA1;
|
static const uint8_t SDA1 = PIN_WIRE_SDA1;
|
||||||
|
|||||||
@ -168,12 +168,13 @@ static inline void spi_onEnd(uint8_t spiNum){}
|
|||||||
|
|
||||||
// I2C
|
// I2C
|
||||||
#define I2C_COMMON_QTY 2
|
#define I2C_COMMON_QTY 2
|
||||||
// Wire (I2C1)
|
#define DEFAULT_WIRE Wire0 // use I2C0 by default
|
||||||
|
// Wire1 (I2C1)
|
||||||
#define PIN_WIRE_SDA P1_12
|
#define PIN_WIRE_SDA P1_12
|
||||||
#define PIN_WIRE_SCL P1_13
|
#define PIN_WIRE_SCL P1_13
|
||||||
static const uint8_t SDA = PIN_WIRE_SDA;
|
static const uint8_t SDA = PIN_WIRE_SDA;
|
||||||
static const uint8_t SCL = PIN_WIRE_SCL;
|
static const uint8_t SCL = PIN_WIRE_SCL;
|
||||||
// Wire1 (I2C0)
|
// Wire0 (I2C0)
|
||||||
#define PIN_WIRE_SDA1 P0_9
|
#define PIN_WIRE_SDA1 P0_9
|
||||||
#define PIN_WIRE_SCL1 P0_10
|
#define PIN_WIRE_SCL1 P0_10
|
||||||
static const uint8_t SDA1 = PIN_WIRE_SDA1;
|
static const uint8_t SDA1 = PIN_WIRE_SDA1;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user