From 4c01e53f2d85e4989b21e311c88a48ede814f736 Mon Sep 17 00:00:00 2001 From: oyvind Date: Wed, 18 Nov 2009 10:15:40 +0000 Subject: [PATCH] uart: allow using UART as diag channel MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Until the UART is opened it's safe to use the UART as a diag channel. Signed-off-by: Øyvind Harboe git-svn-id: http://www.ecosforge.net/ecosforge/trunk/nios2ecos@299 2333b21a-1c27-0410-8132-afba56cb5048 --- .../current/src/altera_avalon_uart.c | 66 ++++++++++------------ 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/packages/devs/serial/sopc/altera_avalon_uart/current/src/altera_avalon_uart.c b/packages/devs/serial/sopc/altera_avalon_uart/current/src/altera_avalon_uart.c index 4a7d9e2..3b49f86 100644 --- a/packages/devs/serial/sopc/altera_avalon_uart/current/src/altera_avalon_uart.c +++ b/packages/devs/serial/sopc/altera_avalon_uart/current/src/altera_avalon_uart.c @@ -368,46 +368,40 @@ static void altera_avalon_uart_DSR(cyg_vector_t vector, /*--------------------------------------------------------------------- * altera_avalon_uart_init * - * Initialise the device. + * Initialize the device. + * + * The UART can safely be used as a diag device up until it is initialized. */ bool altera_avalon_uart_init(struct cyg_devtab_entry *tab) { - serial_channel *chan = (serial_channel *)tab->priv; - altera_avalon_uart_dev *uart_chan = (altera_avalon_uart_dev *)chan->dev_priv; - - if (__builtin_strcmp (DEV_NAME(CYGHWR_HAL_NIOS2_VV_DEBUG_DEV), tab->name) && - __builtin_strcmp (DEV_NAME(CYGHWR_HAL_NIOS2_VV_CONSOLE_DEV), tab->name)) - { - (chan->callbacks->serial_init)(chan); - - /* enable interrupts at the device */ - - if (chan->out_cbuf.len != 0) - { - cyg_drv_interrupt_create(uart_chan->irq, - 99, /* Priority - unused */ - (cyg_addrword_t)chan, /* Data item passed to interrupt handler */ - altera_avalon_uart_ISR, - altera_avalon_uart_DSR, - &uart_chan->serial_interrupt_handle, - &uart_chan->serial_interrupt); - - cyg_drv_interrupt_attach(uart_chan->serial_interrupt_handle); - - IOWR_ALTERA_AVALON_UART_CONTROL(uart_chan->base, - ALTERA_AVALON_UART_CONTROL_RTS_MSK | - ALTERA_AVALON_UART_CONTROL_RRDY_MSK | - ALTERA_AVALON_UART_CONTROL_DCTS_MSK); - - cyg_drv_interrupt_unmask(uart_chan->irq); - } - return true; - } - else - { - return false; - } + serial_channel *chan = (serial_channel *)tab->priv; + altera_avalon_uart_dev *uart_chan = (altera_avalon_uart_dev *)chan->dev_priv; + + (chan->callbacks->serial_init)(chan); + + /* enable interrupts at the device */ + + if (chan->out_cbuf.len != 0) + { + cyg_drv_interrupt_create(uart_chan->irq, + 99, /* Priority - unused */ + (cyg_addrword_t)chan, /* Data item passed to interrupt handler */ + altera_avalon_uart_ISR, + altera_avalon_uart_DSR, + &uart_chan->serial_interrupt_handle, + &uart_chan->serial_interrupt); + + cyg_drv_interrupt_attach(uart_chan->serial_interrupt_handle); + + IOWR_ALTERA_AVALON_UART_CONTROL(uart_chan->base, + ALTERA_AVALON_UART_CONTROL_RTS_MSK | + ALTERA_AVALON_UART_CONTROL_RRDY_MSK | + ALTERA_AVALON_UART_CONTROL_DCTS_MSK); + + cyg_drv_interrupt_unmask(uart_chan->irq); + } + return true; } /*--------------------------------------------------------------------- -- 2.11.4.GIT