/* write a full block or less out EndPoint1 every callback */
void EP1_IN_Callback(void)
{
    static uint8_t buffer[VIRTUAL_COM_PORT_DATA_SIZE];
    unsigned int bytes = GetDataFromRing(&tx_ring, VIRTUAL_COM_PORT_DATA_SIZE, buffer);
    if (bytes)
    {
        USB_SIL_Write(EP1_IN, buffer, bytes);
#ifndef STM32F10X_CL
        SetEPTxValid(ENDP1);
#endif /* STM32F10X_CL */
    }
    else
    {
        write_ready = 1;
    }
}
Exemple #2
0
/* Call the applications call back on interrupt */
void H1UART_HANDLER(void)
{
    stat_uart_irq++;
    if (USART_GetFlagStatus(H1UART, USART_FLAG_TXE))
    {
        uint8_t byte;
        if (GetDataFromRing(&tx_ring, 1, &byte))
        {
            USART_SendData(H1UART, byte);
        }
        else
        {
            USART_ITConfig(H1UART, USART_IT_TXE, DISABLE);
        }
    }

    if (USART_GetFlagStatus(H1UART, USART_FLAG_RXNE))
    {
        uint8_t byte = USART_ReceiveData(H1UART);
        stat_uart_rx++;
        PutDataInRing(&rx_ring, 1, &byte);
    }
}
/* read data from endpoint's ring */
unsigned int USB_VCOMread(unsigned int size, void* buffer)
{
    return GetDataFromRing(&rx_ring, size, (uint8_t*)buffer);
}
Exemple #4
0
/* read as much data as available data from the ring into the provided buffer */
unsigned int UARTread(unsigned int size, void* buffer)
{
    unsigned int ret = GetDataFromRing(&rx_ring, size, (uint8_t*)buffer);

    return ret;
}