From 601ee769f5ceeab7c71e61806804e4788f279c59 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Sat, 5 May 2018 17:13:59 +0200 Subject: Rename class pin to io_pin, add general gpio class, add uart echo --- hal/pin.tpp | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'hal/pin.tpp') diff --git a/hal/pin.tpp b/hal/pin.tpp index 3954945..42d03de 100644 --- a/hal/pin.tpp +++ b/hal/pin.tpp @@ -12,26 +12,26 @@ template template -pin::pin(latch_T *latch, tris_T *tris, port_T *port) : +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(pin::mode::OUTPUT); - set(pin::state::OFF); + set_mode(io_pin::mode::OUTPUT); + set(io_pin::state::OFF); } template -pin::~pin() +io_pin::~io_pin() { } template -void pin::set_mode(unsigned m) +void io_pin::set_mode(unsigned m) { if (m) *_tris |= 1<::set_mode(unsigned m) } template -void pin::set_mode(pin::mode m) +void io_pin::set_mode(io_pin::mode m) { set_mode(static_cast(m)); } template -typename pin::state pin::read() const +unsigned io_pin::read() const { - if (*_port & (1< -void pin::set(unsigned s) +void io_pin::set(unsigned s) { if (s > 0) *_latch |= 1<::set(unsigned s) } template -void pin::set(pin::state s) +void io_pin::set(io_pin::state s) { set(static_cast(s)); } template -void pin::toggle() +void io_pin::toggle() { *_latch ^= 1< -bool pin::operator==(const pin &other) const +bool io_pin::operator==(const io_pin &other) const { return (_latch == other._latch && _tris == other._tris @@ -84,7 +81,7 @@ bool pin::operator==(const pin &other) const } template -bool pin::operator!=(const pin &other) const +bool io_pin::operator!=(const io_pin &other) const { return !(*this == other); } -- cgit v1.2.1