Fix WritePort mistakes in the serial file.

This commit is contained in:
Curle 2019-08-20 16:39:20 +01:00
parent 927aeb0872
commit d830acbbd4

View File

@ -35,13 +35,13 @@
void serial_set_baud_rate(uint16_t com, uint16_t divisor) {
WritePort(SERIAL_LINE_COMMAND_PORT(com),
SERIAL_LINE_ENABLE_DLAB, 8);
SERIAL_LINE_ENABLE_DLAB, 1);
WritePort(SERIAL_DATA_PORT(com),
(divisor >> 8) & 0x00FF, 8);
(divisor >> 8) & 0x00FF, 1);
WritePort(SERIAL_DATA_PORT(com),
divisor & 0x00FF, 8);
divisor & 0x00FF, 1);
}
@ -54,11 +54,11 @@ void serial_set_baud_rate(uint16_t com, uint16_t divisor) {
void serial_configure_line(uint16_t com) {
/* Bit: | 7 | 6 | 5 4 3 | 2 | 1 0 |
* Content: | d | b | parity| s | dl |
* Content: | d | b | parity | s | dl |
* Value: | 0 | 0 | 0 0 0 | 0 | 1 1 | = 0x03
*/
WritePort(SERIAL_LINE_COMMAND_PORT(com), 0x0B, 8);
WritePort(SERIAL_LINE_COMMAND_PORT(com), 0x0B, 1);
}
/** serial_configure_buffers:
@ -75,7 +75,7 @@ void serial_configure_buffers(uint16_t com) {
* Value: | 1 1 | 0 | 0 | 0 | 1 | 1 | 1 | = 0xC7
*/
WritePort(SERIAL_FIFO_COMMAND_PORT(com), 0xC7, 8);
WritePort(SERIAL_FIFO_COMMAND_PORT(com), 0xC7, 1);
}
/** serial_configure_modem
@ -88,7 +88,7 @@ void serial_configure_modem(uint16_t com) {
* Value: | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | = 0x03
*/
WritePort(SERIAL_MODEM_COMMAND_PORT(com), 0x3, 8);
WritePort(SERIAL_MODEM_COMMAND_PORT(com), 0x3, 1);
}
/** serial_check_tqueue:
@ -100,7 +100,7 @@ void serial_configure_modem(uint16_t com) {
*/
int serial_check_tqueue(uint16_t com) {
return ReadPort(SERIAL_LINE_STATUS_PORT(com), 8) & 0x20;
return ReadPort(SERIAL_LINE_STATUS_PORT(com), 1) & 0x20;
}
/** serial_write:
@ -110,10 +110,11 @@ int serial_check_tqueue(uint16_t com) {
* @param data The character to write.
*/
void serial_write(uint16_t com, const char chr) {
void serial_write(const char chr) {
uint16_t com = SERIAL_COM1_BASE;
//Hang until we have access to the COM port.
while(serial_check_tqueue(com) == 0);
WritePort(com, chr, 0);
WritePort(com, chr, 1);
}
/** serial_print:
@ -124,9 +125,9 @@ void serial_write(uint16_t com, const char chr) {
* @param data The string to write.
*/
void serial_print(uint16_t com, const char* data) {
void serial_print(const char* data) {
for(size_t i = 0; i < strlen(data); i++) {
serial_write(com, data[i]);
serial_write(data[i]);
}
}
@ -137,7 +138,8 @@ void serial_print(uint16_t com, const char* data) {
* @param ... The substitutions.
*/
void serial_printf(uint16_t com, const char* format, ...) {
void serial_printf(const char* format, ...) {
uint16_t com = SERIAL_COM1_BASE;
uint32_t storage; //To hold temporary variables
char stringstore[10] = {0}; //To convert ints to strings.
va_list list;
@ -151,7 +153,7 @@ void serial_printf(uint16_t com, const char* format, ...) {
storage = va_arg(list, int);
int_to_ascii(storage, stringstore);
serial_print(com, stringstore);
serial_print(stringstore);
empty_string(stringstore);
i += 2;
@ -159,21 +161,21 @@ void serial_printf(uint16_t com, const char* format, ...) {
storage = va_arg(list, int);
int_to_hex(storage, stringstore);
serial_print(com, stringstore);
serial_print(stringstore);
empty_string(stringstore);
i += 2;
} else if(format[i+1] == 's') {
serial_print(com, va_arg(list, char*));
serial_print(va_arg(list, char*));
i += 2;
} else {
serial_print(com, "ERROR: Attempting to parse unknown format string.");
serial_print("ERROR: Attempting to parse unknown format string.");
return;
}
} else {
serial_write(com, format[i]);
serial_write(format[i]);
i++;
}
}
@ -182,7 +184,7 @@ void serial_printf(uint16_t com, const char* format, ...) {
void init_serial() {
// Disable interrupts
WritePort(SERIAL_COM1_BASE + 1, 0x00, 0);
WritePort(SERIAL_COM1_BASE + 1, 0x00, 1);
// Set baud rate divisor.
serial_set_baud_rate(SERIAL_COM1_BASE, 3);