From cf3e0664b516b032caff80990311d515856d6596 Mon Sep 17 00:00:00 2001 From: BlackMark Date: Wed, 2 Jan 2019 20:54:29 +0100 Subject: [PATCH] Implemented toggle function for pins --- inout.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/inout.h b/inout.h index dba5f59..74b17cf 100644 --- a/inout.h +++ b/inout.h @@ -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::write( bool bValue ) *vpui8PORT &= ~( 1 << ui8Pin ); } +////////////////////////////////////////////////////////////////////////// +template +inline void InOutPin::toggle() +{ + constexpr volatile uint8_t *vpui8PORT = InOut::getPort( enmPin, InOut::Type::PORT ); + constexpr uint8_t ui8Pin = InOut::getPin( enmPin ); + + *vpui8PORT ^= ( 1 << ui8Pin ); +} + /************************************************************************/ //////////////////////////////////////////////////////////////////////////