test code
Sample code for SC18IS606 class library
The SC18IS606 : I2C-bus to SPI bridge
Hello program operation sample on Mbed OS6 is available.
Import programSC18IS606_OS6_Hello
operation test on Mbed OS6
This is a "Hello" code for SC18IS606 class library. Showing how to send/receive data to/from SPI bus through this bridge chip.
How to wire the SC18IS606 (using evaluation board)
Diff: main.cpp
- Revision:
- 0:45ec5ead6731
- Child:
- 1:f0126d924ff8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Jul 13 07:20:21 2021 +0000 @@ -0,0 +1,47 @@ +#include "mbed.h" + +I2C i2c( p28, p27 ); +InterruptIn int_signal( p21 ); + + +#define TARG_ADDRESS 0x50 +#define FuncID_WRITE_BUFFER 0x00 +#define FuncID_ClearIntrrupt 0xF1 + +#define SS_BITMAP 0x01 + +volatile int int_flag = false; + +void int_handler() +{ + int_flag = true; +} + +int main() +{ + char s[ 256 + 1 ]; + char int_clear = FuncID_ClearIntrrupt; + + int_signal.mode( PullUp ); + int_signal.fall( &int_handler ); + i2c.frequency( 400 * 1000 ); + + s[ 0 ] = FuncID_WRITE_BUFFER | SS_BITMAP; + + for ( int i = 0; i < 256; i++ ) { + *(s + i + 1) = i; + } + + + while(1) { + i2c.write( TARG_ADDRESS, s, sizeof( s ) ); + + while ( !int_flag ) + ; + + i2c.write( TARG_ADDRESS, &int_clear, sizeof( int_clear ) ); + int_flag = false; + + wait_ms( 2 ); + } +}