diff options
Diffstat (limited to '')
-rw-r--r-- | hal/pin.tpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/hal/pin.tpp b/hal/pin.tpp index c6cf957..3954945 100644 --- a/hal/pin.tpp +++ b/hal/pin.tpp @@ -1,10 +1,12 @@ /* - * File: pin.cpp + * File: pin.tpp * Author: naopross * * Created on May 3, 2018, 8:02 PM */ +#ifndef PIN_TPP +#define PIN_TPP #include "pin.hpp" @@ -32,21 +34,21 @@ template<unsigned bit> void pin<bit>::set_mode(unsigned m) { if (m) - *_tris |= 1<<bit; + *_tris |= 1<<bit; // input else - *_tris &= ~(1<<bit); + *_tris &= ~(1<<bit); // output } template<unsigned bit> void pin<bit>::set_mode(pin<bit>::mode m) { - set(static_cast<unsigned>(m)); + set_mode(static_cast<unsigned>(m)); } template<unsigned bit> typename pin<bit>::state pin<bit>::read() const { - if (*_tris & (1<<bit)) + if (*_port & (1<<bit)) return state::ON; else return state::OFF; @@ -55,10 +57,10 @@ typename pin<bit>::state pin<bit>::read() const template<unsigned bit> void pin<bit>::set(unsigned s) { - if (s) - *_latch |= 1<<bit; + if (s > 0) + *_latch |= 1<<bit; // on else - *_latch &= ~(1<<bit); + *_latch &= ~(1<<bit); // off } template<unsigned bit> @@ -86,3 +88,5 @@ bool pin<bit>::operator!=(const pin<bit> &other) const { return !(*this == other); } + +#endif
\ No newline at end of file |