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.
GpioDigitalInOut.cpp
00001 #include "mbed.h" 00002 #include "GpioDigitalInOut.h" 00003 00004 GpioDigitalInOut::GpioDigitalInOut( CompGpioExp &gpiop, GpioPinName pin_name ) 00005 : gpio_p( &gpiop ), pin( pin_name ), output_state( 1 ), config_state( 1 ) 00006 { 00007 this->input(); 00008 } 00009 00010 GpioDigitalInOut::~GpioDigitalInOut() 00011 { 00012 } 00013 00014 void GpioDigitalInOut::write( int v ) 00015 { 00016 output_state = v; 00017 gpio_p->write( pin, output_state ); 00018 } 00019 00020 void GpioDigitalInOut::configure( int pin, int v ) 00021 { 00022 config_state = v; 00023 gpio_p->configure( pin, config_state ); 00024 } 00025 00026 int GpioDigitalInOut::read( void ) 00027 { 00028 if ( config_state ) 00029 return ( gpio_p->read( pin ) ); 00030 else 00031 return ( output_state ); 00032 } 00033 00034 void GpioDigitalInOut::input( void ) 00035 { 00036 config_state = 1; 00037 gpio_p->configure( pin, config_state ); 00038 } 00039 00040 void GpioDigitalInOut::output( void ) 00041 { 00042 config_state = 0; 00043 gpio_p->configure( pin, config_state ); 00044 } 00045 00046 GpioDigitalInOut& GpioDigitalInOut::operator=( int rhs ) 00047 { 00048 write( rhs ); 00049 return ( *this ); 00050 } 00051 00052 GpioDigitalInOut& GpioDigitalInOut::operator=( GpioDigitalInOut& rhs ) 00053 { 00054 write( rhs.read() ); 00055 return *this; 00056 } 00057 00058 GpioDigitalInOut::operator int( void ) 00059 { 00060 return( read() ); 00061 }
Generated on Tue Jul 12 2022 14:15:36 by
