diff options
Diffstat (limited to 'hal/pin.tpp')
-rw-r--r-- | hal/pin.tpp | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/hal/pin.tpp b/hal/pin.tpp index c3c005f..c6cf957 100644 --- a/hal/pin.tpp +++ b/hal/pin.tpp @@ -11,13 +11,13 @@ template<unsigned bit> template<typename latch_T, typename tris_T, typename port_T> pin<bit>::pin(latch_T *latch, tris_T *tris, port_T *port) : - _latch(reinterpret_cast<volatile uint8_t *>(latch)), - _tris(reinterpret_cast<volatile uint8_t *>(tris)), - _port(reinterpret_cast<volatile uint8_t *>(port)) + _latch(reinterpret_cast<volatile uint8_t *>(latch)), + _tris(reinterpret_cast<volatile uint8_t *>(tris)), + _port(reinterpret_cast<volatile uint8_t *>(port)) { - // default settings - set_mode(pin<bit>::mode::OUTPUT); - set(pin<bit>::state::OFF); + // default settings + set_mode(pin<bit>::mode::OUTPUT); + set(pin<bit>::state::OFF); } @@ -31,58 +31,58 @@ pin<bit>::~pin() template<unsigned bit> void pin<bit>::set_mode(unsigned m) { - if (m) - *_tris |= 1<<bit; - else - *_tris &= ~(1<<bit); + if (m) + *_tris |= 1<<bit; + else + *_tris &= ~(1<<bit); } template<unsigned bit> void pin<bit>::set_mode(pin<bit>::mode m) { - set(static_cast<unsigned>(m)); + set(static_cast<unsigned>(m)); } template<unsigned bit> typename pin<bit>::state pin<bit>::read() const { - if (*_tris & (1<<bit)) - return state::ON; - else - return state::OFF; + if (*_tris & (1<<bit)) + return state::ON; + else + return state::OFF; } template<unsigned bit> void pin<bit>::set(unsigned s) { - if (s) - *_latch |= 1<<bit; - else - *_latch &= ~(1<<bit); + if (s) + *_latch |= 1<<bit; + else + *_latch &= ~(1<<bit); } template<unsigned bit> void pin<bit>::set(pin<bit>::state s) { - set(static_cast<unsigned>(s)); + set(static_cast<unsigned>(s)); } template<unsigned bit> void pin<bit>::toggle() { - *_latch ^= 1<<bit; + *_latch ^= 1<<bit; } template<unsigned bit> bool pin<bit>::operator==(const pin<bit> &other) const { - return (_latch == other._latch - && _tris == other._tris - && _port == other._port); + return (_latch == other._latch + && _tris == other._tris + && _port == other._port); } template<unsigned bit> bool pin<bit>::operator!=(const pin<bit> &other) const { - return !(*this == other); -}
\ No newline at end of file + return !(*this == other); +} |