mtgos-kernel/kernel/hw/raspi2/uart/uart.cpp
Morten Delenk d0736af522 added broken raspi2 port
fixed all arm ports
2017-07-20 09:26:35 +01:00

25 lines
620 B
C++

#include "uart.hpp"
static volatile uint32_t x;
auto delay = [&x](uint32_t count) {
for(x=0;x<count;x++);
};
UART &UART::getInstance() {
static UART instance;
return instance;
}
uint32_t &UART::operator[](uint32_t off) {
return *((uint32_t*)(0x3F200000+off));
}
uint32_t &UART::operator[](UART_MEM off) {
return (*this)[(uint32_t)off];
}
UART::UART() {
auto &self = *this;
self[UART_MEM::CR] = 0;
self[UART_MEM::GPPUD] = 0;
delay(150);
self[UART_MEM::GPPUDCLK0] = (3 << 14);
delay(150);
self[UART_MEM::GPPUDCLK0] = 0;
self[UART_MEM::ICR] = 0x7FF; //Clear interrupts
}