Hello world program for PCAL955x component library. This demonstrates standard usage of this library.
Refer to library page for details.
Revision 1:15df36975a85, committed 2015-03-19
- Comitter:
- nxp_ip
- Date:
- Thu Mar 19 04:22:27 2015 +0000
- Parent:
- 0:26310705044b
- Commit message:
- sample code with high-level API
Changed in this revision
PCAL955x.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 26310705044b -r 15df36975a85 PCAL955x.lib --- a/PCAL955x.lib Sat Mar 07 13:05:21 2015 +0000 +++ b/PCAL955x.lib Thu Mar 19 04:22:27 2015 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/users/nxp_ip/code/PCAL955x/#6c9a51a50eea +http://developer.mbed.org/users/nxp_ip/code/PCAL955x/#fd7cfa821b6a
diff -r 26310705044b -r 15df36975a85 main.cpp --- a/main.cpp Sat Mar 07 13:05:21 2015 +0000 +++ b/main.cpp Thu Mar 19 04:22:27 2015 +0000 @@ -1,18 +1,14 @@ -#include "mbed.h" -#include "PCAL9555.h" - -PCAL9555 gpio( p28, p27, 0x40 ); +#include "mbed.h" +#include "PCAL9555.h" -int main() -{ - gpio.configure( 0xFFFF ); // Set all pins: input - printf( " 0x%04X\r\n", (int)gpio );// Print pins state - - gpio.configure( 0x0000 ); // Set all pins: output - - int count = 0; - - while(1) { - gpio.write( count++ ); +PCAL9555 gpio_exp( p28, p27, 0xE8 ); // SDA, SCL, Slave_address(option) +GpioBusOut mypins( gpio_exp, X0_0, X0_1, X0_2, X0_3 ); + +int main() { + while( 1 ) { + for( int i = 0; i < 16; i++ ) { + mypins = i; + wait( 0.1 ); + } } }