示例#1
0
static void usart_read_callback(struct usart_module *const usart_module)
{
    /* Write byte to circular buffer */
    if (circularBufferWrite(&rxcb, rx_buffer[0]) != 0) {
        printf("RX error\r\n");
    }

    /* Set for usart callback */
    usart_read_buffer_job(&usart_debug, (uint8_t *)rx_buffer, MAX_RX_BUFFER_LENGTH);
}
示例#2
0
/** Transfer bytes from a receive buffer into receive FIFO.
  * \warning This assumes there is enough space (if not, usbFatalError() will
  *          be called). There should always be enough space, since a receive
  *          is never queued unless there is enough space.
  */
static void transferIntoReceiveFIFO(uint8_t *buffer, uint32_t length)
{
	uint32_t i;

	if (circularBufferSpaceRemaining(&receive_fifo) < length)
	{
		// This should never happen.
		usbFatalError();
	}
	for (i = 0; i < length; i++)
	{
		circularBufferWrite(&receive_fifo, buffer[i], 1);
	}
}