/* * File: pin.tpp * Author: naopross * * Created on May 3, 2018, 8:02 PM */ #ifndef PIN_TPP #define PIN_TPP #include "pin.hpp" template template pin::pin(latch_T *latch, tris_T *tris, port_T *port) : _latch(reinterpret_cast(latch)), _tris(reinterpret_cast(tris)), _port(reinterpret_cast(port)) { // default settings set_mode(pin::mode::OUTPUT); set(pin::state::OFF); } template pin::~pin() { } template void pin::set_mode(unsigned m) { if (m) *_tris |= 1< void pin::set_mode(pin::mode m) { set_mode(static_cast(m)); } template typename pin::state pin::read() const { if (*_port & (1< void pin::set(unsigned s) { if (s > 0) *_latch |= 1< void pin::set(pin::state s) { set(static_cast(s)); } template void pin::toggle() { *_latch ^= 1< bool pin::operator==(const pin &other) const { return (_latch == other._latch && _tris == other._tris && _port == other._port); } template bool pin::operator!=(const pin &other) const { return !(*this == other); } #endif