Ejemplo n.º 1
0
uint32_t vsf_fifo_push(struct vsf_fifo_t *fifo, uint32_t size, uint8_t *data)
{
	uint32_t tmp32;

#if __VSF_DEBUG__
	if ((NULL == fifo) || (NULL == data))
	{
		return 0;
	}
#endif
	if (size > vsf_fifo_get_avail_length(fifo))
	{
		return 0;
	}

	tmp32 = fifo->buffer.size - fifo->head;
	if (size > tmp32)
	{
		memcpy(&fifo->buffer.buffer[fifo->head], &data[0], tmp32);
		memcpy(&fifo->buffer.buffer[0], &data[tmp32], size - tmp32);
		fifo->head = size - tmp32;
	}
	else
	{
		memcpy(&fifo->buffer.buffer[fifo->head], data, size);
		fifo->head += size;
		if (fifo->head == fifo->buffer.size)
		{
			fifo->head = 0;
		}
	}
	return size;
}
Ejemplo n.º 2
0
uint32_t vsf_fifo_push8(struct vsf_fifo_t *fifo, uint8_t data)
{
	if (vsf_fifo_get_avail_length(fifo) < 1)
	{
		return 0;
	}

	fifo->buffer.buffer[fifo->head] = data;
	fifo->head = vsf_fifo_get_next_index(fifo->head, fifo->buffer.size);
	return 1;
}
Ejemplo n.º 3
0
vsf_err_t usart_status(uint8_t index, struct usart_status_t *status)
{
	struct vsf_fifo_t *fifo_tx, *fifo_rx;
	
	switch (index)
	{
	case 0:
		if (NULL == status)
		{
			return VSFERR_INVALID_PTR;
		}
		
		fifo_tx = &usart_stream_p0.stream_tx.fifo;
		fifo_rx = &usart_stream_p0.stream_rx.fifo;
		status->tx_buff_avail = vsf_fifo_get_avail_length(fifo_tx);
		status->tx_buff_size = vsf_fifo_get_data_length(fifo_tx);
		status->rx_buff_avail = vsf_fifo_get_avail_length(fifo_rx);
		status->rx_buff_size = vsf_fifo_get_data_length(fifo_rx);
		return VSFERR_NONE;
	default:
		return VSFERR_NOT_SUPPORT;
	}
}
Ejemplo n.º 4
0
static void APPIO_OUTBUFF(uint8_t *buff, uint32_t size)
{
	uint32_t free_space, cur_size;
	
#if HW_HAS_LCM
	vsprog_ui_print((char *)buff);
#endif
	
	if (appio_dummy)
	{
		return;
	}
	
	while (size > 0)
	{
		do
		{
			usb_protocol_poll();
			free_space = vsf_fifo_get_avail_length(&shell_stream.stream_rx.fifo);
		} while (!free_space);
		
		if (free_space > size)
		{
			cur_size = size;
		}
		else
		{
			cur_size = free_space;
		}
		
		vsf_fifo_push(&shell_stream.stream_rx.fifo, cur_size, buff);
		
		size -= cur_size;
		buff += cur_size;
	}
	
	app_io_out_sync();
}
Ejemplo n.º 5
0
static uint32_t fifo_stream_get_avail_length(struct vsf_stream_t *stream)
{
	struct vsf_fifostream_t *fifostream = (struct vsf_fifostream_t *)stream;
	return vsf_fifo_get_avail_length(&fifostream->mem);
}
Ejemplo n.º 6
0
uint32_t stream_get_free_size(struct vsf_stream_t *stream)
{
	return vsf_fifo_get_avail_length(&stream->fifo);
}