diff --git a/InOut.cpp b/inout.cpp similarity index 99% rename from InOut.cpp rename to inout.cpp index ca576e5..1bb3c2d 100644 --- a/InOut.cpp +++ b/inout.cpp @@ -1,17 +1,17 @@ -#include "InOut.h" +#include "inout.h" ////////////////////////////////////////////////////////////////////////// volatile uint8_t* InOut::getPort( Pin enmPin, Type enmType ) { volatile uint8_t *vpui8Port = nullptr; - + if( enmPin == Pin::P_NONE ) { return vpui8Port; } - + uint8_t ui8Port = ( static_cast( enmPin ) >> 4 ) & 0x0F; - + switch( ui8Port ) { case 0: @@ -99,13 +99,13 @@ void InOut::setPinDirection( Pin enmPin, Dir enmDir, bool bPullup ) { return; } - + volatile uint8_t *vpui8PortDir = getPort( enmPin, Type::T_DDR ); volatile uint8_t *vpui8PortOut = getPort( enmPin, Type::T_PORT ); uint8_t ui8Pin = getPin( enmPin ); - + setPinDirection( vpui8PortDir, ui8Pin, enmDir ); - + if( enmDir == Dir::D_IN ) { writePin( vpui8PortOut, ui8Pin, bPullup ); @@ -119,10 +119,10 @@ bool InOut::readPin( Pin enmPin ) { return false; } - + volatile uint8_t *vpui8Port = getPort( enmPin, Type::T_PIN ); uint8_t ui8Pin = getPin( enmPin ); - + return readPin( vpui8Port, ui8Pin ); } @@ -133,7 +133,7 @@ void InOut::writePin( Pin enmPin, bool bValue ) { return; } - + volatile uint8_t *vpui8Port = getPort( enmPin, Type::T_PORT ); uint8_t ui8Pin = getPin( enmPin ); @@ -147,9 +147,9 @@ uint8_t InOut::readPort( Pin enmPortPin ) { return 0; } - + volatile uint8_t *vpui8Port = getPort( enmPortPin, Type::T_PIN ); - + return readPort( vpui8Port ); } @@ -160,7 +160,7 @@ void InOut::writePort( Pin enmPortPin, uint8_t ui8Value ) { return; } - + volatile uint8_t *vpui8Port = getPort( enmPortPin, Type::T_PORT ); writePort( vpui8Port, ui8Value ); @@ -190,7 +190,7 @@ void InOutPin::setPin( InOut::Pin enmPin ) m_vpui8Input = InOut::getPort( enmPin, InOut::Type::T_PIN ); m_vpui8Dir = InOut::getPort( enmPin, InOut::Type::T_DDR ); m_vpui8Output = InOut::getPort( enmPin, InOut::Type::T_PORT ); - + m_ui8Pin = InOut::getPin( enmPin ); } @@ -218,4 +218,4 @@ void InOutPort::setPort( InOut::Pin enmPortPin ) m_vpui8Input = InOut::getPort( enmPortPin, InOut::Type::T_PIN ); m_vpui8Dir = InOut::getPort( enmPortPin, InOut::Type::T_DDR ); m_vpui8Output = InOut::getPort( enmPortPin, InOut::Type::T_PORT ); -} \ No newline at end of file +} diff --git a/InOut.h b/inout.h similarity index 98% rename from InOut.h rename to inout.h index 61de1e0..1da178a 100644 --- a/InOut.h +++ b/inout.h @@ -116,17 +116,17 @@ public: T_DDR = 1, T_PORT = 2 }; - + static volatile uint8_t* getPort( Pin enmPin, Type enmType ); static uint8_t getPin( Pin enmPin ); - + static void setPinDirection( Pin enmPin, Dir enmDir, bool bPullup ); static bool readPin( Pin enmPin ); static void writePin( Pin enmPin, bool bValue ); - + static uint8_t readPort( Pin enmPortPin ); static void writePort( Pin enmPortPin, uint8_t ui8Value ); - + ////////////////////////////////////////////////////////////////////////// static inline void setPinDirection( volatile uint8_t *vpui8Port, uint8_t ui8Pin, Dir enmDir ) { @@ -139,7 +139,7 @@ public: *vpui8Port &= ~( 1 << ui8Pin ); } } - + ////////////////////////////////////////////////////////////////////////// static inline bool readPin( volatile uint8_t *vpui8Port, uint8_t ui8Pin ) { @@ -147,10 +147,10 @@ public: { return true; } - + return false; } - + ////////////////////////////////////////////////////////////////////////// static inline void writePin( volatile uint8_t *vpui8Port, uint8_t ui8Pin, bool bValue ) { @@ -163,19 +163,19 @@ public: *vpui8Port &= ~( 1 << ui8Pin ); } } - + ////////////////////////////////////////////////////////////////////////// static inline void setPortDirection( volatile uint8_t *vpui8Port, Dir enmDir ) { *vpui8Port = ( ( enmDir == InOut::Dir::D_OUT ) ? ( 0xFF ) : ( 0x00 ) ); } - + ////////////////////////////////////////////////////////////////////////// static inline uint8_t readPort( volatile uint8_t *vpui8Port ) { return *vpui8Port; } - + ////////////////////////////////////////////////////////////////////////// static inline void writePort( volatile uint8_t *vpui8Port, uint8_t ui8Value ) { @@ -191,16 +191,16 @@ private: volatile uint8_t *m_vpui8Input; volatile uint8_t *m_vpui8Dir; volatile uint8_t *m_vpui8Output; - + uint8_t m_ui8Pin; - + public: InOutPin(); InOutPin( InOut::Pin enmPin ); ~InOutPin(); - + void setPin( InOut::Pin enmPin ); - + ////////////////////////////////////////////////////////////////////////// inline void setDirection( InOut::Dir enmDir, bool bPullup ) { @@ -208,15 +208,15 @@ public: { return; } - + InOut::setPinDirection( m_vpui8Dir, m_ui8Pin, enmDir ); - + if( enmDir == InOut::Dir::D_IN ) { InOut::writePin( m_vpui8Output, m_ui8Pin, bPullup ); } } - + ////////////////////////////////////////////////////////////////////////// inline bool read() { @@ -224,10 +224,10 @@ public: { return false; } - + return InOut::readPin( m_vpui8Input, m_ui8Pin ); } - + ////////////////////////////////////////////////////////////////////////// inline void write( bool bValue ) { @@ -235,7 +235,7 @@ public: { return; } - + InOut::writePin( m_vpui8Output, m_ui8Pin, bValue ); } }; @@ -253,9 +253,9 @@ public: InOutPort(); InOutPort( InOut::Pin enmPortPin ); ~InOutPort(); - + void setPort( InOut::Pin enmPortPin ); - + ////////////////////////////////////////////////////////////////////////// inline void setDirection( InOut::Dir enmDir, bool bPullup ) { @@ -263,15 +263,15 @@ public: { return; } - + InOut::setPortDirection( m_vpui8Dir, enmDir ); - + if( enmDir == InOut::Dir::D_IN ) { InOut::writePort( m_vpui8Output, ( ( bPullup ) ? ( 0xFF ) : ( 0x00 ) ) ); } } - + ////////////////////////////////////////////////////////////////////////// inline uint8_t read() { @@ -279,10 +279,10 @@ public: { return 0; } - + return InOut::readPort( m_vpui8Input ); } - + ////////////////////////////////////////////////////////////////////////// inline void write( uint8_t ui8Value ) { @@ -290,9 +290,9 @@ public: { return; } - + InOut::writePort( m_vpui8Output, ui8Value ); } }; -#endif \ No newline at end of file +#endif