Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 4:2759b8e6d5ec, committed 2021-07-14
- Comitter:
- okano
- Date:
- Wed Jul 14 03:00:41 2021 +0000
- Parent:
- 3:fd0a24b6fd7c
- Child:
- 5:b5b951709cab
- Commit message:
- buffer write/read splitted
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 Tue Jul 13 10:48:34 2021 +0000 +++ b/SC18IS606.lib Wed Jul 14 03:00:41 2021 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/okano/code/SC18IS606/#b44f801ac9f2 +https://os.mbed.com/users/okano/code/SC18IS606/#4e64923032ad
--- a/main.cpp Tue Jul 13 10:48:34 2021 +0000
+++ b/main.cpp Wed Jul 14 03:00:41 2021 +0000
@@ -16,7 +16,11 @@
InterruptIn int_line( p21 );
SC18IS606 bridge( i2c );
-#define WAIT_INTERVAL_mS 2
+#define I2C_FREQUENCY (400 * 1000) // Hz
+#define SLAVE_SELECT_NUM 0
+#define DATA_LENGTH 256
+
+void data_check( char *data, int length );
volatile int int_flag = false;
@@ -28,26 +32,39 @@
int main()
{
printf( "SC18IS606 Hello\r\n" );
-
+
int_line.mode( PullUp );
int_line.fall( &int_handler );
- i2c.frequency( 400 * 1000 );
+ i2c.frequency( I2C_FREQUENCY );
- char s[ 256 ];
+ char snd_data[ DATA_LENGTH ];
+ char rcv_data[ DATA_LENGTH ];
- for ( int i = 0; i < 256; i++ ) {
- s[ i ] = i;
+ for ( int i = 0; i < DATA_LENGTH; i++ ) {
+ snd_data[ i ] = i;
}
while(1) {
- bridge.transfer( s, NULL, sizeof( s ) );
+ bridge.transfer( SLAVE_SELECT_NUM, snd_data, sizeof( snd_data ) );
while ( !int_flag )
;
-
+
bridge.clear_interrupt();
int_flag = false;
- wait_ms( WAIT_INTERVAL_mS );
+ bridge.read_buffer( rcv_data, sizeof( rcv_data ) );
+ // data_check( rcv_data, DATA_LENGTH );
}
}
+
+
+void data_check( char *data, int length )
+{
+ for ( int i = 0; i < length; i++ ) {
+ if ( !(i % 16) )
+ printf( "\r\n %02X :", i );
+ printf( " %02X", data[ i ] );
+ }
+
+}