コード例 #1
0
ファイル: slip.c プロジェクト: MSP430Dev/uos-embedded
/*
 * Receive interrupt task.
 */
static void
slip_receiver (void *arg)
{
    slip_t *u = arg;
    unsigned short len;

    /* Start receiver. */
    mutex_lock_irq (&u->netif.lock, RECEIVE_IRQ (u->port),
                    (handler_t) slip_receive_data, u);

    enable_receiver (u->port);
    enable_receive_interrupt (u->port);

    for (;;) {
        if (! u->in_ptr) {
            /* Allocate buffer for receive data. */
            u->in = buf_alloc (u->pool, u->netif.mtu, 16);
            if (u->in) {
                u->in_ptr = u->in->payload;
                u->in_limit = u->in_ptr + u->netif.mtu;
            } else {
                /* No buffer - ignore input. */
                debug_printf ("slip_receiver: out of memory\n");
                ++u->netif.in_discards;
            }
        }

        /* Wait for the receive interrupt. */
        mutex_wait (&u->netif.lock);

        /* Process all available received data. */
        if (u->in_ptr && u->in_ptr > u->in->payload) {
            len = u->in_ptr - u->in->payload;
            debug_printf ("slip_receiver(%ld): received %d bytes\n", u->netif.in_packets, len);
            buf_truncate (u->in, len);
            ++u->netif.in_packets;

            if (buf_queue_is_full (&u->inq)) {
                debug_printf ("slip_receiver: input overflow\n");
                ++u->netif.in_discards;

                /* Reuse the packet. */
                u->in_ptr = u->in->payload;
                u->in_limit = u->in_ptr + u->netif.mtu;
            } else {
                /* Enqueue the received packet. */
                buf_queue_put (&u->inq, u->in);
                u->in_ptr = 0;
            }
        }
#ifndef TRANSMIT_IRQ
        if (u->out_free)
            slip_out_next (u);
#endif
    }
}
コード例 #2
0
ファイル: usbdevhal.c プロジェクト: Kefir0192/uos-embedded
static void usb_interrupt (void *arg)
{
    static int ep;
    
    mutex_lock_irq (io_lock, USB_IRQn, 0, 0);

    for (;;) {
        mutex_wait (io_lock);
        
        if (ARM_USB->SIS & ARM_USB->SIM & ARM_USB_SC_RESET_EV) {
//debug_printf ("usb_interrupt: device reset\n");
            ARM_USB->SIS = ARM_USB_SC_RESET_EV;
            ARM_USB->SIM &= ~ARM_USB_SC_RESET_EV;
            usbdevhal_reset (usbdev);
            mldr_usb_reset ();
        }
        if (ARM_USB->SIS & ARM_USB->SIM & ARM_USB_SC_SOF_REC) {
//debug_printf ("usb_interrupt: start of frame, SIS = %02X, SIM = %02X, SFN = %d.%d\n", ARM_USB->SIS, ARM_USB->SIM, ARM_USB->SFN_L, ARM_USB->SFN_H);
            ARM_USB->SIS = ARM_USB_SC_SOF_REC;
        }
        if (ARM_USB->SIS & ARM_USB->SIM & ARM_USB_SC_TDONE) {
            ARM_USB->SIS = ARM_USB_SC_TDONE;
//debug_printf ("usb_interrupt: tx done, RXFDC = %d, CTRL = %X, STS = %X, TS = %X\n", ARM_USB->SEPF[0].RXFDC_H, ARM_USB->SEPS[0].CTRL, ARM_USB->SEPS[0].STS, ARM_USB->SEPS[0].TS);
            for (ep = 0; ep < USBDEV_MAX_EP_NB; ++ep) {
                if (ARM_USB->SEPS[ep].STS & ARM_USB_SC_STALL_SENT) {
                    ARM_USB->SEPS[ep].STS &= ~ARM_USB_SC_STALL_SENT;
//debug_printf ("STALL sent\n");
                    ARM_USB->SEPS[ep].CTRL = (ARM_USB->SEPS[ep].CTRL & ~ARM_USB_EPSSTALL) | ARM_USB_EPRDY;
                } else if ((ARM_USB->SEPS[ep].CTRL & (ARM_USB_EPEN | ARM_USB_EPRDY)) == ARM_USB_EPEN) {
                    do_usbdev (ep);
                }
            }
        }
        if (ARM_USB->SIS & ARM_USB->SIM & ARM_USB_SC_RESUME) {
//debug_printf ("usb_interrupt: resume\n");
            ARM_USB->SIS = ARM_USB_SC_RESUME;
        }
        if (ARM_USB->SIS & ARM_USB->SIM & ARM_USB_SC_NAK_SENT) {
            for (ep = 0; ep < USBDEV_MAX_EP_NB; ++ep) {
                if ((ARM_USB->SEPS[ep].CTRL & (ARM_USB_EPEN | ARM_USB_EPRDY)) == ARM_USB_EPEN) {
//debug_printf ("NAK sent, EP%d CTRL = %x, STS = %x\n", ep, ARM_USB->SEPS[ep].CTRL, ARM_USB->SEPS[ep].STS);
                    if (ARM_USB->SEPS[ep].STS & ARM_USB_SC_ACK_RXED ||
                        ARM_USB->SEPS[ep].STS == 0x90)
                        do_usbdev (ep);
                        
                    if (ARM_USB->SEPS[ep].CTRL & ARM_USB_EPSSTALL)
                        //ARM_USB->SEPS[ep].CTRL |= ARM_USB_EPRDY;
                        ARM_USB->SEPS[ep].CTRL = (ARM_USB->SEPS[ep].CTRL & ~ARM_USB_EPSSTALL) | ARM_USB_EPRDY;
                }
            }
            ARM_USB->SIS = ARM_USB_SC_NAK_SENT;
        }
    }
}
コード例 #3
0
ファイル: eth.c プロジェクト: alexrayne/uos-embedded
/*
 * Interrupt task.
 */
static void interrupt_task(void *arg) {
	eth_t *u = arg;

	/* Register the interrupt. */
	mutex_lock_irq(&u->netif.lock, ETH_IRQ, 0, 0);

	for (;;) {
		/* Wait for the interrupt. */
		mutex_wait(&u->netif.lock);
		++u->intr;
		handle_interrupt(u);
	}
}
コード例 #4
0
ファイル: slip.c プロジェクト: MSP430Dev/uos-embedded
/*
 * Transmit interrupt task.
 */
static void
slip_transmitter (void *arg)
{
    slip_t *u = arg;

    /* Start transmitter. */
    mutex_lock_irq (&u->transmitter, TRANSMIT_IRQ (u->port),
                    (handler_t) slip_transmit_start, u);
    enable_transmitter (u->port);

    for (;;) {
        /* Wait for the transmit interrupt. */
        mutex_wait (&u->transmitter);
        if (u->out_free)
            slip_out_next (u);
    }
}
コード例 #5
0
ファイル: uartx.c プロジェクト: alexrayne/uos-embedded
/*
 * Receive interrupt task.
 */
static void
uartx_receiver (void *arg)
{
	uartx_t *u = (uartx_t *)arg;
	unsigned port;

	/*
	 * Enable receiver.
	 */
	mutex_lock_irq (&uartx_lock, RECEIVE_IRQ, 0, 0);
	UARTX_IER (0) |= MC_IER_ERXRDY | MC_IER_ERLS;
	UARTX_IER (1) |= MC_IER_ERXRDY | MC_IER_ERLS;
	UARTX_IER (2) |= MC_IER_ERXRDY | MC_IER_ERLS;

	for (;;) {
		mutex_wait (&uartx_lock);
/*debug_putchar (0, '!');*/
		for (port=0; port<3; port++)
			uartx_interrupt (u + port);
	}
}