void sprint(uint8_t* buf, uint16_t len){ if(is_configured == 1){ serial_configure_bit_rate(SERIAL_COM1_BASE, 1); serial_configure_line(SERIAL_COM1_BASE); serial_configure_fifo(SERIAL_COM1_BASE); serial_configure_modem(SERIAL_COM1_BASE); is_configured = 1; } for(unsigned int i = 0; i < len; i++){ while(serial_is_transmit_fifo_empty(SERIAL_COM1_BASE) == 0); outb(SERIAL_DATA_PORT(SERIAL_COM1_BASE), buf[i]); } }
void serial_init() { #if 0 outb(SERIAL_COM1 + 1, 0x00); // Disable all interrupts outb(SERIAL_COM1 + 3, 0x80); // Enable DLAB (set baud rate divisor) outb(SERIAL_COM1 + 0, 0x01); // Set divisor to 3 (lo byte) 38400 baud outb(SERIAL_COM1 + 1, 0x00); // (hi byte) outb(SERIAL_COM1 + 3, 0x03); // 8 bits, no parity, one stop bit outb(SERIAL_COM1 + 2, 0xC7); // Enable FIFO, clear them, with 14-byte threshold outb(SERIAL_COM1 + 4, 0x0B); // IRQs enabled, RTS/DSR set #else /*Set baud rate to be 115200*/ serial_configure_baud_rate(SERIAL_COM1, 1); /* 8 bits, no parity, one stop bit, no break control */ serial_configure_line(SERIAL_COM1, SERIAL_8N1); serial_configure_fifo(SERIAL_COM1, SERIAL_FIFO_14); serial_configure_modem(SERIAL_COM1, SERIAL_RTS_DTR); #endif }