ZNeo Serial: Need to configure UART1 alternate function
This commit is contained in:
parent
344ed99bd4
commit
07bc8e53ff
@ -406,7 +406,6 @@ _c0_isr:
|
||||
ld r1, #Z16F_IRQ_C0 /* r1 = Port C0, both edges DMA0 IRQ number */
|
||||
/* Join common interrupt handling logic */
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Name: _common_isr
|
||||
*
|
||||
|
@ -90,7 +90,7 @@
|
||||
* Description:
|
||||
* Initialize UART0 or UART1
|
||||
*
|
||||
* Parameters:
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
*************************************************************************/
|
||||
@ -111,6 +111,8 @@ _z16f_lowuartinit:
|
||||
sll r3, #4 /* r3 = baud * 16 */
|
||||
udiv r0, r3 /* BRG = (freq + baud * 8)/(baud * 16) */
|
||||
|
||||
/* Hacks to get a serial console available ASAP */
|
||||
|
||||
#ifdef CONFIG_UART1_SERIAL_CONSOLE
|
||||
ld.w Z16F_UART1_BR, r0 /* Z16F_UART1_BR = BRG */
|
||||
|
||||
@ -152,10 +154,10 @@ _z16f_lowuartinit:
|
||||
* Description:
|
||||
* Send one character to the selected serial console
|
||||
*
|
||||
* Parmeters:
|
||||
* Input Parameters:
|
||||
* r1 = character
|
||||
*
|
||||
* Return:
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
* Modifies r0 (and maybe r1)
|
||||
|
@ -435,6 +435,7 @@ static int z16f_attach(struct uart_dev_s *dev)
|
||||
irq_detach(priv->rxirq);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -451,8 +452,10 @@ static int z16f_attach(struct uart_dev_s *dev)
|
||||
static void z16f_detach(struct uart_dev_s *dev)
|
||||
{
|
||||
struct z16f_uart_s *priv = (struct z16f_uart_s*)dev->priv;
|
||||
|
||||
up_disable_irq(priv->rxirq);
|
||||
up_disable_irq(priv->txirq);
|
||||
|
||||
irq_detach(priv->rxirq);
|
||||
irq_detach(priv->txirq);
|
||||
}
|
||||
@ -484,8 +487,8 @@ static int z16f_rxinterrupt(int irq, void *context)
|
||||
{
|
||||
dev = &g_uart0port;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
#endif
|
||||
{
|
||||
PANIC();
|
||||
}
|
||||
@ -504,7 +507,7 @@ static int z16f_rxinterrupt(int irq, void *context)
|
||||
|
||||
if (status & Z16F_UARTSTAT0_RDA)
|
||||
{
|
||||
/* Handline an incoming, receive byte */
|
||||
/* Handle an incoming, received byte */
|
||||
|
||||
uart_recvchars(dev);
|
||||
}
|
||||
@ -539,8 +542,8 @@ static int z16f_txinterrupt(int irq, void *context)
|
||||
{
|
||||
dev = &g_uart0port;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
#endif
|
||||
{
|
||||
PANIC();
|
||||
}
|
||||
@ -593,6 +596,7 @@ static int z16f_receive(struct uart_dev_s *dev, uint32_t *status)
|
||||
rxd = getreg8(priv->uartbase + Z16F_UART_RXD);
|
||||
stat0 = getreg8(priv->uartbase + Z16F_UART_STAT0);
|
||||
*status = (uint32_t)rxd | (((uint32_t)stat0) << 8);
|
||||
|
||||
return rxd;
|
||||
}
|
||||
|
||||
@ -730,15 +734,46 @@ static bool z16f_txempty(struct uart_dev_s *dev)
|
||||
|
||||
void up_earlyserialinit(void)
|
||||
{
|
||||
/* REVISIT: UART GPIO AFL register is not initialized */
|
||||
uint8_t regval;
|
||||
|
||||
/* Configure UART alternate pin functions */
|
||||
|
||||
#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);
|
||||
|
Loading…
Reference in New Issue
Block a user