diff options
author | Nao Pross <naopross@thearcway.org> | 2018-05-04 18:27:12 +0200 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2018-05-04 18:27:12 +0200 |
commit | 5e8e628da03121323351e54e6866826288e4c4bd (patch) | |
tree | 4b3476cec9c295b5c633ea6b801815a131e2780b /hal/pin.tpp | |
parent | Add templated generic implementaions for uart, rename uart1.tpp to uart.tpp (diff) | |
download | SAMLiquidSmoke-5e8e628da03121323351e54e6866826288e4c4bd.tar.gz SAMLiquidSmoke-5e8e628da03121323351e54e6866826288e4c4bd.zip |
Implement most of basic HAL
Oscillator:
The oscillator is configured correctly.
Interrupts:
RX uart interrupts work.
The global interrupt vector table is enabled.
UART:
RX features work.
Diffstat (limited to '')
-rw-r--r-- | hal/pin.tpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/hal/pin.tpp b/hal/pin.tpp index c6cf957..3954945 100644 --- a/hal/pin.tpp +++ b/hal/pin.tpp @@ -1,10 +1,12 @@ /* - * File: pin.cpp + * File: pin.tpp * Author: naopross * * Created on May 3, 2018, 8:02 PM */ +#ifndef PIN_TPP +#define PIN_TPP #include "pin.hpp" @@ -32,21 +34,21 @@ template<unsigned bit> void pin<bit>::set_mode(unsigned m) { if (m) - *_tris |= 1<<bit; + *_tris |= 1<<bit; // input else - *_tris &= ~(1<<bit); + *_tris &= ~(1<<bit); // output } template<unsigned bit> void pin<bit>::set_mode(pin<bit>::mode m) { - set(static_cast<unsigned>(m)); + set_mode(static_cast<unsigned>(m)); } template<unsigned bit> typename pin<bit>::state pin<bit>::read() const { - if (*_tris & (1<<bit)) + if (*_port & (1<<bit)) return state::ON; else return state::OFF; @@ -55,10 +57,10 @@ typename pin<bit>::state pin<bit>::read() const template<unsigned bit> void pin<bit>::set(unsigned s) { - if (s) - *_latch |= 1<<bit; + if (s > 0) + *_latch |= 1<<bit; // on else - *_latch &= ~(1<<bit); + *_latch &= ~(1<<bit); // off } template<unsigned bit> @@ -86,3 +88,5 @@ bool pin<bit>::operator!=(const pin<bit> &other) const { return !(*this == other); } + +#endif
\ No newline at end of file |