Esempio n. 1
0
void vQueueOverwritePeriodicISRDemo( void )
{
static uint32_t ulCallCount = 0;
const uint32_t ulTx1 = 10UL, ulTx2 = 20UL, ulNumberOfSwitchCases = 3UL;
uint32_t ulRx;

	/* This function should be called from an interrupt, such as the tick hook
	function vApplicationTickHook(). */

	configASSERT( xISRQueue );

	switch( ulCallCount )
	{
		case 0:
			/* The queue is empty.  Write ulTx1 to the queue.  In this demo the
			last parameter is not used because there are no tasks blocked on
			this queue. */
			xQueueOverwriteFromISR( xISRQueue, &ulTx1, NULL );

			/* Peek the queue to check it holds the expected value. */
			xQueuePeekFromISR( xISRQueue, &ulRx );
			if( ulRx != ulTx1 )
			{
				xISRTestStatus = pdFAIL;
			}
			break;

		case 1:
			/* The queue already holds ulTx1.  Overwrite the value in the queue
			with ulTx2. */
			xQueueOverwriteFromISR( xISRQueue, &ulTx2, NULL );
			break;

		case 2:
			/* Read from the queue to empty the queue again.  The value read
			should be ulTx2. */
			xQueueReceiveFromISR( xISRQueue, &ulRx, NULL );

			if( ulRx != ulTx2 )
			{
				xISRTestStatus = pdFAIL;
			}
			break;
	}

	/* Run the next case in the switch statement above next time this function
	is called. */
	ulCallCount++;

	if( ulCallCount >= ulNumberOfSwitchCases )
	{
		/* Go back to the start. */
		ulCallCount = 0;
	}
}
Esempio n. 2
0
File: ecu_can.c Progetto: aakre/ecu
/* Call Back called by can_drv, channel 1 */
void can_out_callback_channel1(U8 handle, U8 event){
	if (handle == mob_rx_speed_sens_fl.handle) {
		mob_rx_speed_sens_fl.can_msg->data.u64	= can_get_mob_data(CAN_BUS_1, handle).u64;
		mob_rx_speed_sens_fl.can_msg->id		= can_get_mob_id(CAN_BUS_1, handle);
		mob_rx_speed_sens_fl.dlc				= can_get_mob_dlc(CAN_BUS_1, handle);
		mob_rx_speed_sens_fl.status				= event;
		
		xQueueOverwriteFromISR(queue_wheel_fl, &mob_rx_speed_sens_fl.can_msg->data.u16[0], NULL);
		/* Empty message field */
		mob_rx_speed_sens_fl.can_msg->data.u64 = 0x0LL;
		
		/* Prepare message reception */
		can_rx(CAN_BUS_1,
		mob_rx_speed_sens_fl.handle,
		mob_rx_speed_sens_fl.req_type,
		mob_rx_speed_sens_fl.can_msg);
		
	} else if (handle == mob_rx_speed_sens_fr.handle) {
		mob_rx_speed_sens_fr.can_msg->data.u64	= can_get_mob_data(CAN_BUS_1, handle).u64;
		mob_rx_speed_sens_fr.can_msg->id		= can_get_mob_id(CAN_BUS_1, handle);
		mob_rx_speed_sens_fr.dlc				= can_get_mob_dlc(CAN_BUS_1, handle);
		mob_rx_speed_sens_fr.status				= event;
		
		xQueueOverwriteFromISR(queue_wheel_fr, &mob_rx_speed_sens_fr.can_msg->data.u16[0], NULL);
		/* Empty message field */
		mob_rx_speed_sens_fr.can_msg->data.u64 = 0x0LL;
		
		/* Prepare message reception */
		can_rx(CAN_BUS_1,
		mob_rx_speed_sens_fr.handle,
		mob_rx_speed_sens_fr.req_type,
		mob_rx_speed_sens_fr.can_msg);
	} else if (handle == mob_rx_speed_sens_rl.handle) {
		mob_rx_speed_sens_rl.can_msg->data.u64	= can_get_mob_data(CAN_BUS_1, handle).u64;
		mob_rx_speed_sens_rl.can_msg->id			= can_get_mob_id(CAN_BUS_1, handle);
		mob_rx_speed_sens_rl.dlc					= can_get_mob_dlc(CAN_BUS_1, handle);
		mob_rx_speed_sens_rl.status				= event;

		xQueueOverwriteFromISR(queue_wheel_rl, &mob_rx_speed_sens_rl.can_msg->data.u16[0], NULL);
	
		/* Empty message field */
		mob_rx_speed_sens_rl.can_msg->data.u64 = 0x0LL;
		
		/* Prepare message reception */
		can_rx(CAN_BUS_1, 
		mob_rx_speed_sens_rl.handle,
		mob_rx_speed_sens_rl.req_type,
		mob_rx_speed_sens_rl.can_msg);
		
	} else if (handle == mob_rx_speed_sens_rr.handle) {
		mob_rx_speed_sens_rr.can_msg->data.u64	= can_get_mob_data(CAN_BUS_1, handle).u64;
		mob_rx_speed_sens_rr.can_msg->id		= can_get_mob_id(CAN_BUS_1, handle);
		mob_rx_speed_sens_rr.dlc				= can_get_mob_dlc(CAN_BUS_1, handle);
		mob_rx_speed_sens_rr.status				= event;

		xQueueOverwriteFromISR(queue_wheel_rr, &mob_rx_speed_sens_rr.can_msg->data.u16[0], NULL);
		
		/* Empty message field */
		mob_rx_speed_sens_rr.can_msg->data.u64 = 0x0LL;
		
		/* Prepare message reception */
		can_rx(CAN_BUS_1,
		mob_rx_speed_sens_rr.handle,
		mob_rx_speed_sens_rr.req_type,
		mob_rx_speed_sens_rr.can_msg);
	
	}	else if (handle == mob_rx_trq_sens1.handle) {
		mob_rx_trq_sens1.can_msg->data.u64	= can_get_mob_data(CAN_BUS_1, handle).u64;
		mob_rx_trq_sens1.can_msg->id			= can_get_mob_id(CAN_BUS_1, handle);
		mob_rx_trq_sens1.dlc					= can_get_mob_dlc(CAN_BUS_1, handle);
		mob_rx_trq_sens1.status					= event;
		
		xQueueOverwriteFromISR(queue_trq_sens1, &mob_rx_trq_sens1.can_msg->data.s16[0], NULL);
		xQueueOverwriteFromISR(queue_trq_sens1_err, &mob_rx_trq_sens1.can_msg->data.u8[2], NULL);
		asm("nop");
		/* Empty message field */
		mob_rx_trq_sens1.can_msg->data.u64 = 0x0LL;
		
		/* Prepare message reception */
		can_rx(CAN_BUS_1, 
		mob_rx_trq_sens1.handle,
		mob_rx_trq_sens1.req_type,
		mob_rx_trq_sens1.can_msg);
	
	} else if (handle == mob_rx_bms_precharge.handle) {
		mob_rx_bms_precharge.can_msg->data.u64	= can_get_mob_data(CAN_BUS_1, handle).u64;
		mob_rx_bms_precharge.can_msg->id		= can_get_mob_id(CAN_BUS_1, handle);
		mob_rx_bms_precharge.dlc				= can_get_mob_dlc(CAN_BUS_1, handle);
		mob_rx_bms_precharge.status				= event;
		
		bms_can_msg_t bms_can_msg;
		bms_can_msg.data.u64 = mob_rx_bms_precharge.can_msg->data.u64;
		bms_can_msg.id = mob_rx_bms_precharge.can_msg->id;
		xQueueSendToBackFromISR(queue_bms_rx, &bms_can_msg, NULL);
		/* Empty message field */
		mob_rx_bms_precharge.can_msg->data.u64 = 0x0LL;
		/* Prepare message reception */
		can_rx(CAN_BUS_1,
		mob_rx_bms_precharge.handle,
		mob_rx_bms_precharge.req_type,
		mob_rx_bms_precharge.can_msg);
		
	} else if (handle == mob_rx_bms_battvolt.handle) {
		mob_rx_bms_battvolt.can_msg->data.u64	= can_get_mob_data(CAN_BUS_1, handle).u64;
		mob_rx_bms_battvolt.can_msg->id			= can_get_mob_id(CAN_BUS_1, handle);
		mob_rx_bms_battvolt.dlc					= can_get_mob_dlc(CAN_BUS_1, handle);
		mob_rx_bms_battvolt.status				= event;
		
		bms_can_msg_t bms_can_msg;
		bms_can_msg.data.u64 = mob_rx_bms_battvolt.can_msg->data.u64;
		bms_can_msg.id = mob_rx_bms_battvolt.can_msg->id;
		
		xQueueSendToBackFromISR(queue_bms_rx, &bms_can_msg, NULL);
		/* Empty message field */
		mob_rx_bms_battvolt.can_msg->data.u64 = 0x0LL;
		/* Prepare message reception */
		can_rx(CAN_BUS_1,
		mob_rx_bms_battvolt.handle,
		mob_rx_bms_battvolt.req_type,
		mob_rx_bms_battvolt.can_msg);	
	} else if (handle == mob_brk.handle) {
		mob_brk.can_msg->data.u64	= can_get_mob_data(CAN_BUS_1, handle).u64;
		mob_brk.can_msg->id			= can_get_mob_id(CAN_BUS_1, handle);
		mob_brk.dlc					= can_get_mob_dlc(CAN_BUS_1, handle);
		mob_brk.status				= event;
		
		if (mob_brk.can_msg->id == (CANR_FCN_DATA_ID | CANR_GRP_SENS_BRK_ID | CANR_MODULE_ID0_ID)) {
			xQueueSendToBackFromISR( queue_brake_front, &mob_brk.can_msg->data.u16[0], NULL );
		} else {
			xQueueSendToBackFromISR( queue_brake_rear, &mob_brk.can_msg->data.u16[0], NULL );
		}
		/* Empty message field */
		mob_brk.can_msg->data.u64 = 0x0LL;
		/* Prepare message reception */
		can_rx(CAN_BUS_1,
		mob_brk.handle,
		mob_brk.req_type,
		mob_brk.can_msg);
	}
}
Esempio n. 3
0
File: ecu_can.c Progetto: aakre/ecu
void can_out_callback_channel0(U8 handle, U8 event){
	if (handle == mob_rx_dash_pri.handle) {
		mob_rx_dash_pri.can_msg->data.u64	= can_get_mob_data(CAN_BUS_0, handle).u64;
		mob_rx_dash_pri.can_msg->id			= can_get_mob_id(CAN_BUS_0, handle);
		mob_rx_dash_pri.dlc					= can_get_mob_dlc(CAN_BUS_0, handle);
		mob_rx_dash_pri.status				= event;
		
		dash_can_msg_t dash_can_msg;
		
		dash_can_msg.data.u64 = mob_rx_dash_pri.can_msg->data.u64;
		dash_can_msg.id = mob_rx_dash_pri.can_msg->id;
		xQueueSendToBackFromISR(queue_dash_msg, &dash_can_msg, NULL);
		/* Empty message field */
		mob_rx_dash_pri.can_msg->data.u64 = 0x0LL;
		
		/* Prepare message reception */
		can_rx(CAN_BUS_0,
		mob_rx_dash_pri.handle,
		mob_rx_dash_pri.req_type,
		mob_rx_dash_pri.can_msg);
		
	} else if (handle == mob_rx_dash_data.handle) {
		mob_rx_dash_data.can_msg->data.u64	= can_get_mob_data(CAN_BUS_0, handle).u64;
		mob_rx_dash_data.can_msg->id			= can_get_mob_id(CAN_BUS_0, handle);
		mob_rx_dash_data.dlc					= can_get_mob_dlc(CAN_BUS_0, handle);
		mob_rx_dash_data.status				= event;
		
		dash_can_msg_t dash_can_msg;
		
		dash_can_msg.data.u64 = mob_rx_dash_data.can_msg->data.u64;
		dash_can_msg.id = mob_rx_dash_data.can_msg->id;
		xQueueSendToBackFromISR(queue_dash_msg, &dash_can_msg, NULL);
		/* Empty message field */
		mob_rx_dash_data.can_msg->data.u64 = 0x0LL;
		
		/* Prepare message reception */
		can_rx(CAN_BUS_0, 
		mob_rx_dash_data.handle,
		mob_rx_dash_data.req_type,
		mob_rx_dash_data.can_msg);
		
	} else if (handle == mob_rx_trq_sens0.handle) {
		mob_rx_trq_sens0.can_msg->data.u64	= can_get_mob_data(CAN_BUS_0, handle).u64;
		mob_rx_trq_sens0.can_msg->id		= can_get_mob_id(CAN_BUS_0, handle);
		mob_rx_trq_sens0.dlc				= can_get_mob_dlc(CAN_BUS_0, handle);
		mob_rx_trq_sens0.status				= event;
	
		xQueueOverwriteFromISR(queue_trq_sens0, &mob_rx_trq_sens0.can_msg->data.s16[0], NULL);
		xQueueOverwriteFromISR(queue_trq_sens0_err, &mob_rx_trq_sens0.can_msg->data.u8[2], NULL);
		asm("nop");
		/* Empty message field */
		mob_rx_trq_sens0.can_msg->data.u64 = 0x0LL;
		
		/* Prepare message reception */
		can_rx(CAN_BUS_0, 
		mob_rx_trq_sens0.handle,
		mob_rx_trq_sens0.req_type,
		mob_rx_trq_sens0.can_msg);
		
	}	else if (handle == mob_rx_bspd.handle) {
		mob_rx_bspd.can_msg->data.u64	= can_get_mob_data(CAN_BUS_0, handle).u64;
		mob_rx_bspd.can_msg->id			= can_get_mob_id(CAN_BUS_0, handle);
		mob_rx_bspd.dlc					= can_get_mob_dlc(CAN_BUS_0, handle);
		mob_rx_bspd.status				= event;
		
		xQueueOverwriteFromISR( queue_bspd, &mob_rx_bspd.can_msg->data.u8[0], NULL );
		/* Empty message field */
		mob_rx_bspd.can_msg->data.u64 = 0x0LL;
		/* Prepare message reception */
		can_rx(CAN_BUS_0,
		mob_rx_bspd.handle,
		mob_rx_bspd.req_type,
		mob_rx_bspd.can_msg);
	} 
}