本文整理汇总了C++中RingBuffer_Insert函数的典型用法代码示例。如果您正苦于以下问题:C++ RingBuffer_Insert函数的具体用法?C++ RingBuffer_Insert怎么用?C++ RingBuffer_Insert使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RingBuffer_Insert函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: println_C
void println_C (char * str)
{
for (uint16_t i = 0; i<strlen(str);i++)
{
RingBuffer_Insert(&USARTtoUSB_Buffer,str[i]);
}
RingBuffer_Insert(&USARTtoUSB_Buffer, 13);
}
示例2: send_ELM327_OK
void send_ELM327_OK()
{
//Serial_SendByte('O'); //
RingBuffer_Insert(&FFtoBT_Buffer,'O');
//Serial_SendByte('K'); //
RingBuffer_Insert(&FFtoBT_Buffer,'K');
send_ELM327_CR();
}
示例3: UCOM_int_hdlr
/* UCOM interrupt EP_IN and EP_OUT endpoints handler */
static ErrorCode_t UCOM_int_hdlr(USBD_HANDLE_T hUsb, void *data, uint32_t event)
{
switch (event) {
case USB_EVT_IN:
/* USB_EVT_IN occurs when HW completes sending IN packet. So clear the
busy flag for main loop to queue next packet.
*/
g_usb.usbTxFlags &= ~UCOM_TX_BUSY;
if (RingBuffer_GetCount(&usb_txrb) >= 1) {
g_usb.usbTxFlags |= UCOM_TX_BUSY;
RingBuffer_Pop(&usb_txrb, g_usb.usbTx_buff);
USBD_API->hw->WriteEP(g_usb.hUsb, HID_EP_IN, g_usb.usbTx_buff, AVAM_P_COUNT);
}
break;
case USB_EVT_OUT:
g_usb.usbRx_count = USBD_API->hw->ReadEP(hUsb, HID_EP_OUT, g_usb.usbRx_buff);
#ifdef DEBUG_VERBOSE
if (RingBuffer_GetCount(&usb_rxrb) == RX_BUF_CNT) {
debug32("E:(%d-%x %x %x %x) usb_rxrb overflow evt out\n", g_usb.usbRx_count,
g_usb.usbRx_buff[0],
g_usb.usbRx_buff[1],
g_usb.usbRx_buff[2],
g_usb.usbRx_buff[3]);
}
#endif
if (g_usb.usbRx_count >= AVAM_P_COUNT) {
RingBuffer_Insert(&usb_rxrb, g_usb.usbRx_buff);
g_usb.usbRx_count -= AVAM_P_COUNT;
}
if (g_usb.usbRxFlags & UCOM_RX_BUF_QUEUED) {
g_usb.usbRxFlags &= ~UCOM_RX_BUF_QUEUED;
if (g_usb.usbRx_count != 0)
g_usb.usbRxFlags |= UCOM_RX_BUF_FULL;
}
break;
case USB_EVT_OUT_NAK:
/* queue free buffer for RX */
if ((g_usb.usbRxFlags & (UCOM_RX_BUF_FULL | UCOM_RX_BUF_QUEUED)) == 0) {
g_usb.usbRx_count = USBD_API->hw->ReadReqEP(hUsb, HID_EP_OUT, g_usb.usbRx_buff, UCOM_RX_BUF_SZ);
#ifdef DEBUG_VERBOSE
if (RingBuffer_GetCount(&usb_rxrb) == RX_BUF_CNT)
debug32("E: usb_rxrb overflow evt nak\n");
#endif
if (g_usb.usbRx_count >= AVAM_P_COUNT) {
RingBuffer_Insert(&usb_rxrb, g_usb.usbRx_buff);
g_usb.usbRx_count -= AVAM_P_COUNT;
}
g_usb.usbRxFlags |= UCOM_RX_BUF_QUEUED;
}
break;
default:
break;
}
return LPC_OK;
}
示例4: ISR
/** ISR to manage the reception of data from the serial port, placing received bytes into a circular buffer
* for later transmission to the host.
*/
ISR(USART1_RX_vect, ISR_BLOCK)
{
uint8_t ReceivedByte = UDR1;
if (USB_DeviceState == DEVICE_STATE_Configured) {
if (eeprom_op) {
RingBuffer_Insert(&USARTtoEEPROM_Buffer, ReceivedByte);
} else {
RingBuffer_Insert(&USARTtoUSB_Buffer, ReceivedByte);
}
}
}
示例5: UCOM_bulk_hdlr
/* UCOM bulk EP_IN and EP_OUT endpoints handler */
static ErrorCode_t UCOM_bulk_hdlr(USBD_HANDLE_T hUsb, void *data, uint32_t event)
{
UCOM_DATA_T *pUcom = (UCOM_DATA_T *) data;
switch (event) {
/* A transfer from us to the USB host that we queued has completed. */
case USB_EVT_IN:
pUcom->usbTxFlags &= ~UCOM_TX_BUSY;
break;
/* We received a transfer from the USB host . */
case USB_EVT_OUT:
pUcom->usbRx_count = USBD_API->hw->ReadEP(hUsb, USB_CDC_OUT_EP, pUcom->usbRx_buff);
if(pUcom->usbRx_count){
if(1 == pUcom->usbRx_count){
RingBuffer_Insert(&usb_rxrb, pUcom->usbRx_buff);
}else
{
RingBuffer_InsertMult(&usb_rxrb, pUcom->usbRx_buff, pUcom->usbRx_count);
}
}
if (pUcom->usbRxFlags & UCOM_RX_BUF_QUEUED) {
pUcom->usbRxFlags &= ~UCOM_RX_BUF_QUEUED;
if (pUcom->usbRx_count != 0) {
pUcom->usbRxFlags |= UCOM_RX_BUF_FULL;
}
}
break;
case USB_EVT_OUT_NAK:
/* queue free buffer for RX */
if ((pUcom->usbRxFlags & (UCOM_RX_BUF_FULL | UCOM_RX_BUF_QUEUED)) == 0) {
pUcom->usbRx_count = USBD_API->hw->ReadReqEP(hUsb, USB_CDC_OUT_EP, pUcom->usbRx_buff, UCOM_RX_BUF_SZ);
if(pUcom->usbRx_count){
if(1 == pUcom->usbRx_count){
RingBuffer_Insert(&usb_rxrb, pUcom->usbRx_buff);
}else
{
RingBuffer_InsertMult(&usb_rxrb, pUcom->usbRx_buff, pUcom->usbRx_count);
}
}
pUcom->usbRxFlags |= UCOM_RX_BUF_QUEUED;
}
break;
default:
break;
}
return LPC_OK;
}
示例6: main
/** Main program entry point. This routine contains the overall program flow, including initial
* setup of all components and the main program loop.
*/
int main(void)
{
SetupHardware();
RingBuffer_InitBuffer(&USBtoUSART_Buffer, USBtoUSART_Buffer_Data, sizeof(USBtoUSART_Buffer_Data));
RingBuffer_InitBuffer(&USARTtoUSB_Buffer, USARTtoUSB_Buffer_Data, sizeof(USARTtoUSB_Buffer_Data));
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
GlobalInterruptEnable();
for (;;)
{
/* Only try to read in bytes from the CDC interface if the transmit buffer is not full */
if (!(RingBuffer_IsFull(&USBtoUSART_Buffer)))
{
int16_t ReceivedByte = CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface);
/* Read bytes from the USB OUT endpoint into the USART transmit buffer */
if (!(ReceivedByte < 0))
RingBuffer_Insert(&USBtoUSART_Buffer, ReceivedByte);
}
/* Check if the UART receive buffer flush timer has expired or the buffer is nearly full */
uint16_t BufferCount = RingBuffer_GetCount(&USARTtoUSB_Buffer);
if (BufferCount)
{
Endpoint_SelectEndpoint(VirtualSerial_CDC_Interface.Config.DataINEndpoint.Address);
/* Check if a packet is already enqueued to the host - if so, we shouldn't try to send more data
* until it completes as there is a chance nothing is listening and a lengthy timeout could occur */
if (Endpoint_IsINReady())
{
/* Never send more than one bank size less one byte to the host at a time, so that we don't block
* while a Zero Length Packet (ZLP) to terminate the transfer is sent if the host isn't listening */
uint8_t BytesToSend = MIN(BufferCount, (CDC_TXRX_EPSIZE - 1));
/* Read bytes from the USART receive buffer into the USB IN endpoint */
while (BytesToSend--)
{
/* Try to send the next byte of data to the host, abort if there is an error without dequeuing */
if (CDC_Device_SendByte(&VirtualSerial_CDC_Interface,
RingBuffer_Peek(&USARTtoUSB_Buffer)) != ENDPOINT_READYWAIT_NoError)
{
break;
}
/* Dequeue the already sent byte from the buffer now we have confirmed that no transmission error occurred */
RingBuffer_Remove(&USARTtoUSB_Buffer);
}
}
}
/* Load the next byte from the USART transmit buffer into the USART */
if (!(RingBuffer_IsEmpty(&USBtoUSART_Buffer)))
Serial_SendByte(RingBuffer_Remove(&USBtoUSART_Buffer));
CDC_Device_USBTask(&VirtualSerial_CDC_Interface);
USB_USBTask();
}
}
示例7: serialAddByte
//------------------------------------------------------------------------------
uint8_t serialAddByte(uint8_t byte)
{
uint16_t size;
size = RingBuffer_GetCount(&buffer_);
if(size == 0)
{
if(byte >= SERIAL_END_COMMANDS)
{
return false;
}
}
else if(size == 1)
{
frame_size_ = byte+2;
}
RingBuffer_Insert(&buffer_, byte);
size = RingBuffer_GetCount(&buffer_);
if(size == frame_size_)
{
frame_size_ = 0;
return true;
}
return false;
}
示例8: CAN_rx
void CAN_rx(uint8_t msg_obj_num) {
msg_obj.msgobj = msg_obj_num;
LPC_CCAN_API->can_receive(&msg_obj);
if (msg_obj_num == 1) {
RingBuffer_Insert(&CAN_rx_buffer, &msg_obj);
}
}
示例9: HandleSerial
void HandleSerial(void)
{
// Only try to read in bytes from the CDC interface if the transmit buffer is not full
if (!(RingBuffer_IsFull(&FromHost_Buffer)))
{
int16_t ReceivedByte = CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface);
// Read bytes from the USB OUT endpoint into the USART transmit buffer
if (!(ReceivedByte < 0)){
RingBuffer_Insert(&FromHost_Buffer, ReceivedByte);
CDC_Device_SendByte(&VirtualSerial_CDC_Interface, ReceivedByte);
}
}
while (RingBuffer_GetCount(&FromHost_Buffer) > 0)
{
int16_t c = RingBuffer_Remove(&FromHost_Buffer);
if(c == '\n' || c == '\r'){
if(cmd_cnt > 0 && (cmd[cmd_cnt-1] == '\n' || cmd[cmd_cnt-1] == '\r'))
cmd_cnt--;
cmd[cmd_cnt] = 0;
execute_command();
cmd_cnt = 0;
}
else{
cmd[cmd_cnt++] = c;
}
}
}
示例10: CAN_rx
/**
* @details Moves received on-chip CAN messages into ring buffer
*
* @param msg_obj_num CAN message object that received message
*/
void CAN_rx(uint8_t msg_obj_num) {
/* Determine which CAN message has been received */
can_msg_obj.msgobj = msg_obj_num;
/* Now load up the msg_obj structure with the CAN message */
LPC_CCAN_API->can_receive(&can_msg_obj);
RingBuffer_Insert(&rx_buffer, &can_msg_obj);
}
示例11: main
/** Main program entry point. This routine contains the overall program flow, including initial
* setup of all components and the main program loop.
*/
int main(void)
{
SetupHardware();
RingBuffer_InitBuffer(&USBtoUSART_Buffer, USBtoUSART_Buffer_Data, sizeof(USBtoUSART_Buffer_Data));
RingBuffer_InitBuffer(&ToUSB_Buffer, ToUSB_Buffer_Data, sizeof(ToUSB_Buffer_Data));
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
sei();
for (;;)
{
/* Only try to read in bytes from the CDC interface if the transmit buffer is not full */
if (!(RingBuffer_IsFull(&USBtoUSART_Buffer)))
{
int16_t ReceivedByte = CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface);
/* Read bytes from the USB OUT endpoint into the USART transmit buffer */
if (!(ReceivedByte < 0))
RingBuffer_Insert(&USBtoUSART_Buffer, ReceivedByte);
}
/* Load the next byte from the USART transmit buffer into the USART */
if (!(RingBuffer_IsEmpty(&USBtoUSART_Buffer)))
Serial_SendByte(RingBuffer_Remove(&USBtoUSART_Buffer));
cdc_send_USB_data(&VirtualSerial_CDC_Interface);
USB_USBTask();
}
}
示例12: ISR
/** ISR to manage the reception of data from the serial port, placing received bytes into a circular buffer
* for later transmission to the host.
*/
ISR(USART1_RX_vect, ISR_BLOCK)
{
uint8_t ReceivedByte = UDR1;
if (USB_DeviceState == DEVICE_STATE_Configured)
RingBuffer_Insert(&USARTtoUSB_Buffer, ReceivedByte);
}
示例13: RFM12B_Receive
void RFM12B_Receive( void )
{
uint8_t ch = RFM12B_SPI_Transfer( RFM12B_RX_FIFO_READ ) & 0xFF;
if ( RxLength == 0 )
{
if ( ch == 0 )
{
RFM12B_EndOfPacket();
}
else
{
RxLength = ch;
RxTimeout = 0;
}
}
else
{
RingBuffer_Insert( &RF12toUSB_Buffer, ch );
/* Decrement the RxLength for each byte of payload received.
When it gets to zero that's the end of the packet */
if ( --RxLength == 0 ) RFM12B_EndOfPacket();
}
}
示例14: Chip_UART_RXIntHandlerRB
/* UART receive-only interrupt handler for ring buffers */
void Chip_UART_RXIntHandlerRB(LPC_USART_T *pUART, RINGBUFF_T *pRB)
{
/* New data will be ignored if data not popped in time */
while (Chip_UART_ReadLineStatus(pUART) & UART_LSR_RDR) {
uint8_t ch = Chip_UART_ReadByte(pUART);
RingBuffer_Insert(pRB, &ch);
}
}
示例15: Chip_UARTN_RXIntHandlerRB
/* UART receive-only interrupt handler for ring buffers */
void Chip_UARTN_RXIntHandlerRB(LPC_USARTN_T *pUART, RINGBUFF_T *pRB)
{
/* New data will be ignored if data not popped in time */
while ((Chip_UARTN_GetStatus(pUART) & UARTN_STAT_RXRDY) != 0) {
uint8_t ch = Chip_UARTN_ReadByte(pUART);
RingBuffer_Insert(pRB, &ch);
}
}