/* * File: pin.tpp * Author: naopross * * Created on May 3, 2018, 8:02 PM */ #ifndef PIN_TPP #define PIN_TPP #include "pin.hpp" template template io_pin::io_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(io_pin::mode::OUTPUT); set(io_pin::state::OFF); } template io_pin::~io_pin() { } template void io_pin::set_mode(unsigned m) { if (m) *_tris |= 1< void io_pin::set_mode(io_pin::mode m) { set_mode(static_cast(m)); } template unsigned io_pin::read() const { return (*_port & (1< unsigned io_pin::is_set() const { return (*_latch & (1< void io_pin::set(unsigned s) { if (s > 0) *_latch |= 1< void io_pin::set(io_pin::state s) { set(static_cast(s)); } template void io_pin::toggle() { *_latch ^= 1< bool io_pin::operator==(const io_pin &other) const { return (_latch == other._latch && _tris == other._tris && _port == other._port); } template bool io_pin::operator!=(const io_pin &other) const { return !(*this == other); } #endif