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)
main.cpp@2:6d65d24e55ed, 2021-07-13 (annotated)
- Committer:
- okano
- Date:
- Tue Jul 13 10:46:24 2021 +0000
- Revision:
- 2:6d65d24e55ed
- Parent:
- 1:f0126d924ff8
- Child:
- 4:2759b8e6d5ec
SC18IS606 class lib usage sample (ver.0.1)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
okano | 2:6d65d24e55ed | 1 | /* |
okano | 2:6d65d24e55ed | 2 | * SC18IS606 library |
okano | 2:6d65d24e55ed | 3 | * |
okano | 2:6d65d24e55ed | 4 | * @author Akifumi (Tedd) OKANO, NXP Semiconductors |
okano | 2:6d65d24e55ed | 5 | * @version 0.1 |
okano | 2:6d65d24e55ed | 6 | * @date 13-July-2021 |
okano | 2:6d65d24e55ed | 7 | * |
okano | 2:6d65d24e55ed | 8 | * SC18IS606 is an "I2C-bus to SPI bridge" |
okano | 2:6d65d24e55ed | 9 | * http://www.nxp.com/ (product infomation page will be updated later) |
okano | 2:6d65d24e55ed | 10 | */ |
okano | 2:6d65d24e55ed | 11 | |
okano | 0:45ec5ead6731 | 12 | #include "mbed.h" |
okano | 1:f0126d924ff8 | 13 | #include "SC18IS606.h" |
okano | 0:45ec5ead6731 | 14 | |
okano | 0:45ec5ead6731 | 15 | I2C i2c( p28, p27 ); |
okano | 1:f0126d924ff8 | 16 | InterruptIn int_line( p21 ); |
okano | 1:f0126d924ff8 | 17 | SC18IS606 bridge( i2c ); |
okano | 0:45ec5ead6731 | 18 | |
okano | 2:6d65d24e55ed | 19 | #define WAIT_INTERVAL_mS 2 |
okano | 2:6d65d24e55ed | 20 | |
okano | 0:45ec5ead6731 | 21 | volatile int int_flag = false; |
okano | 0:45ec5ead6731 | 22 | |
okano | 0:45ec5ead6731 | 23 | void int_handler() |
okano | 0:45ec5ead6731 | 24 | { |
okano | 0:45ec5ead6731 | 25 | int_flag = true; |
okano | 0:45ec5ead6731 | 26 | } |
okano | 0:45ec5ead6731 | 27 | |
okano | 0:45ec5ead6731 | 28 | int main() |
okano | 0:45ec5ead6731 | 29 | { |
okano | 2:6d65d24e55ed | 30 | printf( "SC18IS606 Hello\r\n" ); |
okano | 2:6d65d24e55ed | 31 | |
okano | 1:f0126d924ff8 | 32 | int_line.mode( PullUp ); |
okano | 1:f0126d924ff8 | 33 | int_line.fall( &int_handler ); |
okano | 0:45ec5ead6731 | 34 | i2c.frequency( 400 * 1000 ); |
okano | 0:45ec5ead6731 | 35 | |
okano | 2:6d65d24e55ed | 36 | char s[ 256 ]; |
okano | 0:45ec5ead6731 | 37 | |
okano | 0:45ec5ead6731 | 38 | for ( int i = 0; i < 256; i++ ) { |
okano | 1:f0126d924ff8 | 39 | s[ i ] = i; |
okano | 0:45ec5ead6731 | 40 | } |
okano | 0:45ec5ead6731 | 41 | |
okano | 0:45ec5ead6731 | 42 | while(1) { |
okano | 1:f0126d924ff8 | 43 | bridge.transfer( s, NULL, sizeof( s ) ); |
okano | 0:45ec5ead6731 | 44 | |
okano | 0:45ec5ead6731 | 45 | while ( !int_flag ) |
okano | 0:45ec5ead6731 | 46 | ; |
okano | 0:45ec5ead6731 | 47 | |
okano | 2:6d65d24e55ed | 48 | bridge.clear_interrupt(); |
okano | 0:45ec5ead6731 | 49 | int_flag = false; |
okano | 0:45ec5ead6731 | 50 | |
okano | 2:6d65d24e55ed | 51 | wait_ms( WAIT_INTERVAL_mS ); |
okano | 0:45ec5ead6731 | 52 | } |
okano | 0:45ec5ead6731 | 53 | } |