test version 0.2
Dependents: SC18IS606_Hello SC18IS606_EEPROM_access_test SC18IS606_OS6_Hello
Revision 1:b44f801ac9f2, committed 2021-07-13
- Comitter:
- okano
- Date:
- Tue Jul 13 10:45:46 2021 +0000
- Parent:
- 0:d4d72026aaf3
- Child:
- 2:4e64923032ad
- Commit message:
- class lib version 0.1 (only data send test had been done)
Changed in this revision
--- a/SC18IS606.c Tue Jul 13 08:33:47 2021 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/* - * SC18IS606 library - * - * @author Akifumi (Tedd) OKANO, NXP Semiconductors - * @version 0.1 - * @date 13-Jul-2021 - * - * SC18IS606 is a - * http://www.nxp.com/ - */ - -#include "mbed.h" -#include "SC18IS606.h" - -SC18IS606::SC18IS606( PinName sda, PinName sdl, char i2c_address ) - : i2c_p( new I2C( sda, sdl ) ), i2c( *i2c_p ), device_address( i2c_address ) -{ - init(); -} - -SC18IS606::SC18IS606( I2C &i2c_, i2c_address ) - : i2c_p( NULL ), i2c( i2c_ ), device_address( i2c_address ) -{ - init(); -} - -SC18IS606::~SC18IS606() -{ - if ( NULL != i2c_p ) - delete i2c_p; -} - -int SC18IS606::init( void ) -{ - // dummy -} - - -int SC18IS606::transfer( char *send_data_ptr, char *receive_data_ptr, int length ) -{ - char *p - p = new char[ length + 1 ]; - - *p = SPI_read_and_write; - memcpy( p + 1, send_data_ptr, length ); - i2c.write( device_address, p, length + 1 ); - delete[] p; - - 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 ]; - s[ 0 ] = fid; - s[ 1 ] = data; - i2c.write( device_address, s, sizeof( s ) ); - - return 0; // dummy -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SC18IS606.cpp Tue Jul 13 10:45:46 2021 +0000 @@ -0,0 +1,72 @@ +/* + * SC18IS606 library + * + * @author Akifumi (Tedd) OKANO, NXP Semiconductors + * @version 0.1 + * @date 13-July-2021 + * + * SC18IS606 is an "I2C-bus to SPI bridge" + * http://www.nxp.com/ (product infomation page will be updated later) + */ + +#include "mbed.h" +#include "SC18IS606.h" + +SC18IS606::SC18IS606( PinName sda, PinName scl, char i2c_address ) + : i2c_p( new I2C( sda, scl ) ), i2c( *i2c_p ), device_address( i2c_address ) +{ + init(); +} + +SC18IS606::SC18IS606( I2C &i2c_, char i2c_address ) + : i2c_p( NULL ), i2c( i2c_ ), device_address( i2c_address ) +{ + init(); +} + +SC18IS606::~SC18IS606() +{ + if ( NULL != i2c_p ) + delete i2c_p; +} + +int SC18IS606::init( void ) +{ + return 0; // dummy +} + + +int SC18IS606::transfer( char *send_data_ptr, char *receive_data_ptr, int length ) +{ + char *p; + p = new char[ length + 1 ]; + + *p = SPI_read_and_write; + memcpy( p + 1, send_data_ptr, length ); + i2c.write( device_address, p, length + 1 ); + delete[] p; + + 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 ]; + s[ 0 ] = fid; + s[ 1 ] = data; + i2c.write( device_address, s, sizeof( s ) ); + + return 0; // dummy +} + +int SC18IS606::clear_interrupt( void ) +{ + char c = Clear_Interrupt; + i2c.write( device_address, &c, sizeof( c ) ); + + return 0; // dummy +}
--- a/SC18IS606.h Tue Jul 13 08:33:47 2021 +0000 +++ b/SC18IS606.h Tue Jul 13 10:45:46 2021 +0000 @@ -5,17 +5,15 @@ * @version 0.1 * @date 13-July-2021 * - * SC18IS606 is a - * http://www.nxp.com/ - * - * RTC initializing part is ported from.. - * http://mbed.org/users/roen/notebook/real-time/ + * SC18IS606 is an "I2C-bus to SPI bridge" + * http://www.nxp.com/ (product infomation page will be updated later) */ +#include "mbed.h" + #ifndef MBED_SC18IS606 #define MBED_SC18IS606 -#include "mbed.h" /** SC18IS606 class * @@ -26,8 +24,6 @@ * @endcode */ -#define DEFAULT_I2C_SLAVE_ADDRESS 0x50 - class SC18IS606 { public: @@ -38,7 +34,7 @@ Configure_SPI_Interface = 0xF0, Clear_Interrupt, Idle_mode, - GPIO_Write = 0xF4, + GPIO_Write = 0xF4, GPIO_Read, GPIO_Enable, GPIO_Configuration @@ -56,11 +52,11 @@ * * @param i2c I2C object (instance) */ - PCF2127( I2C &i2c, char i2c_address = DEFAULT_I2C_SLAVE_ADDRESS ); + SC18IS606( I2C &i2c, char i2c_address = DEFAULT_I2C_SLAVE_ADDRESS ); /** Destractor */ - ~PCF2127(); + ~SC18IS606(); /** Transfer (send and receive) data * @@ -78,17 +74,23 @@ */ int config( FunctionID fid, char data ); + /** Clear interrupt + * + * @return dummy + */ + int clear_interrupt( void ); + private: enum { - DEFAULT_I2C_SLAVE_ADDRESS = 0x90 + DEFAULT_I2C_SLAVE_ADDRESS = 0x50 }; + int init( void ); + I2C *i2c_p; I2C &i2c; char device_address; }; -} -; #endif // end of "#ifndef MBED_SC18IS606"