You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1018 B
C++

#include "serial.h"
Serial::Serial(ComPort port, BaudRate baud_rate, DataBits data_bits,
StopBits stop_bits, Parity parity)
: port(port) {
// initialize FIFO mode, no irqs for sending, irq if first byte was received
// line control, select r/w of divisor latch register
writeReg(LINE_CONTROL_REGISTER, DIVISOR_LATCH_ACCESS_BIT);
// TODO: Implement here the correct handling of input arguments
(void)baud_rate;
(void)data_bits;
(void)stop_bits;
(void)parity;
// FIFO: Enable & clear buffers
writeReg(FIFO_CONTROL_REGISTER,
ENABLE_FIFO | CLEAR_RECEIVE_FIFO | CLEAR_TRANSMIT_FIFO);
// Modem Control: OUT2 (0000 1000) must be set for interrupt
writeReg(MODEM_CONTROL_REGISTER, OUT_2);
}
void Serial::writeReg(RegisterIndex reg, char out) {
// TODO: Implement
(void)reg;
(void)out;
}
char Serial::readReg(RegisterIndex reg) {
// TODO: Implement
(void)reg;
return '\0';
}
int Serial::write(char out) {
// TODO: Implement
(void)out;
return 0;
}