Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of bertl14 by
Diff: bertl14.cpp
- Revision:
- 2:d9f2452ba88d
- Parent:
- 1:01bc0c86f111
- Child:
- 3:4326e2654adb
--- a/bertl14.cpp Mon Jan 25 11:44:13 2016 +0000 +++ b/bertl14.cpp Sun Jan 31 16:44:34 2016 +0000 @@ -10,7 +10,7 @@ PwmOut engineREN(p36); //EN2, P36, right_ENABLE //********************************************************************************** // Define PC9555 Routines -I2C pc9555 (P0_5, P0_4);// SDA, SCL +I2C pc9555(P0_5, P0_4);// SDA, SCL //********************************************************************************** //Start PC9555 Routines @@ -23,11 +23,11 @@ // Adresse, R/W# = 0, Config PORT 0 (6) = 0x00(= Output), Stop data[0] = PC9555_PORT0_DIRCONFIG; data[1] = 0x00; - pc9555.write(PC9555_ADDR, data, 2); + pc9555.write(PC9555_ADDR_W, data, 2); // Adresse, R/W# = 0, Config PORT 1 (7) = 0xFF(= Input), Stop data[0] = PC9555_PORT1_DIRCONFIG; data[1] = 0xFF; - pc9555.write(PC9555_ADDR, data, 2); + pc9555.write(PC9555_ADDR_W, data, 2); } @@ -38,16 +38,30 @@ // Start, Address, RW# = 0, CMD PC9555_PORT0_OUT, leds, STOP data[0] = PC9555_PORT0_OUT; data[1] = ~leds; //bitwise inversion since Hardware is switched on with 0 (inverse logic) - pc9555.write(PC9555_ADDR, data, 2); + pc9555.write(PC9555_ADDR_W, data, 2); } unsigned char bertl_PC9555_switches() { - ; + int taster; + + pc9555.start(); // Start PC9555 to write the Adress + pc9555.write(PC9555_ADDR_W); // Write the WRITE-Adress + pc9555.write(0x01); // To define the Switches => 0x02: LEDs + pc9555.start(); // Start PC9555 again to read the Values + pc9555.write(PC9555_ADDR_R); // Set the READ_bit + taster = pc9555.read(0); // Read the Value of the Switches + pc9555.stop(); // Stop the I2C + + return (taster); // Return the value + } // END PC9555 Routines //********************************************************************************** + + +//********************************************************************************** // Begin Motor Routines void bertl_engine(int left, int right) {