Implemented toggle function for pins

This commit is contained in:
BlackMark committed 2019-01-02 20:54:29 +01:00
1 parent 42bc1147b8
commit cf3e0664b5
1 file changed
+14 -3
+14 -3
View File
@@ -1,7 +1,7 @@
/*
* Copyright (c) by BlackMark 2015-2018
* Date 26/04/2018
* Version 3.0
* Copyright (c) by BlackMark 2015-2019
* Date 02/01/2019
* Version 3.1
*/
#ifndef INOUT_H
@@ -207,6 +207,7 @@ public:
static inline bool read() __attribute__( (always_inline) );
static inline void write( bool bValue ) __attribute__( (always_inline) );
static inline void toggle() __attribute__( (always_inline) );
};
//////////////////////////////////////////////////////////////////////////
@@ -255,6 +256,16 @@ inline void InOutPin<enmPin>::write( bool bValue )
*vpui8PORT &= ~( 1 << ui8Pin );
}
//////////////////////////////////////////////////////////////////////////
template<InOut::Pin enmPin>
inline void InOutPin<enmPin>::toggle()
{
constexpr volatile uint8_t *vpui8PORT = InOut::getPort( enmPin, InOut::Type::PORT );
constexpr uint8_t ui8Pin = InOut::getPin( enmPin );
*vpui8PORT ^= ( 1 << ui8Pin );
}
/************************************************************************/
//////////////////////////////////////////////////////////////////////////