avr-something

Something something AVR side…
git clone git://henryandlizzy.uk/avr-something
Log | Files | Refs | README

commit 99217a38ca823950df30aab22cc5856cdebeb5cf
parent f729aeca86b6eae7eaf9e231fbaafd9b14bb8822
Author: Henry Wilson <m3henry@googlemail.com>
Date:   Sun,  4 Feb 2018 21:58:20 +0000

starting reding pictor

Diffstat:
Mled-test.cpp | 83++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------
1 file changed, 57 insertions(+), 26 deletions(-)

diff --git a/led-test.cpp b/led-test.cpp @@ -2,34 +2,65 @@ #include "io.h" #include <util/delay.h> -int main(void) +constexpr uint8_t bit(const uint8_t shift) { - io::direction::B() = 0xFF; - - // OCR0A - auto& val = memory(0x47); - - // TCCR0B - memory(0x45) = 0x05; - // TCCR0A - memory(0x44) = 0xC3; - +// static_assert(8 > shift, "must be in range (0, 7)"); + return uint8_t(1) << shift; +} - uint8_t i = 0x00; - for (;;) +namespace lcd +{ + auto& control() + { + return io::pin::A(); + } + auto& data() + { + return io::pin::C(); + } + + namespace signal + { + constexpr auto select_n = bit(0); + constexpr auto backlight = bit(1); + constexpr auto reset_n = bit(2); + constexpr auto write_n = bit(3); + constexpr auto command_n = bit(4); + constexpr auto read_n = bit(5); + constexpr auto vSync = bit(6); + constexpr auto hSync = bit(7); + } + + void init() + { + control() = 0b11111001; + io::direction::A() = 0xFF; + io::direction::C() = 0xFF; + +// FMARK VSYNC !READ DATA/!CTRL !WRITE !RESET BACKLI !CHIPSELECT + + _delay_ms(16); + control() = 0xFF; + } + void writeCommand(const uint8_t cmd) { - do - { - i <<= 1; - i |= 1; - val = i; - _delay_ms(500); - } while (0xFF != i); - do - { - i >>= 1; - val = i; - _delay_ms(500); - } while (i); + // control sequence probably wrong! + + using namespace signal; + control() = ~command_n; + data() = cmd; + control() = ~(command_n | write_n); + control() = 0xFF; } } + +int main(void) +{ + auto& mcuCtrl = memory(0x55); + mcuCtrl |= 0x80; + mcuCtrl |= 0x80; + + lcd::init(); + + for(;;); +}