Hi ,
       I am using two different IRQ number for RX and TX in serial driver.

My init function of serial driver looks like this ---

static bool test_serial_init(struct cyg_devtab_entry *tab)
{
       serial_channel *chan = (serial_channel *)tab->priv;
(chan->callbacks->serial_init)(chan); // Really only required for interrupt driven devices

       /* Allocate the IRQs */
       if (chan->out_cbuf.len != 0) {
               /* TX interrupt */
               cyg_drv_interrupt_create(TX_IRQ,
0, // IRQ priority (cyg_addrword_t)chan, // Data item passed to interrupt handler
                                        &test_tx_serial_ISR,
                                        &test_tx_serial_DSR,
                                        &tx_serial_interrupt_handle,
                                        &tx_serial_interrupt);
               cyg_drv_interrupt_attach(tx_serial_interrupt_handle);
               cyg_drv_interrupt_unmask(TX_IRQ);
       }
       if (chan->in_cbuf.len != 0) {
               /* RX interrupt */
               cyg_drv_interrupt_create(RX_IRQ,
0, // IRQ priority (cyg_addrword_t)chan, // Data item passed to interrupt handler
                                        &test_rx_serial_ISR,
                                        &test_rx_serial_DSR,
                                        &rx_serial_interrupt_handle,
                                        &rx_serial_interrupt);
               cyg_drv_interrupt_attach(rx_serial_interrupt_handle);
               cyg_drv_interrupt_unmask(RX_IRQ);
       }

       return true;
}

My problems are :

1. when I press any key from keyboard test_rx_serial_ISR and test_rx_serial_DSR are called one by one.
               But that charcter is not displayed.
2. In scanf function --- control is stuck into " while (size < *len) {" this loop in serial_read function.

Here is my DSR for RX:

static void test_rx_serial_DSR(cyg_vector_t vector, cyg_ucount32 count, cyg_addrword_t data)
{
       serial_channel *chan = (serial_channel *)data;
       cyg_uint8 _c;
       unsigned int fifocnt;

       fifocnt = *FSTAT & RXFFLMASK;
       if(fifocnt--) {
               _c = *ASC_RBUF;
               (chan->callbacks->rcv_char)(chan, _c);
/* I print this "_c" variable by diag_printf and I have seen it get correct key which I type from keyboard */

               /* RX happened ... so try to print that char */
               if(((*FSTAT & TXFFLMASK) >> TXFFLOFF) != TXFIFO_FULL) {
                       cbuf_t *tx_cbuf = &chan->out_cbuf;
diag_printf("TX: %d\n", tx_cbuf->nb); /* I got 0 here */ (chan->callbacks->xmt_char)(chan); /* nothing is printed */
               }
       }

       cyg_drv_interrupt_unmask(RX_IRQ);
}

Thanks in advance

Regards,
Tatha


--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

Reply via email to