45 lines
811 B
C++
45 lines
811 B
C++
#include <Wire.h>
|
|
#include "TcsBus.h"
|
|
|
|
#define PCA9554_ADDR 0x20 //PCA9554 = 0 1 0 0 a2 a1 a0
|
|
|
|
#define PIN_AUDIO_READ 0
|
|
#define PIN_API_SWITCH 4
|
|
#define PIN_TCS_READ 13
|
|
#define PIN_TCS_SEND 14
|
|
#define PIN_AUDIO_SEND 17
|
|
|
|
TcsBus tcs(PIN_TCS_SEND, PIN_TCS_READ);
|
|
|
|
static uint32_t ms_old = 0;
|
|
|
|
void setup() {
|
|
// put your setup code here, to run once:
|
|
Wire.begin();
|
|
Serial.begin(115200);
|
|
|
|
tcs.begin();
|
|
|
|
ms_old = millis();
|
|
}
|
|
|
|
|
|
void i2cScan() {
|
|
for(uint8_t a = 0; a < 0x80; a++) {
|
|
Wire.beginTransmission(a);
|
|
byte error = Wire.endTransmission();
|
|
if(!error) Serial.printf("i2cScan: found 0x%0x\n", a);
|
|
}
|
|
}
|
|
|
|
void loop() {
|
|
uint32_t ms = millis();
|
|
if(ms_old != ms) {
|
|
if(ms_old < ms) ms_old++; else ms_old = ms; //prevent overflow
|
|
|
|
if(!(ms & 1023)) {
|
|
i2cScan();
|
|
}
|
|
}
|
|
}
|