test code

Dependencies:   mbed SC18IS606

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. https://os.mbed.com/media/uploads/okano/screenshot_2021-07-14_13.13.55.png

How to wire the SC18IS606 (using evaluation board) https://os.mbed.com/media/uploads/okano/untitled.png

Files at this revision

API Documentation at this revision

Comitter:
okano
Date:
Sun Jul 25 08:30:18 2021 +0000
Parent:
5:b5b951709cab
Child:
7:df3611f05b77
Commit message:
transfer complete wait function implemented

Changed in this revision

SC18IS606.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
--- a/SC18IS606.lib	Fri Jul 23 05:06:17 2021 +0000
+++ b/SC18IS606.lib	Sun Jul 25 08:30:18 2021 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/users/okano/code/SC18IS606/#47f1f22747cc
+https://os.mbed.com/users/okano/code/SC18IS606/#ac0aef91fd94
--- a/main.cpp	Fri Jul 23 05:06:17 2021 +0000
+++ b/main.cpp	Sun Jul 25 08:30:18 2021 +0000
@@ -29,6 +29,15 @@
     int_flag    = true;
 }
 
+void wait_transfer_done( void )
+{
+    while ( !int_flag )
+        ;
+
+    bridge.clear_interrupt();
+    int_flag    = false;
+}
+
 int main()
 {
     printf( "SC18IS606 Hello\r\n" );
@@ -36,6 +45,7 @@
     int_line.mode( PullUp );
     int_line.fall( &int_handler );
     i2c.frequency( I2C_FREQUENCY );
+    bridge.install_wait_func( wait_transfer_done );
 
     char    snd_data[ DATA_LENGTH ];
     char    rcv_data[ DATA_LENGTH ];
@@ -46,13 +56,6 @@
 
     while(1) {
         bridge.transfer( SLAVE_SELECT_NUM, snd_data, sizeof( snd_data ) );
-
-        while ( !int_flag )
-            ;
-
-        bridge.clear_interrupt();
-        int_flag    = false;
-
         bridge.read_buffer( rcv_data, sizeof( rcv_data ) );
         //  data_check( rcv_data, DATA_LENGTH );
     }