Пример #1
0
/**
 * @brief Function to handle the state machine serial data exchange.
 */
void serial_data_handler(void)
{
	/* Rx processing */
	if (data_length == 0) {
		/* No data to process, read the stream IO */
		rx_index = 0;
		data_length = sio2host_rx(data, SIO_RX_BUF_SIZE);
	} else { /* Data has been received, process the data */
		 /* Process each single byte */
		process_incoming_sio_data();
		data_length--;
		rx_index++;
	}

	/* Tx processing */
	if (buf_count != 0) {
		if (sio2host_tx(sio_tx_buf[head],
				(sio_tx_buf[head][1] + 3)) != 0) {
			head++;
			head %= SIO_BUF_COUNT;
			buf_count--;
		} else {
			/* @ToDo what happens if none or only a part of the
			 * bytes could be transmitted? */
		}
	}
}
Пример #2
0
/*
 * @brief Function to handle the state machine serial data exchange.
 */
void serial_data_handler(void)
{
	/* Rx processing */
	if (data_length == 0) {
		/* No data to process, read the stream IO */
		rx_index = 0;
		data_length = sio2host_rx(&data[0], SIO_RX_BUF_SIZE); /* @ToDo 20 ?,
		                                                   * different
		                                                   * values for
		                                                   * USB and
		                                                   * UART ? */
	} else { /* Data has been received, process the data */
		/* Process each single byte */
		process_incoming_sio_data();
		data_length--;
		rx_index++;
	}
}