test
Diff: main.cpp
- Revision:
- 1:397813654863
- Parent:
- 0:8491d8911089
- Child:
- 2:8fd249f35ceb
--- a/main.cpp Mon Feb 08 18:35:32 2021 +0000
+++ b/main.cpp Mon Feb 08 18:56:11 2021 +0000
@@ -15,33 +15,13 @@
I2C i2c(P3_4, P3_5);
-const int addr = 0xAA;
-
-void scanI2C() {
- printf("Searching for I2C devices...\n\r");
-
- int count = 0;
- for (int address = 0; address < 255; address +=2) { // check only for device's read addres
- if (!i2c.write(address, NULL, 0)) { // 0 returned is ok
- printf("I2C device found at address 0x%02X (0x%02X in 8-bit)\n\r", address >> 1, address); // the address is without LSB, which is R/W flag. shoft it right once
- count++;
- }
- thread_sleep_for(1);
- }
- if (count)
- printf("%d", count);
- else
- printf("No");
- printf(" device%c found\n\r\n", count == 1?'\0':'s');
-}
+const int addr = 0x55;
int main()
{
i2c.frequency(400000);
char cmd[4];
-
- scanI2C();
-
+
// Initialise the digital pin LED1 as an output
DigitalOut led(LED1);
DigitalOut rst(RST_PIN);
@@ -54,6 +34,8 @@
thread_sleep_for(10);
rst = 1;
thread_sleep_for(1500);
+
+ scanI2C();
while (true) {
cmd[0] = 0x02;