static void serial_hardware_init(int speed, int word_bits, int parity, int stop_bits) { unsigned char reg; #if !IS_ENABLED(CONFIG_LP_PL011_SERIAL_CONSOLE) /* Disable interrupts. */ serial_write_reg(0, 0x01); /* Assert RTS and DTR. */ serial_write_reg(3, 0x04); /* Set the divisor latch. */ reg = serial_read_reg(0x03); serial_write_reg(reg | 0x80, 0x03); /* Write the divisor. */ uint16_t divisor = 115200 / speed; serial_write_reg(divisor & 0xFF, 0x00); serial_write_reg(divisor >> 8, 0x01); /* Restore the previous value of the divisor. * And set 8 bits per character */ serial_write_reg((reg & ~0x80) | 3, 0x03); #endif }
int serial_getchar(void) { if (!serial_hardware_is_present) return -1; while (!serial_havechar()) ; return serial_read_reg(0x00); }
void serial_putchar(unsigned int c) { if (!serial_hardware_is_present) return; while ((serial_read_reg(0x05) & 0x20) == 0) ; serial_write_reg(c, 0x00); if (c == '\n') serial_putchar('\r'); }
void serial_putchar(unsigned int c) { if (!serial_hardware_is_present) return; #if !IS_ENABLED(CONFIG_LP_PL011_SERIAL_CONSOLE) while ((serial_read_reg(0x05) & 0x20) == 0) ; #endif serial_write_reg(c, 0x00); }
void serial_putchar(unsigned int c) { if (!serial_hardware_is_present) return; #if !CONFIG(LP_PL011_SERIAL_CONSOLE) while ((serial_read_reg(0x05) & 0x20) == 0) ; #endif serial_write_reg(c, 0x00); if (c == '\n') serial_putchar('\r'); }
int serial_havechar(void) { if (!serial_hardware_is_present) return 0; return serial_read_reg(0x05) & 0x01; }