Tedd OKANO / Mbed 2 deprecated SC18IS606_Hello

Dependencies:   mbed SC18IS606

Files at this revision

API Documentation at this revision

Comitter:
okano
Date:
Wed Jul 28 01:48:47 2021 +0000
Parent:
6:741cdb9c5726
Commit message:
code cleaned

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	Sun Jul 25 08:30:18 2021 +0000
+++ b/SC18IS606.lib	Wed Jul 28 01:48:47 2021 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/users/okano/code/SC18IS606/#ac0aef91fd94
+https://os.mbed.com/users/okano/code/SC18IS606/#436b2c7854e8
--- a/main.cpp	Sun Jul 25 08:30:18 2021 +0000
+++ b/main.cpp	Wed Jul 28 01:48:47 2021 +0000
@@ -1,9 +1,9 @@
 /*
- *  SC18IS606 library
+ *  "Hello code" for SC18IS606 library
  *
  *  @author     Akifumi (Tedd) OKANO, NXP Semiconductors
- *  @version    0.1
- *  @date       13-July-2021
+ *  @version    0.2
+ *  @date       28-July-2021
  *
  *  SC18IS606 is an "I2C-bus to SPI bridge"
  *  http://www.nxp.com/ (product infomation page will be updated later)
@@ -14,7 +14,7 @@
 
 I2C         i2c( p28, p27 );
 InterruptIn int_line( p21 );
-SC18IS606   bridge( i2c );
+SC18IS606   bridge( i2c );      //  make a SC18IS606 instance as "bridge"
 
 #define I2C_FREQUENCY       (400 * 1000)    // Hz
 #define SLAVE_SELECT_NUM    0
@@ -38,13 +38,18 @@
     int_flag    = false;
 }
 
+void hardware_settings( void )
+{
+    int_line.mode( PullUp );
+    int_line.fall( &int_handler );
+    i2c.frequency( I2C_FREQUENCY );
+}
+
 int main()
 {
     printf( "SC18IS606 Hello\r\n" );
 
-    int_line.mode( PullUp );
-    int_line.fall( &int_handler );
-    i2c.frequency( I2C_FREQUENCY );
+    hardware_settings();
     bridge.install_wait_func( wait_transfer_done );
 
     char    snd_data[ DATA_LENGTH ];
@@ -57,11 +62,10 @@
     while(1) {
         bridge.transfer( SLAVE_SELECT_NUM, snd_data, sizeof( snd_data ) );
         bridge.read_buffer( rcv_data, sizeof( rcv_data ) );
-        //  data_check( rcv_data, DATA_LENGTH );
+        data_check( rcv_data, DATA_LENGTH );
     }
 }
 
-
 void data_check( char *data, int length )
 {
     for ( int i = 0; i < length; i++ ) {
@@ -69,5 +73,4 @@
             printf( "\r\n %02X :", i );
         printf( " %02X", data[ i ] );
     }
-
 }