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.
PCAL6416.cpp
00001 #include "mbed.h" 00002 #include "PCAL6416.h" 00003 00004 00005 PCAL6416::PCAL6416( PinName i2c_sda, PinName i2c_scl, char i2c_address ) 00006 : PCAL955x( i2c_sda, i2c_scl, i2c_address ), n_of_pins( 16 ) 00007 { 00008 } 00009 00010 PCAL6416::PCAL6416( I2C &i2c_obj, char i2c_address ) 00011 : PCAL955x( i2c_obj, i2c_address ), n_of_pins( 16 ) 00012 { 00013 } 00014 00015 PCAL6416::~PCAL6416() 00016 { 00017 } 00018 00019 int PCAL6416::number_of_pins( void ) 00020 { 00021 return ( n_of_pins ); 00022 } 00023 00024 void PCAL6416::reg_index_write( char reg_index, int data ) 00025 { 00026 char a[ 3 ]; 00027 00028 a[ 0 ] = regmap[ reg_index ]; 00029 a[ 1 ] = data; 00030 a[ 2 ] = data >> 8; 00031 00032 bus_write( a, sizeof( a ) ); 00033 } 00034 00035 int PCAL6416::reg_index_read( char reg_index ) 00036 { 00037 char a[ 2 ]; 00038 00039 bus_read( regmap[ reg_index ], a, sizeof( a ) ); 00040 00041 return ( ((int)(a[ 1 ]) << 8) | a[ 0 ] ); 00042 } 00043 00044 PCAL6416& PCAL6416::operator= ( int bit_pattern ) 00045 { 00046 write( bit_pattern ); 00047 return ( *this ); 00048 } 00049 00050 PCAL6416& PCAL6416::operator= ( PCAL6416& rhs ) 00051 { 00052 write( rhs.read() ); 00053 return *this; 00054 } 00055 00056 const char PCAL6416::regmap[] = { 00057 InputPort, 00058 OutoutPort, 00059 PolarityInversionPort, 00060 ConfigurationPort, 00061 OutputDriveStrength0, 00062 OutputDriveStrength1, 00063 InputLatch, 00064 PullUpPullDowmEnable, 00065 PullUpPullDowmSelection, 00066 InterruptMask, 00067 InterruptStatus, 00068 OutputPortConfiguration 00069 };
Generated on Tue Jul 12 2022 14:15:36 by
