コード例 #1
0
ファイル: JackVST.cpp プロジェクト: briancline/jackosx
//-----------------------------------------------------------------------------------------
void JackVST::Close()
{
	fStatus = kIsOff;
	list<JackVST*>::iterator it;
	
	printf("actually there are %ld instances.\n",JackVST::fPlugInList.size());
	JackVST::fPlugInList.remove(this);
	printf("now there are %ld instances.\n",JackVST::fPlugInList.size());
	
	for(int i = 0; i < fInPortsNum; i++) {
		RingBuffer_Flush(&fRingBufferIn[i]);	
		free(fRBufferIn[i]);
		jack_port_unregister(JackVST::fJackClient,fInPorts[i]);
		printf("unregistering in port %d.\n",i);
	}
	free(fInPorts);
	
	for(int i = 0; i < fOutPortsNum; i++) {
		RingBuffer_Flush(&fRingBufferIn[i]);	
		free(fRBufferOut[i]);
		jack_port_unregister(JackVST::fJackClient,fOutPorts[i]);
		printf("unregistering out port %d.\n",i);
	}
	free(fOutPorts);
				
	if(JackVST::fPlugInList.size() == 0) { 
		printf("closing client.\n"); 
		jack_deactivate(JackVST::fJackClient); 
		jack_client_close(JackVST::fJackClient);
		JackVST::fJackClient = NULL;
		JackVST::fInstances = 0;
	} 
}
コード例 #2
0
void test_RingBuffer_Flush_empties_the_ring_buffer(void)
{
  RingBuffer_Put(&rb, 'A');
  RingBuffer_Flush(&rb);

  TEST_ASSERT_EQUAL(0, rb.len);
  TEST_ASSERT_EQUAL(0, rb.head);
  TEST_ASSERT_EQUAL(0, rb.tail);
}
コード例 #3
0
ファイル: skynet_cdc.c プロジェクト: i7sid/SkyNet-Dongle
int skynet_cdc_init(void) {
	USBD_API_INIT_PARAM_T usb_param;
	USB_CORE_DESCS_T desc;
	ErrorCode_t ret = LPC_OK;

	RingBuffer_Init(&usb_tx_ringbuf, usb_tx_buf, sizeof(uint8_t), USB_TX_FIFO_QUEUE_SIZE);
	RingBuffer_Flush(&usb_tx_ringbuf);

	Chip_USB_Init();

	LPC_USB->USBClkCtrl = 0x12;                /* Dev, AHB clock enable */
	while ((LPC_USB->USBClkSt & 0x12) != 0x12);

	/* initialize call back structures */
	memset((void *) &usb_param, 0, sizeof(USBD_API_INIT_PARAM_T));
	usb_param.usb_reg_base = LPC_USB_BASE + 0x200;
	usb_param.max_num_ep = 3;
	usb_param.mem_base = USB_STACK_MEM_BASE;
	usb_param.mem_size = USB_STACK_MEM_SIZE;

	/* Set the USB descriptors */
	desc.device_desc = (uint8_t *) &USB_DeviceDescriptor[0];
	desc.string_desc = (uint8_t *) &USB_StringDescriptor[0];
	/* Note, to pass USBCV test full-speed only devices should have both
	   descriptor arrays point to same location and device_qualifier set to 0.
	 */
	desc.high_speed_desc = (uint8_t *) &USB_FsConfigDescriptor[0];
	desc.full_speed_desc = (uint8_t *) &USB_FsConfigDescriptor[0];
	desc.device_qualifier = 0;

	/* USB Initialization */
	ret = USBD_API->hw->Init(&g_hUsb, &desc, &usb_param);
	if (ret == LPC_OK) {

		/* Init VCOM interface */
		ret = vcom_init(g_hUsb, &desc, &usb_param);
		if (ret == LPC_OK) {
			/*  enable USB interrupts */
			NVIC_EnableIRQ(USB_IRQn);

			// first disable to simulate re-plug
			skynet_cdc_disconnect();

			msDelay(100);

			// and now enable connection
			skynet_cdc_connect();

			return 1;
		}
	}

	//char* welcome_msg = "# This is skynet dongle.\n";
	//vcom_write(welcome_msg, strlen(welcome_msg));
	return 0;
}
コード例 #4
0
ファイル: ringbuffer.c プロジェクト: DmitrySigaev/DSMedia
/***************************************************************************
 * Initialize FIFO.
 * numBytes must be power of 2, returns -1 if not.
 */
long RingBuffer_Init( RingBuffer *rbuf, long numBytes, void *dataPtr )
{
    if( ((numBytes-1) & numBytes) != 0) return -1; /* Not Power of two. */
    rbuf->bufferSize = numBytes;
    rbuf->buffer = (char *)dataPtr;
    RingBuffer_Flush( rbuf );
    rbuf->bigMask = (numBytes*2)-1;
    rbuf->smallMask = (numBytes)-1;
    return 0;
}
コード例 #5
0
/* This should be called after stopping or aborting the stream, so that on next
   start, the buffers will be ready. */
PaError resetBlioRingBuffers( PaMacBlio *blio )
{
#ifdef PA_MAC__BLIO_MUTEX
   int result;
#endif
   blio->statusFlags = 0;
   if( blio->outputRingBuffer.buffer ) {
      RingBuffer_Flush( &blio->outputRingBuffer );
      bzero( blio->outputRingBuffer.buffer,
             blio->outputRingBuffer.bufferSize );
      /* Advance buffer */
      RingBuffer_AdvanceWriteIndex( &blio->outputRingBuffer, blio->outputRingBuffer.bufferSize );

      /* Update isOutputFull. */
#ifdef PA_MAC__BLIO_MUTEX
      result = blioSetIsOutputFull( blio, toAdvance == blio->outputRingBuffer.bufferSize );
      if( result )
         goto error;
#endif
/*
      printf( "------%d\n" ,  blio->framesPerBuffer );
      printf( "------%d\n" ,  blio->outChan );
      printf( "------%d\n" ,  blio->outputSampleSize );
      printf( "------%d\n" ,  blio->framesPerBuffer*blio->outChan*blio->outputSampleSize );
*/
   }
   if( blio->inputRingBuffer.buffer ) {
      RingBuffer_Flush( &blio->inputRingBuffer );
      bzero( blio->inputRingBuffer.buffer,
             blio->inputRingBuffer.bufferSize );
      /* Update isInputEmpty. */
#ifdef PA_MAC__BLIO_MUTEX
      result = blioSetIsInputEmpty( blio, true );
      if( result )
         goto error;
#endif
   }
   return paNoError;
#ifdef PA_MAC__BLIO_MUTEX
 error:
   return result;
#endif
}
コード例 #6
0
ファイル: main.c プロジェクト: MITEVT/opel_driver_interface
void chip_startup_routine(void) {
	SystemCoreClockUpdate();
	// Initialize SysTick Timer to generate millisecond count
	if (Board_SysTick_Init()) {
		while(1); // Unrecoverable Error. Hang.
	}

	// Initialize UART Communication
	Board_UART_Init(UART_BAUD_RATE);
	Board_UART_Println("Started up driver interface!");

	// Initialize GPIO and LED as output
	Board_LEDs_Init();
	Board_LED_On(LED0);
	Board_LED_On(LED1);

	// Initialize CAN  and CAN Ring Buffer
	RingBuffer_Init(&CAN_rx_buffer, _rx_buffer, sizeof(CCAN_MSG_OBJ_T), BUF_SIZE);
	RingBuffer_Flush(&CAN_rx_buffer);

	Board_CAN_Init(CCAN_BAUD_RATE, CAN_rx, CAN_tx, CAN_error);
	can_error_flag = false;
	can_error_info = 0;
}
コード例 #7
0
/* clear UART rx ringbuffer */
void UART_FlushRxRB(void)
{
	Chip_UART_SetupFIFOS(LPC_USART, (UART_FCR_FIFO_EN | UART_FCR_TRG_LEV2 | UART_FCR_RX_RS));
	RingBuffer_Flush(&uart_rxrb);
}
コード例 #8
0
/* clear UCOM rx ringbuffer */
void UCOM_FlushRxRB(void)
{
	RingBuffer_Flush(&usb_rxrb);
}
コード例 #9
0
ファイル: hid_ucom.c プロジェクト: peterwillcn/Avalon-nano
void UCOM_Flush(void)
{
	RingBuffer_Flush(&usb_txrb);
	RingBuffer_Flush(&usb_rxrb);
}
コード例 #10
0
int main(void)
{

	//---------------
	// Initialize SysTick Timer to generate millisecond count
	if (Board_SysTick_Init()) {
		// Unrecoverable Error. Hang.
		while(1);
	}

	//---------------
	// Initialize GPIO and LED as output
	Board_LEDs_Init();
	Board_LED_On(LED0);
	Board_LED_On(LED1);
	Board_LED_On(LED2);
	Board_LED_On(LED3);

	//Initialize I2C
	Board_I2C_Init();

	//---------------
	// Initialize UART Communication
	Board_UART_Init(UART_BAUD_RATE);
	Board_UART_Println("Started up");

	//---------------
	// Initialize CAN  and CAN Ring Buffer

	RingBuffer_Init(&can_rx_buffer, _rx_buffer, sizeof(CCAN_MSG_OBJ_T), BUFFER_SIZE);
	RingBuffer_Flush(&can_rx_buffer);

	Board_CAN_Init(CCAN_BAUD_RATE, CAN_rx, CAN_tx, CAN_error);

	// For your convenience.
	// typedef struct CCAN_MSG_OBJ {
	// 	uint32_t  mode_id;
	// 	uint32_t  mask;
	// 	uint8_t   data[8];
	// 	uint8_t   dlc;
	// 	uint8_t   msgobj;
	// } CCAN_MSG_OBJ_T;

	/* [Tutorial] How do filters work?

		Incoming ID & Mask == Mode_ID for msgobj to accept message

		Incoming ID : 0xabc
		Mask: 		  0xF0F &
		            -----------
		              0xa0c

		mode_id == 0xa0c for msgobj to accept message

	*/

	//Set mask to only accept messages from Driver Interface
	msg_obj.msgobj = 1;
	msg_obj.mode_id = DI_PACKET__id;
	msg_obj.mask = 0x555;
	LPC_CCAN_API->config_rxmsgobj(&msg_obj);

	can_error_flag = false;
	can_error_info = 0;
	
	lastPrint = msTicks;	

	PDM_STATUS_T pdm_status;
	
	int tmp;
	bool lv_i2c = true, cs_i2c = true, mux_i2c = true;

	//Board_I2C_Reset(I2C_GG_CONTINUOUS, i2c_tx_buffer);

	//Open I2C Channel 0
	i2c_tx_buffer[0] = I2C_MUX_CHANNEL_0;
	tmp = Chip_I2C_MasterSend(DEFAULT_I2C, I2C_MUX_SLAVE_ADDRESS, i2c_tx_buffer, 1);
	Board_UART_Print("Opened Channel 0: ");
	Board_UART_PrintNum(tmp, 10, true);

	//Set Gas Gauge 0 to continuous data collection
	i2c_tx_buffer[0] = I2C_GG_CTRL_REG;
	i2c_tx_buffer[1] = I2C_GG_CONTINUOUS;
	tmp = Chip_I2C_MasterSend(DEFAULT_I2C, I2C_GG_SLAVE_ADDRESS, i2c_tx_buffer, 2);
	Board_UART_Print("Set I2C0 to continuous data collection: ");
	Board_UART_PrintNum(tmp, 10, true);

	//Open I2C Channel 1
	i2c_tx_buffer[0] = I2C_MUX_CHANNEL_1;
	tmp = Chip_I2C_MasterSend(DEFAULT_I2C, I2C_MUX_SLAVE_ADDRESS, i2c_tx_buffer, 1);
	Board_UART_Print("Opened Channel 1: ");
	Board_UART_PrintNum(tmp, 10, true);

	//Set Gas Gauge 1 to continuous data collection
	i2c_tx_buffer[0] = I2C_GG_CTRL_REG;
	i2c_tx_buffer[1] = I2C_GG_CONTINUOUS;
	tmp = Chip_I2C_MasterSend(DEFAULT_I2C, I2C_GG_SLAVE_ADDRESS, i2c_tx_buffer, 2);
	Board_UART_Print("Set I2C1 to continuous data collection: ");
	Board_UART_PrintNum(tmp, 10, true);

	

	while (1) {
		
		//Set PDM status based on CAN messages from Driver Interface
		if (!RingBuffer_IsEmpty(&can_rx_buffer)) {					
			CCAN_MSG_OBJ_T temp_msg;
			RingBuffer_Pop(&can_rx_buffer, &temp_msg);
			//Test for DI OFF or SHUTDOWN IMPENDING message
			if((temp_msg.data[3] << 8 | temp_msg.data[2]) == ____DI_PACKET__DRIVE_STATUS__SHUTDOWN_IMPENDING ||	
					(temp_msg.data[3] << 8 | temp_msg.data[2]) == ____DI_PACKET__DRIVE_STATUS__OFF) {	
				if(pdm_status.pdm_on) {							
					pdm_status.pdm_on = false;
					Board_LED_Off(LED0);
					Board_I2C_Reset(I2C_GG_SLEEP, i2c_tx_buffer);
				}
			}
			else {
				if(!(pdm_status.pdm_on)) {
					pdm_status.pdm_on = true;
					Board_LED_On(LED0);
					Board_I2C_Reset(I2C_GG_CONTINUOUS, i2c_tx_buffer);
				}
			}
		}
		

		//Reset gas gauge 0 if it has been diconnected and then reconnected to power
		i2c_tx_buffer[0] = I2C_MUX_CHANNEL_0;
		tmp = Chip_I2C_MasterSend(DEFAULT_I2C, I2C_MUX_SLAVE_ADDRESS, i2c_tx_buffer, 1);	//Open I2C Channel 0
		tmp = Chip_I2C_MasterCmdRead(DEFAULT_I2C, I2C_GG_SLAVE_ADDRESS, I2C_GG_CTRL_REG, i2c_rx_buffer, 1);	
		Board_UART_PrintNum(i2c_rx_buffer[0],16,true);
		if((uint16_t)i2c_rx_buffer[0] == I2C_GG_DEFAULT) {					//Test for default values in control register
			if(pdm_status.pdm_on) {
				Board_I2C_Reset(I2C_GG_CONTINUOUS, i2c_tx_buffer);
			}
			else {
				Board_I2C_Reset(I2C_GG_SLEEP, i2c_tx_buffer);
			}
			//Send a heartbeat with a com error
			Board_CAN_SendHeartbeat(&pdm_status, &msg_obj, true);
		}

			
		//Reset gas gauge 1 if it has been diconnected and then reconnected to power	
		i2c_tx_buffer[0] = I2C_MUX_CHANNEL_1;
		tmp = Chip_I2C_MasterSend(DEFAULT_I2C, I2C_MUX_SLAVE_ADDRESS, i2c_tx_buffer, 1);	//Open 12C Channel 1
		tmp = Chip_I2C_MasterCmdRead(DEFAULT_I2C, I2C_GG_SLAVE_ADDRESS, I2C_MUX_CHANNEL_0, i2c_rx_buffer, 1);
		Board_UART_PrintNum(i2c_rx_buffer[0],16,true);
		if((uint16_t)i2c_rx_buffer[0] == I2C_GG_DEFAULT) {					//Test for default values in control register
			if(pdm_status.pdm_on) {
				Board_I2C_Reset(I2C_GG_CONTINUOUS, i2c_tx_buffer);
			}
			else {
				Board_I2C_Reset(I2C_GG_SLEEP, i2c_tx_buffer);
			}
			//Send a heartbeat with a com error
			Board_CAN_SendHeartbeat(&pdm_status, &msg_obj, true);
		}


		/* Update PDM and Debug LED code */

		//Attempt to open I2C Channel 0
		i2c_tx_buffer[0] = I2C_MUX_CHANNEL_0;
		mux_i2c = Chip_I2C_MasterSend(DEFAULT_I2C, I2C_MUX_SLAVE_ADDRESS, i2c_tx_buffer, 1);	
		//Attempt to update Critical Systems PDM Struct
		cs_i2c = Board_PDM_Status_Update(&pdm_status, i2c_rx_buffer, true);			
		//Attempt to open I2C Channel 1
		i2c_tx_buffer[0] = I2C_MUX_CHANNEL_1;
		mux_i2c = Chip_I2C_MasterSend(DEFAULT_I2C, I2C_MUX_SLAVE_ADDRESS, i2c_tx_buffer, 1);	
		//Attempt to update Low Voltage PDM struct
		lv_i2c = Board_PDM_Status_Update(&pdm_status, i2c_rx_buffer, false);			
		//Run debug logic and update state
		Board_PDM_Status_Debug(&pdm_status, mux_i2c, cs_i2c, lv_i2c);

		if(msTicks - lastPrint > FREQ_THRESHOLD){				// 10 times per second
			lastPrint = msTicks;				// Store the current time, to allow the process to be done in another 1/10 seconds
			
			Board_CAN_SendHeartbeat(&pdm_status, &msg_obj, false);
		}
	}
}
コード例 #11
0
ファイル: main.c プロジェクト: MITEVT/can_validator
int main(void)
{

	//---------------
	// Initialize UART Communication
	Board_UART_Init(UART_BAUD_RATE);
	Board_UART_Println("Started up");

	//---------------
	// Initialize SysTick Timer to generate millisecond count
	if (Board_SysTick_Init()) {
		Board_UART_Println("Failed to Initialize SysTick. ");
		// Unrecoverable Error. Hang.
		while(1);
	}

	//---------------
	// Initialize GPIO and LED as output
	Board_LEDs_Init();
	Board_LED_On(LED0);

	//---------------
	// Initialize CAN  and CAN Ring Buffer

	RingBuffer_Init(&can_rx_buffer, _rx_buffer, sizeof(CCAN_MSG_OBJ_T), BUFFER_SIZE);
	RingBuffer_Flush(&can_rx_buffer);

	Board_CAN_Init(CCAN_BAUD_RATE, CAN_rx, CAN_tx, CAN_error);

	// For your convenience.
	// typedef struct CCAN_MSG_OBJ {
	// 	uint32_t  mode_id;
	// 	uint32_t  mask;
	// 	uint8_t   data[8];
	// 	uint8_t   dlc;
	// 	uint8_t   msgobj;
	// } CCAN_MSG_OBJ_T;

	msg_obj.msgobj = 1;
	msg_obj.mode_id = 0x000;
	msg_obj.mask = 0x000;
	LPC_CCAN_API->config_rxmsgobj(&msg_obj);

	can_error_flag = false;
	can_error_info = 0;

	uint8_t status_led_state = 1;
	uint32_t status_led_time = msTicks;

	while (1) {
		if (!RingBuffer_IsEmpty(&can_rx_buffer)) {
			Board_LED_On(LED3);
			CCAN_MSG_OBJ_T temp_msg;
			RingBuffer_Pop(&can_rx_buffer, &temp_msg);
			Board_UART_PrintNum(temp_msg.mode_id, 16, false);
			Board_UART_Print("\t");
			Board_UART_PrintNum(temp_msg.dlc, 10, false);

			int i = 0;
			for (i = 0; i < temp_msg.dlc; i++) {
				Board_UART_Print("\t");
				Board_UART_PrintNum(temp_msg.data[i], 16, false);
			}

			Board_UART_Println("");
			Board_LED_Off(LED3);
		}	

		if (can_error_flag) {
			can_error_flag = false;
			Board_UART_Print("CAN Error: 0b");
			Board_UART_PrintNum(can_error_info, 2, true);
		}

		if (msTicks - status_led_time > STATUS_LED_PERIOD) {
			status_led_time = msTicks;
			status_led_state = 1 - status_led_state;
			Board_LED_Set(LED0, status_led_state);
		}
	}
}
コード例 #12
0
ファイル: test.c プロジェクト: MITEVT/opel_throttle_interface
int main(void) {
	if (Board_SysTick_Init()) {
		while(1);
	}

	Board_LEDs_Init();
	Board_LED_On(LED0);
	Board_ADC_Init();

	uint16_t tps_data = 0;
	int16_t tps_error = 0;

	Board_UART_Init(9600);

	DEBUG_Print("Started up\n\r");

	RingBuffer_Init(&rx_buffer, _rx_buffer, sizeof(CCAN_MSG_OBJ_T), 8);
	RingBuffer_Flush(&rx_buffer);

	Board_CAN_Init(TEST_CCAN_BAUD_RATE, CAN_rx, CAN_tx, CAN_error);

	msg_obj.msgobj = 1;
	msg_obj.mode_id = 0x301;
	msg_obj.mask = 0x000;
	LPC_CCAN_API->config_rxmsgobj(&msg_obj);

	can_error_flag = false;
	can_error_info = 0;
	
	bool send = false;
	while (1) {
		
		Board_TPS_ADC_Read(&tps_data);		
	
//		itoa(tps_data,tx_buffer_str,10);
//		DEBUG_Print("TPS_DATA:");
//		DEBUG_Print(tx_buffer_str);
//		DEBUG_Print("\r\n");

		if (!RingBuffer_IsEmpty(&rx_buffer)) {
			CCAN_MSG_OBJ_T temp_msg;
			RingBuffer_Pop(&rx_buffer, &temp_msg);
			DEBUG_Print("Received Message ID: 0x");
			itoa(temp_msg.mode_id, str, 16);
			DEBUG_Print(str);
			DEBUG_Print("\r\n");
		}
		
		if (can_error_flag) {
			can_error_flag = false;
			DEBUG_Print("CAN Error: 0b");
			itoa(can_error_info, str, 2);
			DEBUG_Print(str);
			DEBUG_Print("\r\n");
		}
		
		if (send) {
			DEBUG_Print("Sending CAN with ID: 0x301\r\n");
			msg_obj.msgobj = 2;
			msg_obj.mode_id = 0x301;
			msg_obj.dlc = 4;
			msg_obj.data[0] = tps_data>>2;
			msg_obj.data[1] = (uint8_t) 0x00;
			msg_obj.data[2] = (uint8_t) tps_error;
			LPC_CCAN_API->can_transmit(&msg_obj);
			Board_UART_PrintNum(msg_obj.data[0],10,true);
			Board_UART_PrintNum(msg_obj.data[1],10,true);
			Board_UART_PrintNum(msg_obj.data[2],10,true);
		}

		uint8_t count;
		count = Chip_UART_Read(LPC_USART, uart_rx_buf, UART_RX_BUFFER_SIZE);
		if (count != 0) {
			switch (uart_rx_buf[0]) {
				case 'a':
					send = true;
					break;
				case 'z':
					send = false;
					break;
				case 'r':
					DEBUG_Print("Sending CAN with ID: 0x301\r\n");
					msg_obj.msgobj = 2;
					msg_obj.mode_id = 0x301;
					msg_obj.dlc = 2;
					msg_obj.data[0] = tps_data;
					msg_obj.data[1] = tps_error;
					LPC_CCAN_API->can_transmit(&msg_obj);
					Board_UART_PrintNum(msg_obj.data[0],10,true);
					Board_UART_PrintNum(msg_obj.data[1],10,true);
					break;
				
				default:
					DEBUG_Print("Invalid Command\r\n");
					break;
			}
		}
	}
}
コード例 #13
0
ファイル: uartHandler.c プロジェクト: Wiznet/WIZ550S2E
void UART_buffer_flush(RINGBUFF_T *buf)
{
	RingBuffer_Flush(buf);
}
コード例 #14
0
/**
 * @details Initializes both on-chip and off-chip CAN and sets up filters and masks.
 */
void Init_CAN(void) {
	// ------------------------------------------------
	// MCP2515 Init
	MCP2515_Init(MCP_CS_GPIO, MCP_CS_PIN, MCP_INT_GPIO, MCP_INT_PIN);
	uint8_t i = MCP2515_SetBitRate(MCP_BAUD_KHZ, MCP_INP_CLK_MHZ, MCP_SJW);
	itoa(i, str, 10);
	if (i) {
		DEBUG_Print("Baud Error: ");
		DEBUG_Print(str);
		DEBUG_Print("\r\n");
		_error(ERROR_CAN_BUS, true, true);
	}

	Brusa_MakeCTL(&brusa_control, &mcp_msg_obj);
	MCP2515_LoadBuffer(0, &mcp_msg_obj);

	MCP2515_BitModify(RXB0CTRL, RXM_MASK, RXM_STD); //Turn RXB0 Mask
	MCP2515_BitModify(RXB1CTRL, RXM_MASK, RXM_STD);
	MCP2515_BitModify(RXF0SIDH, 0xFF, 0xC2);
	MCP2515_BitModify(RXF0SIDL, 0xE0, 0x00); // Message 610
	MCP2515_BitModify(RXF1SIDH, 0xFF, 0xC2);
	MCP2515_BitModify(RXF1SIDL, 0xE0, 0x80); // Message 614
	MCP2515_BitModify(RXM0SIDH, 0xFF, 0xFF);
	MCP2515_BitModify(RXM0SIDL, 0xE0, 0xE0); // Buffer 0 gets odd
	MCP2515_BitModify(RXF2SIDH, 0xFF, 0xC2);
	MCP2515_BitModify(RXF2SIDL, 0xE0, 0x20); // Message 611
	MCP2515_BitModify(RXF3SIDH, 0xFF, 0xC2);
	MCP2515_BitModify(RXF3SIDL, 0xE0, 0x60); // Message 613
	MCP2515_BitModify(RXF4SIDH, 0xFF, 0xC2);
	MCP2515_BitModify(RXF4SIDL, 0xE0, 0x20); // Message 611
	MCP2515_BitModify(RXF5SIDH, 0xFF, 0xC2);
	MCP2515_BitModify(RXF5SIDL, 0xE0, 0x20); // Message 611
	MCP2515_BitModify(RXM1SIDH, 0xFF, 0xFF);
	MCP2515_BitModify(RXM1SIDL, 0xE0, 0xE0); // Buffer 1 gets even

	MCP2515_Mode(MODE_NORMAL);

	// ------------------------------------------------
	// On-Chip CCAN Init
	RingBuffer_Init(&rx_buffer, _rx_buffer, sizeof(CCAN_MSG_OBJ_T), 8);
	RingBuffer_Flush(&rx_buffer);

	// MBB_STD
	can_msg_obj.msgobj = MBB_STD_MSG_OBJ;
	can_msg_obj.mode_id = 0x200;
	can_msg_obj.mask = 0xF00;
	LPC_CCAN_API->config_rxmsgobj(&can_msg_obj);

	// MBB_EXT_1
	can_msg_obj.msgobj = MBB_EXT_1_MSG_OBJ;
	can_msg_obj.mode_id = 0x300;
	can_msg_obj.mask = 0xF00;
	LPC_CCAN_API->config_rxmsgobj(&can_msg_obj);

	// MBB_EXT_2
	can_msg_obj.msgobj = MBB_EXT_2_MSG_OBJ;
	can_msg_obj.mode_id = 0x400;
	can_msg_obj.mask = 0xF00;
	LPC_CCAN_API->config_rxmsgobj(&can_msg_obj);

	// MBB_EXT_3
	can_msg_obj.msgobj = MBB_EXT_3_MSG_OBJ;
	can_msg_obj.mode_id = 0x500;
	can_msg_obj.mask = 0xF00;
	LPC_CCAN_API->config_rxmsgobj(&can_msg_obj);

	// MBB_EXT_4
	can_msg_obj.msgobj = MBB_EXT_4_MSG_OBJ;
	can_msg_obj.mode_id = 0x600;
	can_msg_obj.mask = 0xF00;
	LPC_CCAN_API->config_rxmsgobj(&can_msg_obj);
}
コード例 #15
0
ファイル: skynet_cdc.c プロジェクト: i7sid/SkyNet-Dongle
void skynet_cdc_flush_buffers(void) {
	RingBuffer_Flush(&usb_tx_ringbuf);
}
コード例 #16
0
ファイル: avalon_uart.c プロジェクト: Johnson-Fan/Avalon-nano
/* clear UART tx ringbuffer */
void uart_flush_txrb(void)
{
    Chip_UART_SetupFIFOS(LPC_USART, (UART_FCR_FIFO_EN | UART_FCR_TRG_LEV2 | UART_FCR_TX_RS));
    RingBuffer_Flush(&uart_txrb);
}