void up_earlyserialinit(void) { (void)z16f_disableuartirq(&TTYS0_DEV); (void)z16f_disableuartirq(&TTYS1_DEV); CONSOLE_DEV.isconsole = true; z16f_setup(&CONSOLE_DEV); }
void up_earlyserialinit(void) { uint8_t regval; /* Configure UART alternate pin functions. This may duplicate logic in * z16f_lowuartinit() or z16f_lowinit(). */ #ifdef CONFIG_Z16F_UART0 /* UART0 is PA4 and PA5, alternate function 1 */ regval = getreg8(Z16F_GPIOA_AFL); regval |= 0x30; putreg8(regval, Z16F_GPIOA_AFL); regval = getreg8(Z16F_GPIOA_AFH); regval &= ~0x30; putreg8(regval, Z16F_GPIOA_AFH); #endif #ifdef CONFIG_Z16F_UART1 /* UART1 is PD4 and PD5, alternate function 1 */ regval = getreg8(Z16F_GPIOD_AFL); regval |= 0x30; putreg8(regval, Z16F_GPIOD_AFL); regval = getreg8(Z16F_GPIOD_AFH); regval &= ~0x30; putreg8(regval, Z16F_GPIOD_AFH); #endif /* Disable UART interrupts */ #ifdef TTYS0_DEV (void)z16f_disableuartirq(&TTYS0_DEV); #endif #ifdef TTYS1_DEV (void)z16f_disableuartirq(&TTYS1_DEV); #endif /* Configuration any serial console */ #ifdef CONSOLE_DEV CONSOLE_DEV.isconsole = true; z16f_setup(&CONSOLE_DEV); #endif }
int up_putc(int ch) { uint8_t state; /* Keep interrupts disabled so that we do not interfere with normal * driver operation. * * REVISIT: I can imagine scenarios where the follow logic gets pre-empted * and the the UART interrupts get left in a bad state. */ state = z16f_disableuartirq(&CONSOLE_DEV); /* Check for LF */ if (ch == '\n') { /* Add CR before LF */ z16f_consoleput('\r'); } /* Output the character */ z16f_consoleput((uint8_t)ch); /* It is important to restore the TX interrupt while the send is pending. * otherwise, TRDE interrupts can be lost since they do not pend after the * TRDE false->true transition. */ z16f_restoreuartirq(&CONSOLE_DEV, state); return ch; }
int up_putc(int ch) { uint8_t state; /* Keep interrupts disabled so that we do not interfere with normal * driver operation */ state = z16f_disableuartirq(&CONSOLE_DEV); /* Check for LF */ if (ch == '\n') { /* Add CR before LF */ z16f_consoleput('\r'); } /* Output the character */ z16f_consoleput((uint8_t)ch); /* It is important to restore the TX interrupt while the send is pending. * otherwise, TRDE interrupts can be lost since they do not pend after the * TRDE false->true transition. */ z16f_restoreuartirq(&CONSOLE_DEV, state); return ch; }
static void z16f_shutdown(struct uart_dev_s *dev) { (void)z16f_disableuartirq(dev); }
static void z16f_shutdown(struct uart_dev_s *dev) { struct z16f_uart_s *priv = (struct z16f_uart_s*)dev->priv; (void)z16f_disableuartirq(dev); }