diff options
Diffstat (limited to '')
-rw-r--r-- | hal/pin.hpp | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/hal/pin.hpp b/hal/pin.hpp index 9df22d4..6625f90 100644 --- a/hal/pin.hpp +++ b/hal/pin.hpp @@ -8,16 +8,39 @@ #ifndef PIN_HPP #define PIN_HPP -template<typename reg, unsigned bit> +template<unsigned bit> class pin { public: - pin(reg *r); + enum class mode : unsigned + { INPUT = 1, OUTPUT = 0 }; + + enum class state : unsigned + { ON = 1, OFF = 0 }; + + pin() = delete; + + template<typename latch_T, typename tris_T, typename port_T> + pin(latch_T *latch, tris_T *tris, port_T *port); + virtual ~pin(); - void set(bool v); + void set_mode(unsigned m); + void set_mode(mode m); + + state read() const; + + void set(unsigned s); + void set(state s); + + void toggle(); + + bool operator==(const pin<bit> &other) const; + bool operator!=(const pin<bit> &other) const; private: - reg *_register; + volatile uint8_t *_latch; + volatile uint8_t *_tris; + volatile uint8_t *_port; }; #endif /* PIN_HPP */
\ No newline at end of file |