static void uart_txStart(struct SerialHardware * _hw)
{
	struct EmulSerial *hw = (struct EmulSerial *)_hw;

	while(!fifo_isempty(&hw->ser->txfifo))
	{
		char c = fifo_pop(&hw->ser->txfifo);
		write(hw->fd, &c, 1);
	}
}
Example #2
0
/**
 * Wait until all pending output is completely
 * transmitted to the other end.
 *
 * \note The current implementation only checks the
 *       software transmission queue. Any hardware
 *       FIFOs are ignored.
 */
static int ser_flush(struct KFile *fd)
{
	Serial *fds = SERIAL_CAST(fd);

	/*
	 * Wait until the FIFO becomes empty, and then until the byte currently in
	 * the hardware register gets shifted out.
	 */
	while (!fifo_isempty(&fds->txfifo)
	       || fds->hw->table->txSending(fds->hw))
		cpu_relax();
	return 0;
}
Example #3
0
static void spi_starttx(struct SerialHardware *_hw)
{
	struct AvrSerial *hw = (struct AvrSerial *)_hw;

	cpu_flags_t flags;
	IRQ_SAVE_DISABLE(flags);

	/* Send data only if the SPI is not already transmitting */
	if (!hw->sending && !fifo_isempty(&ser_handles[SER_SPI]->txfifo))
	{
		hw->sending = true;
		SPDR = fifo_pop(&ser_handles[SER_SPI]->txfifo);
	}

	IRQ_RESTORE(flags);
}
Example #4
0
int fifo_pop(struct fifo * f) {
    assert(!fifo_isempty(f));

    int e_ret = 0;
    if (stack_isempty(f->s[1])) {
        while (!stack_isempty(f->s[0])) {
            int e = stack_topandpop(f->s[0]);
            if (stack_isempty(f->s[0])) {
                e_ret = e;
            } else {
                stack_push(f->s[1], e);
            }
        }
    } else {
        e_ret = stack_topandpop(f->s[1]);
    }
    
    f->size -= 1;
    return e_ret;
}