test version 0.2

Dependents:   SC18IS606_Hello SC18IS606_EEPROM_access_test SC18IS606_OS6_Hello

Files at this revision

API Documentation at this revision

Comitter:
okano
Date:
Wed Jul 14 03:00:18 2021 +0000
Parent:
1:b44f801ac9f2
Child:
3:47f1f22747cc
Commit message:
buffer write/read splitted

Changed in this revision

SC18IS606.cpp Show annotated file Show diff for this revision Revisions of this file
SC18IS606.h Show annotated file Show diff for this revision Revisions of this file
--- a/SC18IS606.cpp	Tue Jul 13 10:45:46 2021 +0000
+++ b/SC18IS606.cpp	Wed Jul 14 03:00:18 2021 +0000
@@ -35,24 +35,27 @@
     return 0;   //  dummy
 }
 
-
-int SC18IS606::transfer( char *send_data_ptr, char *receive_data_ptr, int length )
+int SC18IS606::transfer( int slave_select_num, char *send_data_ptr, int length )
 {
     char    *p;
     p   = new char[ length + 1 ];
     
-    *p  = SPI_read_and_write;
+    *p  = SPI_read_and_write | (0x1 << slave_select_num);
     memcpy( p + 1, send_data_ptr, length );
     i2c.write( device_address, p, length + 1 );
     delete[]    p;
-    
+
+    return 0;   //  dummy
+}
+
+int SC18IS606::read_buffer( char *receive_data_ptr, int length )
+{
     if ( receive_data_ptr )
         i2c.read( device_address, receive_data_ptr, length );
     
     return 0;   //  dummy
 }
 
-
 int SC18IS606::config( FunctionID fid, char data )
 {
     char    s[ 2 ];
@@ -70,3 +73,12 @@
 
     return 0;   //  dummy
 }
+
+#if 0
+void SC18IS606::wait_transfer_done( void )
+{
+    char    func_id = 0x01;
+    while ( i2c.write( device_address, &func_id, 1 ) )
+        ;
+}
+#endif
--- a/SC18IS606.h	Tue Jul 13 10:45:46 2021 +0000
+++ b/SC18IS606.h	Wed Jul 14 03:00:18 2021 +0000
@@ -58,14 +58,28 @@
      */
     ~SC18IS606();
 
-    /** Transfer (send and receive) data
+    /** Transfer (send data)
+     *
+     *  @param slave_select_num SPI slave select number (0 ~ 2)
+     *  @param send_ptr         Send_data_ptr
+     *  @param length           Length of data array
+     *  @return                 dummy
+     */
+    int transfer( int slave_select_num, char *send_data_ptr, int length );
+
+    /** Read buffer (reading out received data from buffer)
      *
-     *  @param send_ptr     Send_data_ptr
-     *  @param receive_ptr  Receive_data_ptr
-     *  @param length       Length of data array
-     *  @return             dummy
+     *  @param receive_ptr      Receive_data_ptr
+     *  @param length           Length of data array
+     *  @return                 dummy
      */
-    int transfer( char *send_data_ptr, char *receive_data_ptr, int length );
+    int read_buffer( char *receive_data_ptr, int length );
+
+#if 0
+    /** Wait transfer done (using polling method)
+     */
+    void wait_transfer_done( void );
+#endif
 
     /** Set congiguration
      *