您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ xSemaphoreTake函数代码示例

51自学网 2021-06-03 10:14:30
  C++
这篇教程C++ xSemaphoreTake函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中xSemaphoreTake函数的典型用法代码示例。如果您正苦于以下问题:C++ xSemaphoreTake函数的具体用法?C++ xSemaphoreTake怎么用?C++ xSemaphoreTake使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了xSemaphoreTake函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: GUI_X_WaitEvent

void GUI_X_WaitEvent (void) {  while( xSemaphoreTake(xSemaTxDone, portMAX_DELAY ) != pdTRUE );}
开发者ID:TAKETODAY,项目名称:STemWin,代码行数:4,


示例2: vHTTPTask

/*-----------------------------------------------------------*/void vHTTPTask( void * pvParameters ){short i, sLen;unsigned char ucState;	( void ) pvParameters;    /* Create the semaphore used to communicate between this task and the    WIZnet ISR. */    vSemaphoreCreateBinary( xTCPSemaphore );	/* Make sure everything is setup before we start. */	prvNetifInit();	prvHTTPInit();	for( ;; )	{		/* Wait until the ISR tells us there is something to do. */    	xSemaphoreTake( xTCPSemaphore, portMAX_DELAY );		/* Check each socket. */		for( i = 0; i < httpSOCKET_NUM; i++ )		{			ucState = select( i, SEL_CONTROL );			switch (ucState)			{				case SOCK_ESTABLISHED :  /* new connection established. */					if( ( sLen = select( i, SEL_RECV ) ) > 0 )					{						if( sLen > httpSOCKET_BUFFER_SIZE )						{							sLen = httpSOCKET_BUFFER_SIZE;						}						disable();						sLen = recv( i, ucSocketBuffer, sLen );						if( ucConnection[ i ] == 1 )						{							/* This is our first time processing a HTTP							 request on this connection. */							prvTransmitHTTP( i );							ucConnection[i] = 0;						}						enable();					}					break;				case SOCK_CLOSE_WAIT :					close(i);					break;				case SOCK_CLOSED :					ucConnection[i] = 1;					socket( i, SOCK_STREAM, 80, 0x00 );					NBlisten( i ); /* reinitialize socket. */					break;			}		}	}}
开发者ID:jbalcerz,项目名称:Stm32Discovery_FreeRTOS,代码行数:67,


示例3: prvCDCCommandConsoleTask

static void prvCDCCommandConsoleTask( void *pvParameters ){char cRxedChar;uint8_t ucInputIndex = 0;char *pcOutputString;static char cInputString[ cmdMAX_INPUT_SIZE ], cLastInputString[ cmdMAX_INPUT_SIZE ];portBASE_TYPE xReturned;	( void ) pvParameters;	/* Obtain the address of the output buffer.  Note there is no mutual	exclusion on this buffer as it is assumed only one command console	interface will be used at any one time. */	pcOutputString = FreeRTOS_CLIGetOutputBuffer();	/* Initialise the virtual com port (CDC) interface. */	prvSetupUSBDrivers();	/* Send the welcome message.  This probably won't be seen as the console	will not have been connected yet. */	USB_WriteEP( CDC_DEP_IN, ( uint8_t * ) pcWelcomeMessage, strlen( pcWelcomeMessage ) );	for( ;; )	{		/* No characters received yet for the current input string. */		cRxedChar = 0;		/* Only interested in reading one character at a time. */		cRxedChar = cGetCDCChar();		if( xSemaphoreTake( xCDCMutex, cmdMAX_MUTEX_WAIT ) == pdPASS )		{			/* Echo the character back. */			USB_WriteEP( CDC_DEP_IN, ( uint8_t * ) &cRxedChar, sizeof( uint8_t ) );			/* Was it the end of the line? */			if( cRxedChar == '/n' || cRxedChar == '/r' )			{				/* Just to space the output from the input. */				USB_WriteEP( CDC_DEP_IN, ( uint8_t * ) pcNewLine, strlen( pcNewLine ) );				/* See if the command is empty, indicating that the last command is				to be executed again. */				if( ucInputIndex == 0 )				{					/* Copy the last command back into the input string. */					strcpy( cInputString, cLastInputString );				}				/* Pass the received command to the command interpreter.  The				command interpreter is called repeatedly until it returns pdFALSE				(indicating there is no more output) as it might generate more than				one string. */				do				{					/* Get the next output string from the command interpreter. */					xReturned = FreeRTOS_CLIProcessCommand( cInputString, pcOutputString, configCOMMAND_INT_MAX_OUTPUT_SIZE );					/* Write the generated string to the CDC. */					USB_WriteEP( CDC_DEP_IN, ( uint8_t * ) pcOutputString, strlen( pcOutputString ) );					vTaskDelay( 1 );				} while( xReturned != pdFALSE );				/* All the strings generated by the input command have been sent.				Clear the input	string ready to receive the next command.  Remember				the command that was just processed first in case it is to be				processed again. */				strcpy( cLastInputString, cInputString );				ucInputIndex = 0;				memset( cInputString, 0x00, cmdMAX_INPUT_SIZE );				USB_WriteEP( CDC_DEP_IN, ( uint8_t * ) pcEndOfOutputMessage, strlen( pcEndOfOutputMessage ) );			}			else			{				if( cRxedChar == '/r' )				{					/* Ignore the character. */				}				else if( cRxedChar == '/b' )				{					/* Backspace was pressed.  Erase the last character in the					string - if any. */					if( ucInputIndex > 0 )					{						ucInputIndex--;						cInputString[ ucInputIndex ] = '/0';					}				}				else				{					/* A character was entered.  Add it to the string					entered so far.  When a /n is entered the complete					string will be passed to the command interpreter. */					if( ( cRxedChar >= ' ' ) && ( cRxedChar <= '~' ) )					{						if( ucInputIndex < cmdMAX_INPUT_SIZE )						{							cInputString[ ucInputIndex ] = cRxedChar;//.........这里部分代码省略.........
开发者ID:wind5027,项目名称:FreeRTOS_Learn,代码行数:101,


示例4: vuIP_Task

//.........这里部分代码省略.........	/* Create the semaphore used by the ISR to wake this task. */	vSemaphoreCreateBinary( xEMACSemaphore );		/* Initialise the uIP stack. */	timer_set( &periodic_timer, configTICK_RATE_HZ / 2 );	timer_set( &arp_timer, configTICK_RATE_HZ * 10 );	uip_init();	uip_ipaddr( xIPAddr, uipIP_ADDR0, uipIP_ADDR1, uipIP_ADDR2, uipIP_ADDR3 );	uip_sethostaddr( xIPAddr );	httpd_init();	/* Initialise the MAC. */	while( Init_EMAC() != pdPASS )    {        vTaskDelay( uipINIT_WAIT );    }	portENTER_CRITICAL();	{        IntEnable = INT_RX_DONE;        VICIntEnable |= 0x00200000;        VICVectAddr21 = ( portLONG ) vEMAC_ISR_Wrapper;		prvSetMACAddress();	}	portEXIT_CRITICAL();		for( ;; )	{		/* Is there received data ready to be processed? */		uip_len = uiGetEMACRxData( uip_buf );				if( uip_len > 0 )		{			/* Standard uIP loop taken from the uIP manual. */			if( xHeader->type == htons( UIP_ETHTYPE_IP ) )			{				uip_arp_ipin();				uip_input();				/* If the above function invocation resulted in data that 				should be sent out on the network, the global variable 				uip_len is set to a value > 0. */				if( uip_len > 0 )				{					uip_arp_out();					prvENET_Send();				}			}			else if( xHeader->type == htons( UIP_ETHTYPE_ARP ) )			{				uip_arp_arpin();				/* If the above function invocation resulted in data that 				should be sent out on the network, the global variable 				uip_len is set to a value > 0. */				if( uip_len > 0 )				{					prvENET_Send();				}			}		}		else		{			if( timer_expired( &periodic_timer ) )			{				timer_reset( &periodic_timer );				for( i = 0; i < UIP_CONNS; i++ )				{					uip_periodic( i );						/* If the above function invocation resulted in data that 					should be sent out on the network, the global variable 					uip_len is set to a value > 0. */					if( uip_len > 0 )					{						uip_arp_out();						prvENET_Send();					}				}						/* Call the ARP timer function every 10 seconds. */				if( timer_expired( &arp_timer ) )				{					timer_reset( &arp_timer );					uip_arp_timer();				}			}			else			{							/* We did not receive a packet, and there was no periodic				processing to perform.  Block for a fixed period.  If a packet				is received during this period we will be woken by the ISR				giving us the Semaphore. */				xSemaphoreTake( xEMACSemaphore, configTICK_RATE_HZ / 2 );						}		}	}}
开发者ID:svn2github,项目名称:freertos,代码行数:101,


示例5: vuIP_Task

//.........这里部分代码省略.........		/* Initialise the uIP stack. */	timer_set( &periodic_timer, configTICK_RATE_HZ / 2 );	timer_set( &arp_timer, configTICK_RATE_HZ * 10 );	uip_init();	uip_ipaddr( xIPAddr, uipIP_ADDR0, uipIP_ADDR1, uipIP_ADDR2, uipIP_ADDR3 );	uip_sethostaddr( xIPAddr );	uip_ipaddr( xIPAddr, uipNET_MASK0, uipNET_MASK1, uipNET_MASK2, uipNET_MASK3 );	uip_setnetmask( xIPAddr );	uip_ipaddr( xIPAddr, uipGATEWAY_ADDR0, uipGATEWAY_ADDR1, uipGATEWAY_ADDR2, uipGATEWAY_ADDR3 );	uip_setdraddr( xIPAddr );		httpd_init();	/* Initialise the MAC. */	ENET_InitClocksGPIO();	ENET_Init();	portENTER_CRITICAL();	{		ENET_Start();		prvSetMACAddress();		VIC_Config( ENET_ITLine, VIC_IRQ, 1 );		VIC_ITCmd( ENET_ITLine, ENABLE );			ENET_DMA->ISR = uipDMI_RX_CURRENT_DONE; 		ENET_DMA->IER = uipDMI_RX_CURRENT_DONE;	}	portEXIT_CRITICAL();		while(1)	{		/* Is there received data ready to be processed? */		uip_len = ENET_HandleRxPkt( uip_buf );				if( uip_len > 0 )		{			/* Standard uIP loop taken from the uIP manual. */			if( xHeader->type == htons( UIP_ETHTYPE_IP ) )			{				uip_arp_ipin();				uip_input();				/* If the above function invocation resulted in data that				should be sent out on the network, the global variable				uip_len is set to a value > 0. */				if( uip_len > 0 )				{					uip_arp_out();					prvENET_Send();				}			}			else if( xHeader->type == htons( UIP_ETHTYPE_ARP ) )			{				uip_arp_arpin();				/* If the above function invocation resulted in data that				should be sent out on the network, the global variable				uip_len is set to a value > 0. */				if( uip_len > 0 )				{					prvENET_Send();				}			}		}		else		{			if( timer_expired( &periodic_timer ) )			{				timer_reset( &periodic_timer );				for( i = 0; i < UIP_CONNS; i++ )				{					uip_periodic( i );						/* If the above function invocation resulted in data that					should be sent out on the network, the global variable					uip_len is set to a value > 0. */					if( uip_len > 0 )					{						uip_arp_out();						prvENET_Send();					}				}						/* Call the ARP timer function every 10 seconds. */				if( timer_expired( &arp_timer ) )				{					timer_reset( &arp_timer );					uip_arp_timer();				}			}			else			{							/* We did not receive a packet, and there was no periodic				processing to perform.  Block for a fixed period.  If a packet				is received during this period we will be woken by the ISR				giving us the Semaphore. */				xSemaphoreTake( xSemaphore, configTICK_RATE_HZ / 2 );						}		}	}}
开发者ID:Dzenik,项目名称:FreeRTOS_TEST,代码行数:101,


示例6: vGpsTask

void vGpsTask(void *pvParameters){    delay_ms(100);    GpsInitialization();    //UART_Send(LPC_UART0, "$PMTK314,0,0,0,5,0,0,0,0,1,1,1,1,1,1,1,1,1*2C/r/n", 47, BLOCKING );    //UART_Send(LPC_UART0,(uint8_t *) "$PMTK314,0,0,0,5,5,5,0,0,1,1,1,1,1,1,1,1,1*2C/r/n", 47, BLOCKING );    UART_Send(LPC_UART0,(uint8_t *) "$PMTK314,1,1,1,1,1,5,0,0,0,0,0,0,0,0,0,0,0,0,0*2C/r/n",52, BLOCKING);    //UART_Send(LPC_UART0,(uint8_t *) "$PMTK000*32/r/n",13, BLOCKING);    UART_Send(LPC_UART0,(uint8_t *) "$PMTK101*32/r/n",13, BLOCKING);    while(UART_CheckBusy(LPC_UART0));    NVIC_EnableIRQ(UART0_IRQn);    while(1)    {        gpsSetProcessingBuffer(-1);        if(xSemaphoreTake(xSemaphoreGPS,portMAX_DELAY) == pdTRUE)        {            gpsSetProcessingBuffer(0);            gps_tokenize_input();            char *token_msgid = gps_getToken(0);            if( strcmp(token_msgid, "$GPGGA") == 0)            {                //$GPGGA,081604.000,5204.8543,N,02101.6233,E,1,8,1.06,96.7,M,39.3,M,,*66                //$GPGGA,082316.000,5204.8526,N,02101.6227,E,1,8,1.04,93.9,M,39.3,M,,*6C                //$GPGGA,083352.000,5205.1129,N,02102.3054,E,2,9,0.99,107.4,M,39.3,M,0000,0000*58                asm("nop");                //			if(checkFixPresence()!=0)                //			{                //				parseGgaMessage();                //			}            } else if (strcmp(token_msgid, "$GPRMC")==0) {                //$GPRMC,081253.000,A,5204.8527,N,02101.6226,E,0.04,0.00,210214,,,A*6A                //$GPRMC,082223.000,A,5204.8527,N,02101.6234,E,0.33,175.46,210214,,,A*68                char *test = gps_getToken(2);                if(test[0] == 'V') {                    asm("nop");                } else if (test[0] == 'A') {                    asm("nop");                }            }	else if (strncmp(token_msgid, "GPGSA", 5)==0) {                // GSA - SATELITES AVAILVLE                //$GPGSA,A,3,20,31,17,11,01,,,,,,,,1.80,1.54,0.93*06                //$GPGSA,A,3,20,31D*0C/r/n                asm("nop");            } else if (strncmp(token_msgid, "GPVTG", 5) == 0) {                //$GPVTG,71.41,T,,M,0.06,N,0.10,K,A*09/r/n                // 10 km/h                //$GPVTG,70.02,T,,M,8.04,N,14.90,K,A*38/r/n                // 25 km/h                //$GPVTG,248.73,T,,M,12.53,N,23.23,K,D*37                asm("nop");            } else if (strncmp(token_msgid, "GPGSV", 5) == 0) {                // GSV - Satelistes in view                // $GPGSV,4,1,13,20,76,279,46,01,62,169,45,32,61,082,44,23,40,210,48*7F                // $GPGSV,2,1,08,20,71,276,26,01,67,172,40,11,37,173,31,31,32,091,*79                char *test = getFieldPtr(3);                if (strncmp(test, "00", 2)!= 0) {                    asm("nop");                }            } else if (strncmp(token_msgid, "PMTK011",7)==0) {                asm("nop");            } else if (strncmp(token_msgid, "PMTK010", 7)==0) {                asm("nop");            } else {                asm("nop");            }        }        //	vTaskDelay(1000/portTICK_RATE_MS);    }}
开发者ID:qermit,项目名称:aprs-firmware,代码行数:81,


示例7: print_table_information

void print_table_information(void){	neighbor_info_t *b;#ifdef HAVE_ROUTING	uint8_t addres_length=0;	route_info_t *ptr;#endif	if( xSemaphoreTake( table_lock, ( portTickType ) 10 ) == pdTRUE )	{		uint8_t i, j;		if(neighbor_table.count)		{			debug("Neighbor Info count:");			debug_hex(neighbor_table.count);			debug("/r/n");			debug("Child count:");			debug_hex(neighbor_table.child_count);			debug("/r/n");			for(i=0; i < MAX_NEIGHBOR_COUNT; i++)			{				b=&(neighbor_table.neighbor_info[i]);				if(b->type==ADDR_NONE)					b=0;				if(b)				{					if(b->type== ADDR_802_15_4_PAN_LONG)					{						debug("Long:  ");						for(j=0; j < 2 ; j++)						{							if (j) debug_put(':');							debug_hex( b->address[9-j]);						}						debug("  ");						for(j=0; j < 8 ; j++)						{							if (j) debug_put(':');							debug_hex( b->address[7-j]);						}											}					if(b->type == ADDR_802_15_4_PAN_SHORT)					{						debug("Short:  ");						for(j=0; j < 2 ; j++)						{							if (j) debug_put(':');							debug_hex( b->address[3-j]);						}						debug("  ");						for(j=0; j < 2 ; j++)						{							if (j) debug_put(':');							debug_hex( b->address[1-j]);						}					}					debug("/r/nrssi: ");					debug_int(b->last_rssi);					debug("/r/nTTL: ");					debug_hex(b->ttl);					debug("/r/n");					pause_us(200);				}			}		}		else		{			debug("No Neighbor info/r/n");		}#ifdef HAVE_ROUTING		if(routing_table.count)		{						debug("/r/nroute Info count:");			debug_hex(routing_table.count);			debug("/r/n");						for(i=0; i < MAX_ROUTE_INFO_COUNT; i++)			{				ptr = &(routing_table.route_info[i]);				if(ptr->dest_addr_type==ADDR_NONE)					ptr=0;				if(ptr)				{					debug("Dest:  ");					if(ptr->dest_addr_type==ADDR_802_15_4_PAN_LONG)						addres_length=8;					else						addres_length=2;					for(j=0; j < addres_length ; j++)					{						if (j) debug_put(':');						debug_hex(ptr->destination[(addres_length-1)-j]);					}					debug("/r/nNext hop:  ");					if(ptr->next_hop_addr_type==ADDR_802_15_4_PAN_LONG)						addres_length=10;					else//.........这里部分代码省略.........
开发者ID:Paolo-Maffei,项目名称:nxstack,代码行数:101,


示例8: wc_LockMutex

 int wc_LockMutex(wolfSSL_Mutex* m) {     /* Assume an infinite block, or should there be zero block? */     xSemaphoreTake( *m, portMAX_DELAY );     return 0; }
开发者ID:NickolasLapp,项目名称:wolfssl,代码行数:6,


示例9: check_child_role

child_status_type_t check_child_role(addrtype_t type, address_t address){	neighbor_info_t *b;	uint8_t i,j, length;	child_status_type_t return_value;	return_value = NOT_CHILD;		if( xSemaphoreTake( table_lock, ( portTickType ) 5 ) == pdTRUE )	{		switch (type)		{			case ADDR_802_15_4_PAN_SHORT:						/* Check if broadcast address */				length=4;				break;			case ADDR_802_15_4_SHORT:						/* Check if broadcast address */				length=2;				type=ADDR_802_15_4_PAN_SHORT;				break;			case ADDR_802_15_4_PAN_LONG:				length=8;				break;			default:				xSemaphoreGive( table_lock ); /*free lock*/				return return_value;				break;		}		if(neighbor_table.count > 0)		{			for(i=0; i < MAX_NEIGHBOR_COUNT ; i++)			{				b = &(neighbor_table.neighbor_info[i]);				if(b->type == ADDR_NONE)					b=0;				if(b && (b->type == type) )				{					if(memcmp(b->address, address,length) == 0)					{						if(b->child_dev == 0)						{							neighbor_table.child_count++;							b->child_dev=1;						}						return_value = CHILD;						i=MAX_NEIGHBOR_COUNT;					}				}			}		}		if((return_value==NOT_CHILD) && (neighbor_table.child_count == NWK_MAX_CHILD) )		{			return_value = DISCARD_ASSOC;		}		if((return_value==NOT_CHILD) && (neighbor_table.child_count < NWK_MAX_CHILD))		{			j =neighbor_table.child_count;			j++;				if(j == NWK_MAX_CHILD)					return_value=NO_CAPASITY_AFTER_NEW_CHILD;		}		xSemaphoreGive( table_lock ); /*free lock*/	}return return_value;	}
开发者ID:Paolo-Maffei,项目名称:nxstack,代码行数:69,


示例10: update_routing_table

portCHAR update_routing_table(addrtype_t final_type, address_t final_destination,addrtype_t next_hop_type, address_t next_hop, uint8_t hop_count, int8_t last_rssi , uint8_t only_check){	uint8_t i=0,j, tmp_8=0, final_length, next_hop_length, compare=0, update=0;	route_info_t *ptr;	if( xSemaphoreTake( table_lock, ( portTickType ) 5 ) == pdTRUE )	{		if(final_type==ADDR_802_15_4_PAN_LONG)			final_length=8;		else			final_length=2;		if(next_hop_type==ADDR_802_15_4_PAN_LONG)			next_hop_length=8;		else			next_hop_length=4;		tmp_8 = 0;		/* Predict older route information and shuold use route */		if(only_check != REMOVE_ROUTE)		{			switch	(check_time_stamp(final_type, final_destination))			{				case MESH_TTL_VALID:					tmp_8=1;		/* cancel update process */					break;				case MESH_LOW_RSSI:				case MESH_NOT_NEIGHBOR:					only_check=0;					break;				default:					break;			}		}		if(routing_table.count > 0 && tmp_8==0)		{			for(i=0; i < MAX_ROUTE_INFO_COUNT ; i++)			{				ptr = &(routing_table.route_info[i]);				if(ptr->dest_addr_type == ADDR_NONE)					ptr=0;				/* Check originator address from routing table */				if(ptr && (final_type == ptr->dest_addr_type))				{					if(memcmp(ptr->destination, final_destination,final_length) ==0)					{						if(only_check == REMOVE_ROUTE)						{							ptr->dest_addr_type=ADDR_NONE;							routing_table.count--;						}						else						{							if(next_hop_type==ptr->next_hop_addr_type)							{								/* compare next hop address */								if(memcmp(next_hop, ptr->next_hop, next_hop_length) !=0)									compare=1;								else									update=2;							}							else								compare=1;								if(compare)							{								if(hop_count < ptr->hop_count && last_rssi > -85)								{									update=1;									}								else								{									if(hop_count==ptr->hop_count)									{										if(last_rssi > ptr->last_rssi || (ptr->ttl  < (ROUTING_TTL - 2)  ))											update=1;									}								}							}							if(update)							{								if(update != 2)								{									ptr->next_hop_addr_type = next_hop_type;									next_hop_length+=2;									/* added new next hop info */									for(j=0; j < next_hop_length ; j++)									{										ptr->next_hop[j] = next_hop[j];									}								}								ptr->last_rssi=last_rssi;								ptr->hop_count = hop_count;								ptr->ttl=ROUTING_TTL;							}						}						tmp_8=1;						i=MAX_ROUTE_INFO_COUNT;					}				}				}//.........这里部分代码省略.........
开发者ID:Paolo-Maffei,项目名称:nxstack,代码行数:101,


示例11: update_neighbour_table

/** * Update neighbor tables if necessary. * * Mac-layer use this function every time when received packet which LQI > 0. * * /param type indicates type of neighbor address mode * /param address neighbor address * /param lqi Last received LQI value * /param last_sqn last MAC sqn from this address * * /return 1 when last_sqn is different than current * /return 0 when sqn is same, now MAC discard packet */uint8_t update_neighbour_table(addrtype_t type, address_t address, int8_t last_rssi, uint8_t last_sqn, uint8_t remove){	neighbor_info_t *b;	uint8_t i,j, sqn_check=0, length=0;	dest_delivery_t delivery_mode;	delivery_mode = NOT_NEIGHBOR;		if( xSemaphoreTake( table_lock, ( portTickType ) 5 ) == pdTRUE )	{		if(type==ADDR_802_15_4_PAN_LONG)		{			length=8;							}		if(type == ADDR_802_15_4_PAN_SHORT)			length=4;		delivery_mode = NOT_NEIGHBOR;		if(neighbor_table.count > 0 && remove != ADD_CHILD)		{			for(i=0; i < MAX_NEIGHBOR_COUNT ; i++)			{				b = &(neighbor_table.neighbor_info[i]);				if(b->type == ADDR_NONE)					b=0;				if(b && (type == b->type))				{					if(memcmp(b->address, address,length) == 0)						delivery_mode = NEIGHBOR;										/* Update lqi and compare sqn to old one */					if( delivery_mode == NEIGHBOR )					{						if(type != ADDR_802_15_4_PAN_SHORT)						{							for(j=0; j<2; j++)							{								b->address[length+j] = address[length+j];							}						}						if(remove == REMOVE_NEIGHBOUR)						{							if(b->child_dev)								neighbor_table.child_count--;							b->type=ADDR_NONE;							i=neighbor_table.count;							neighbor_table.count--;						}						else						{							/* Duplicated packet check */							if(b->last_sqn != last_sqn)							{								b->last_sqn = last_sqn;								sqn_check=1;							}							b->last_rssi = last_rssi;							b->ttl=TTL;						}						i=MAX_NEIGHBOR_COUNT;					}				}			}		}		/* Add new neighbor if addresstype is source */		if((delivery_mode == NOT_NEIGHBOR && remove != REMOVE_NEIGHBOUR) && neighbor_table.count < MAX_NEIGHBOR_COUNT)		{			for(i=0; i<MAX_NEIGHBOR_COUNT; i++)			{				b = &(neighbor_table.neighbor_info[i]);				if(b->type == ADDR_NONE)				{					i=MAX_NEIGHBOR_COUNT;				}			}				if(type==ADDR_802_15_4_PAN_LONG)						length+=2;				for(j=0; j < length ; j++)				{					b->address[j] = address[j];				}								/* add lqi value to neighbor */				if(remove  == ADD_CHILD)//.........这里部分代码省略.........
开发者ID:Paolo-Maffei,项目名称:nxstack,代码行数:101,


示例12: xSemaphoreTake

void AnalyzerControl::AnalysisRead(){	xSemaphoreTake(_semaphore, portMAX_DELAY);	WakeAnalysisRequest();}
开发者ID:rpc-fw,项目名称:analyzer,代码行数:5,


示例13: SetWidgetList

void SetWidgetList(tMessage *pMsg){  static Widget_t *pCurrWidget = NULL; // point to Widget in current Widget[]  static Widget_t *pNextWidget = NULL; // point to Widget in new Widget[]  static unsigned char ChangedClockWidget = INVALID_ID;  xSemaphoreTake(SramMutex, portMAX_DELAY);  WidgetList_t *pMsgWgtLst = (WidgetList_t *)pMsg->pBuffer;  unsigned char WidgetNum = pMsg->Length / WIDGET_HEADER_LEN;  unsigned char i = 0;  PrintF(">SetWLst I:%d %s %d %s %d", WGTLST_INDEX(pMsg->Options), "T:", WGTLST_TOTAL(pMsg->Options), "Num:", WidgetNum);  for(; i<WidgetNum; ++i) {PrintH(pMsgWgtLst[i].Id); PrintH(pMsgWgtLst[i].Layout);} PrintR();  if (pNextWidget == NULL) // first time call, only add widgets  {    pCurrWidget = pCurrWidgetList;    pNextWidget = &Widget[0];  }  else  {    if (WGTLST_INDEX(pMsg->Options) == 0 &&      (pCurrWidget != pCurrWidgetList || (pNextWidget != &Widget[0] && pNextWidget != &Widget[MAX_WIDGET_NUM])))    { // last SetWLst failed in the middle.Clean up whole list      PrintS("# Last SetWgtLst broken!");      pCurrWidget = pCurrWidgetList;      pNextWidget = &Widget[0] + (&Widget[MAX_WIDGET_NUM] - pCurrWidgetList);    }  }  while (WidgetNum) // number of list items  {      /* old clock widgets */    if (!IS_CLOCK_WIDGET(pMsgWgtLst->Layout) && pMsgWgtLst->Id <= CLOCK_WIDGET_ID_RANGE) TestFaceId(pMsgWgtLst);    unsigned char Change = GetWidgetChange(pCurrWidget->Id, pCurrWidget->Layout, pMsgWgtLst->Id, pMsgWgtLst->Layout);        switch (Change)    {    case WGT_CHG_CLK_FACE:      PrintS("Chg ClkFce");      if (ON_CURRENT_PAGE(pMsgWgtLst->Layout)) ChangedClockWidget = pMsgWgtLst->Id;          case WGT_CHG_SETTING:     //cpy layout to curr; cpy curr to next; msg, curr, next ++      PrintF("=%02X", pCurrWidget->Id);      pCurrWidget->Id = pMsgWgtLst->Id;      pCurrWidget->Layout = pMsgWgtLst->Layout;      *pNextWidget++ = *pCurrWidget++;      pMsgWgtLst ++;      WidgetNum --;      break;    case WGT_CHG_CLK_ADD:      PrintS("+Clk");      if (ON_CURRENT_PAGE(pMsgWgtLst->Layout)) ChangedClockWidget = pMsgWgtLst->Id;    case WGT_CHG_ADD: //pCurrWidget->Id > pMsgWgtLst->Id)     // add new widget: cpy msg to next; msg and next ++; curr stays      PrintF("+%02X", pMsgWgtLst->Id);      pNextWidget->Id = pMsgWgtLst->Id;      pNextWidget->Layout = pMsgWgtLst->Layout;      AssignWidgetBuffer(pNextWidget);      pNextWidget ++;      pMsgWgtLst ++;      WidgetNum --;      break;          case WGT_CHG_REMOVE:    // remove widget: curr ++      PrintF("-%02X", pCurrWidget->Id);      FreeWidgetBuffer(pCurrWidget);      pCurrWidget ++;      break;          default: break;    }  }  PrintR();  // if part index + 1 == parts, SetWidgetList complete  if (WGTLST_TOTAL(pMsg->Options) == WGTLST_INDEX(pMsg->Options) + 1)  {//    PrintS("C:");//    for (i=0; pCurrWidgetList[i].Id != INVALID_ID && i < MAX_WIDGET_NUM; ++i) PrintH(pCurrWidgetList[i].Id);//    PrintR();    while (pCurrWidget->Id != INVALID_ID && pCurrWidget < &pCurrWidgetList[MAX_WIDGET_NUM])    {      FreeWidgetBuffer(pCurrWidget);      pCurrWidget->Id = INVALID_ID;      pCurrWidget ++;    }    for (i = 0; i < MAX_WIDGET_NUM; ++i)    {      if (pCurrWidgetList[i].Id != INVALID_ID)//.........这里部分代码省略.........
开发者ID:grueni75,项目名称:MetaWatch-Gen2,代码行数:101,


示例14: logRunBlock

/* This function is usually called by the worker subsystem */void logRunBlock(void * arg){  struct log_block *blk = arg;  struct log_ops *ops = blk->ops;  static CRTPPacket pk;  unsigned int timestamp;  xSemaphoreTake(logLock, portMAX_DELAY);  timestamp = ((long long)xTaskGetTickCount())/portTICK_RATE_MS;  pk.header = CRTP_HEADER(CRTP_PORT_LOG, LOG_CH);  pk.size = 4;  pk.data[0] = blk->id;  pk.data[1] = timestamp&0x0ff;  pk.data[2] = (timestamp>>8)&0x0ff;  pk.data[3] = (timestamp>>16)&0x0ff;  while (ops)  {    float variable;    int valuei = 0;    float valuef = 0;    // FPU instructions must run on aligned data. Make sure it is.    variable = *(float *)ops->variable;    switch(ops->storageType)    {      case LOG_UINT8:        valuei = *(uint8_t *)&variable;        break;      case LOG_INT8:        valuei = *(int8_t *)&variable;        break;      case LOG_UINT16:        valuei = *(uint16_t *)&variable;        break;      case LOG_INT16:        valuei = *(int16_t *)&variable;        break;      case LOG_UINT32:        valuei = *(uint32_t *)&variable;        break;      case LOG_INT32:        valuei = *(int32_t *)&variable;        break;      case LOG_FLOAT:        valuei = *(float *)&variable;        break;    }    if (ops->logType == LOG_FLOAT || ops->logType == LOG_FP16)    {      if (ops->storageType == LOG_FLOAT)        valuef = *(float *)&variable;      else        valuef = valuei;      // Try to append the next item to the packet.  If we run out of space,      // drop this and subsequent items.      if (ops->logType == LOG_FLOAT)      {        if (!appendToPacket(&pk, &valuef, 4)) break;      }      else      {        valuei = single2half(valuef);        if (!appendToPacket(&pk, &valuei, 2)) break;      }    }    else  //logType is an integer    {      if (!appendToPacket(&pk, &valuei, typeLength[ops->logType])) break;    }    ops = ops->next;  }  xSemaphoreGive(logLock);  // Check if the connection is still up, oherwise disable  // all the logging and flush all the CRTP queues.  if (!crtpIsConnected())  {    logReset();    crtpReset();  }  else  {    crtpSendPacket(&pk);  }}
开发者ID:rtt-gimbal,项目名称:crazyflie-firmware,代码行数:94,


示例15: FreeRTOS_UART_write

//------------------------------------------------------------------------------------size_t FreeRTOS_UART_write( Peripheral_Descriptor_t const pxPeripheral, const void *pvBuffer, const size_t xBytes ){	// Esta funcion debe poner los caracteres apuntados en pvBuffer en la cola de trasmision.	// Actua como si fuese rprintfStr.	// Debe tomar el semaforo antes de trasmitir. Los semaforos los manejamos en la capa FreeRTOS	// y no en la de los drivers.char cChar;char *p;size_t bytes2tx;Peripheral_Control_t * const pxPeripheralControl = ( Peripheral_Control_t * const ) pxPeripheral;UART_device_control_t *pUart;size_t wBytes = 0;	pUart = pxPeripheralControl->phDevice;	// Controlo no hacer overflow en la cola de trasmision	bytes2tx = xBytes;	// Espero el semaforo en forma persistente.	while ( xSemaphoreTake(pxPeripheralControl->xBusSemaphore, ( TickType_t ) 1 ) != pdTRUE )		taskYIELD();	// Trasmito.	// Espero que los buffers esten vacios. ( La uart se va limpiando al trasmitir )	if ( pUart->txBufferType == QUEUE ) {		while  ( uxQueueMessagesWaiting( pUart->txStruct ) > 0 )			taskYIELD();	} else {		while  ( uxFifoMessagesWaiting( pUart->txStruct ) > 0 )			taskYIELD();	}	// Cargo el buffer en la cola de trasmision.	p = (char *)pvBuffer;	while (*p && (bytes2tx-- > 0) ) {		// Voy cargando la cola de a uno.		cChar = *p;		pv_enqueue( pUart, &cChar );		p++;		wBytes++;	// Cuento los bytes que voy trasmitiendo		// Si la cola esta llena, empiezo a trasmitir y espero que se vacie.		if (  pv_queueReachHighWaterMark(pUart) ) {			// Habilito a trasmitir para que se vacie			vUartInterruptOn(pxPeripheralControl->portId);			// Y espero que se haga mas lugar.			while ( ! pv_queueReachLowWaterMark(pUart) )				taskYIELD();		}	}	// Luego inicio la trasmision invocando la interrupcion.	vUartInterruptOn(pxPeripheralControl->portId);	xSemaphoreGive( pxPeripheralControl->xBusSemaphore );	//return xBytes;	// Puse todos los caracteres en la cola.	return (wBytes);}
开发者ID:ppeluffo,项目名称:sp5KV4_8CH,代码行数:62,


示例16: vHeartbeatTask

void vHeartbeatTask (void * pvParameters){	int Key, Entries, ySize;	uint16_t click_cnt=0;	int8_t Item_nb;	BUTTON_Handle hOK_Button, hTest_Key;	LISTBOX_Handle hStationListBox;	static enum GuiState eGuiState = SELECT;	static const GUI_ConstString StationList[] = {"ZET", "RMFFM", "RMFMAXXX", "SKY.FM", "ESKA ROCK", "TERMINAL", NULL};	vSemaphoreCreateBinary(xButton_pushed_Semaphore);	if(xDMAch1_Semaphore != NULL){		xSemaphoreTake(xButton_pushed_Semaphore, 0);	}else{		// The semaphore was not created	}	BUTTON_Config();	//INT0 Button as source of interrupt	xSemaphoreTake(xButton_pushed_Semaphore, 0);	xListBoxQueue = xQueueCreate(2, sizeof(int8_t));	GUI_Init();	if(0){		_ExecCalibration();	}else{		_DefaultCalibration();	}	GUI_SetBkColor(GUI_BLUE);	GUI_Clear();	if (xSemaphoreTake(xDhcpCmplSemaphore_1, portMAX_DELAY) == pdTRUE) {		/* OK button */		hOK_Button = BUTTON_CreateEx(120, 210, 80, 20, 0, WM_CF_SHOW, 0, 12);		GUI_SetFont(&GUI_Font32_ASCII);		BUTTON_SetText(hOK_Button, "OK");		/* Cancel button */		hTest_Key = BUTTON_CreateEx(120, 180, 80, 20, 0, WM_CF_SHOW, 0, 13);		GUI_SetFont(&GUI_Font16B_ASCII);		BUTTON_SetText(hTest_Key, "CLICK");		WM_SetStayOnTop(hTest_Key, 1);		/* Station list */		Entries = 6;//countof(StationList) - 1;		ySize = GUI_GetYDistOfFont(&GUI_Font16B_ASCII)*Entries;		hStationListBox = LISTBOX_CreateEx(100, 10, 120, ySize, 0, WM_CF_SHOW, 0, 5, StationList);		SCROLLBAR_CreateAttached(hStationListBox, SCROLLBAR_CF_VERTICAL);	}	while(1){		Key = GUI_GetKey();		//top = WM_GetStayOnTop(hTest_Key);		switch(eGuiState){		case SELECT:			switch (Key){			case 12:				Item_nb = LISTBOX_GetSel(hStationListBox);				if(Item_nb >= 0){					if(xQueueSendToBack(xListBoxQueue, &Item_nb, 50/portTICK_RATE_MS) == pdPASS){						/* OK button delete */						BUTTON_Delete(hOK_Button);						GUI_SetBkColor(GUI_BLUE);						GUI_ClearRect(120, 210, 200, 230);						GUI_ClearKeyBuffer();						/* Listbox delete */						LISTBOX_Delete(hStationListBox);						GUI_ClearRect(100, 10, 220, ySize+10);						eGuiState = PLAYING;					}				}				vTaskResume(xShoutcastTaskHandle);				break;			case 13:				click_cnt++;				GUI_SetFont(&GUI_Font16B_ASCII);				Item_nb = LISTBOX_GetSel(hStationListBox);				GUI_DispStringAt("CNT = ", 0, 210);				GUI_DispDecSpace(Item_nb, 3);				break;			default:				break;			}			break;		case PLAYING:			switch (Key){			case 13:				click_cnt++;				GUI_SetFont(&GUI_Font16B_ASCII);//				Item_nb = LISTBOX_GetSel(hStationListBox);				GUI_DispStringAt("CNT = ", 0, 210);				GUI_DispDecSpace(123, 3);//.........这里部分代码省略.........
开发者ID:phuonglab,项目名称:stream-radio-v3,代码行数:101,


示例17: vuIP_Task

//.........这里部分代码省略.........	uip_ipaddr( xIPAddr, configNET_MASK0, configNET_MASK1, configNET_MASK2, configNET_MASK3 );	uip_setnetmask( xIPAddr );	httpd_init();	/* Create the semaphore used to wake the uIP task. */	vSemaphoreCreateBinary( xEMACSemaphore );	/* Initialise the MAC. */	while( lEMACInit() != pdPASS )    {        vTaskDelay( uipINIT_WAIT );    }	portENTER_CRITICAL();	{		LPC_EMAC->IntEnable = ( INT_RX_DONE | INT_TX_DONE );		/* Set the interrupt priority to the max permissible to cause some		interrupt nesting. */		NVIC_SetPriority( ENET_IRQn, configEMAC_INTERRUPT_PRIORITY );		/* Enable the interrupt. */		NVIC_EnableIRQ( ENET_IRQn );		prvSetMACAddress();	}	portEXIT_CRITICAL();	for( ;; )	{		/* Is there received data ready to be processed? */		uip_len = ulGetEMACRxData();		if( ( uip_len > 0 ) && ( uip_buf != NULL ) )		{			/* Standard uIP loop taken from the uIP manual. */			if( xHeader->type == htons( UIP_ETHTYPE_IP ) )			{				uip_arp_ipin();				uip_input();				/* If the above function invocation resulted in data that				should be sent out on the network, the global variable				uip_len is set to a value > 0. */				if( uip_len > 0 )				{					uip_arp_out();					vSendEMACTxData( uip_len );				}			}			else if( xHeader->type == htons( UIP_ETHTYPE_ARP ) )			{				uip_arp_arpin();				/* If the above function invocation resulted in data that				should be sent out on the network, the global variable				uip_len is set to a value > 0. */				if( uip_len > 0 )				{					vSendEMACTxData( uip_len );				}			}		}		else		{			if( timer_expired( &periodic_timer ) && ( uip_buf != NULL ) )			{				timer_reset( &periodic_timer );				for( i = 0; i < UIP_CONNS; i++ )				{					uip_periodic( i );					/* If the above function invocation resulted in data that					should be sent out on the network, the global variable					uip_len is set to a value > 0. */					if( uip_len > 0 )					{						uip_arp_out();						vSendEMACTxData( uip_len );					}				}				/* Call the ARP timer function every 10 seconds. */				if( timer_expired( &arp_timer ) )				{					timer_reset( &arp_timer );					uip_arp_timer();				}			}			else			{				/* We did not receive a packet, and there was no periodic				processing to perform.  Block for a fixed period.  If a packet				is received during this period we will be woken by the ISR				giving us the Semaphore. */				xSemaphoreTake( xEMACSemaphore, configTICK_RATE_HZ / 2 );			}		}	}}
开发者ID:Hermis,项目名称:FreeRTOS_OR1200,代码行数:101,


示例18: handle_received_frame

static void handle_received_frame(void) {	uint8_t rx_length, length, *rx_ptr;	// Take semaphore	xSemaphoreTake(spi_mutex, portMAX_DELAY);	// Check if there is at least one byte in fifo	if (cc1101_status_rxbytes() == 0) {		xSemaphoreGive(spi_mutex);		restore_state();		PRINTF("[PHY] no byte/n");		return;	}	// Get length byte	cc1101_fifo_get(&rx_length, 1);	// Check length	if (rx_length > PHY_MAX_LENGTH) {		xSemaphoreGive(spi_mutex);		restore_state();		PRINTF("[PHY] length too big/n");		return;	}	rx_data_length = rx_length;	// Add 2 to the length for the status bytes	rx_length += PHY_FOOTER_LENGTH;	rx_ptr = rx_data;	// Loop until end of packet	while (cc1101_gdo0_read()) {		// get the bytes in FIFO		length = cc1101_status_rxbytes();		// Check for overflow		if (length & 0x80) {			// Release semaphore			xSemaphoreGive(spi_mutex);			restore_state();			PRINTF("[PHY] overflow/n");			return;		}		// Check for local overflow		if (length > rx_length) {			// Release semaphore			xSemaphoreGive(spi_mutex);			restore_state();			PRINTF("[PHY] local overflow/n");			return;		}		// Read every byte but one, to prevent CC1101 bug.		length -= 1;		cc1101_fifo_get(rx_ptr, length);		rx_ptr += length;		rx_length -= length;		// Wait until FIFO is filled above threshold, or EOP		while (!cc1101_gdo2_read() && cc1101_gdo0_read()) {			;		}	}	// Packet complete, get the end	length = cc1101_status_rxbytes();	// Check for overflow	if (length & 0x80) {		// Release semaphore		xSemaphoreGive(spi_mutex);		restore_state();		PRINTF("[PHY] overflow/n");		return;	}	// Check for local overflow	if (length > rx_length) {		// Release semaphore		xSemaphoreGive(spi_mutex);		restore_state();		PRINTF("[PHY] local overflow/n");		return;	}	// Get the bytes	cc1101_fifo_get(rx_ptr, length);	rx_ptr += length;	// Release semaphore	xSemaphoreGive(spi_mutex);	// Check CRC	if ((rx_data[rx_data_length + 1] & 0x80) == 0) {		// Bad CRC		restore_state();		PRINTF("[PHY] bad crc/n");//.........这里部分代码省略.........
开发者ID:EDAyele,项目名称:wsn430,代码行数:101,


示例19: main_task

/** * /brief Main demo task * * This task keeps track of which screen the user has selected, which tasks * to resume/suspend to draw the selected screen, and also draws the menu bar. * * The menu bar shows which screens the user can select by clicking the * corresponding buttons on the OLED1 Xplained Pro: * - /ref graph_task() "graph" (selected at start-up) * - /ref terminal_task() "term." * - /ref about_task() "about" * * /param params Parameters for the task. (Not used.) */static void main_task(void *params){    bool graph_buffer_initialized = false;    bool selection_changed = true;    bool select_graph_buffer;    enum menu_items current_selection = MENU_ITEM_GRAPH;    gfx_coord_t x, y, display_y_offset;    xTaskHandle temp_task_handle = NULL;    for(;;) {        // Show that task is executing        oled1_set_led_state(&oled1, OLED1_LED3_ID, true);        // Check buttons to see if user changed the selection        if (oled1_get_button_state(&oled1, OLED1_BUTTON1_ID)                && (current_selection != MENU_ITEM_GRAPH)) {            current_selection = MENU_ITEM_GRAPH;            selection_changed = true;        } else if (oled1_get_button_state(&oled1, OLED1_BUTTON2_ID)                   && (current_selection != MENU_ITEM_TERMINAL)) {            current_selection = MENU_ITEM_TERMINAL;            selection_changed = true;        } else if (oled1_get_button_state(&oled1, OLED1_BUTTON3_ID)                   && (current_selection != MENU_ITEM_ABOUT)) {            current_selection = MENU_ITEM_ABOUT;            selection_changed = true;        }        // If selection changed, handle the selection        if (selection_changed) {            // Wait for and take the display semaphore before doing any changes.            xSemaphoreTake(display_mutex, portMAX_DELAY);            // We can now safely suspend the previously resumed task            if (temp_task_handle) {                vTaskSuspend(temp_task_handle);                temp_task_handle = NULL;            }            // Select the new drawing task and corresponding display buffer            switch (current_selection) {            case MENU_ITEM_GRAPH:                // Graph task runs continuously, no need to set task handle                select_graph_buffer = true;                break;            case MENU_ITEM_TERMINAL:                temp_task_handle = terminal_task_handle;                select_graph_buffer = false;                break;            default:            case MENU_ITEM_ABOUT:                temp_task_handle = about_task_handle;                select_graph_buffer = false;            }            // Select and initialize display buffer to use.            display_y_offset = select_graph_buffer ? CANVAS_GRAPH_Y_OFFSET : 0;            // Draw the menu bar (only needs to be done once for graph)            if (!select_graph_buffer || !graph_buffer_initialized) {                // Clear the selected display buffer first                gfx_mono_draw_filled_rect(0, display_y_offset,                                          GFX_MONO_LCD_WIDTH, GFX_MONO_LCD_HEIGHT / 2,                                          GFX_PIXEL_CLR);                // Draw menu lines, each item with height MENU_HEIGHT pixels                y = display_y_offset + CANVAS_HEIGHT;                gfx_mono_draw_horizontal_line(0, y, GFX_MONO_LCD_WIDTH,                                              GFX_PIXEL_SET);                x = MENU_ITEM_WIDTH;                y++;                for (uint8_t i = 0; i < (MENU_NUM_ITEMS - 1); i++) {                    gfx_mono_draw_vertical_line(x, y, MENU_HEIGHT,                                                GFX_PIXEL_SET);                    x += 1 + MENU_ITEM_WIDTH;                }                // Highlight the current selection                gfx_mono_draw_rect(current_selection * (1 + MENU_ITEM_WIDTH), y,                                   MENU_ITEM_WIDTH, MENU_HEIGHT, GFX_PIXEL_SET);                // Draw the menu item text//.........这里部分代码省略.........
开发者ID:ThucVD2704,项目名称:femto-usb-blink-example,代码行数:101,


示例20: vuIP_Task

void vuIP_Task( void *pvParameters ){portBASE_TYPE i;uip_ipaddr_t xIPAddr;struct timer periodic_timer, arp_timer;extern void ( vEMAC_ISR_Wrapper )( void );	( void ) pvParameters;	/* Initialise the uIP stack. */	timer_set( &periodic_timer, configTICK_RATE_HZ / 2 );	timer_set( &arp_timer, configTICK_RATE_HZ * 10 );	uip_init();	uip_ipaddr( &xIPAddr, configIP_ADDR0, configIP_ADDR1, configIP_ADDR2, configIP_ADDR3 );	uip_sethostaddr( &xIPAddr );	uip_ipaddr( &xIPAddr, configNET_MASK0, configNET_MASK1, configNET_MASK2, configNET_MASK3 );	uip_setnetmask( &xIPAddr );	prvSetMACAddress();	httpd_init();	/* Create the semaphore used to wake the uIP task. */	vSemaphoreCreateBinary( xEMACSemaphore );	/* Initialise the MAC. */	vInitEmac();	while( lEMACWaitForLink() != pdPASS )    {        vTaskDelay( uipINIT_WAIT );    }	for( ;; )	{		/* Is there received data ready to be processed? */		uip_len = ( unsigned short ) ulEMACRead();				if( ( uip_len > 0 ) && ( uip_buf != NULL ) )		{			/* Standard uIP loop taken from the uIP manual. */			if( xHeader->type == htons( UIP_ETHTYPE_IP ) )			{				uip_arp_ipin();				uip_input();				/* If the above function invocation resulted in data that				should be sent out on the network, the global variable				uip_len is set to a value > 0. */				if( uip_len > 0 )				{					uip_arp_out();					vEMACWrite();				}			}			else if( xHeader->type == htons( UIP_ETHTYPE_ARP ) )			{				uip_arp_arpin();				/* If the above function invocation resulted in data that				should be sent out on the network, the global variable				uip_len is set to a value > 0. */				if( uip_len > 0 )				{					vEMACWrite();				}			}		}		else		{			if( timer_expired( &periodic_timer ) && ( uip_buf != NULL ) )			{				timer_reset( &periodic_timer );				for( i = 0; i < UIP_CONNS; i++ )				{					uip_periodic( i );					/* If the above function invocation resulted in data that					should be sent out on the network, the global variable					uip_len is set to a value > 0. */					if( uip_len > 0 )					{						uip_arp_out();						vEMACWrite();					}				}				/* Call the ARP timer function every 10 seconds. */				if( timer_expired( &arp_timer ) )				{					timer_reset( &arp_timer );					uip_arp_timer();				}			}			else			{				/* We did not receive a packet, and there was no periodic				processing to perform.  Block for a fixed period.  If a packet				is received during this period we will be woken by the ISR				giving us the Semaphore. */				xSemaphoreTake( xEMACSemaphore, configTICK_RATE_HZ / 2 );			}//.........这里部分代码省略.........
开发者ID:DIYzzuzpb,项目名称:PIC32USB,代码行数:101,


示例21: uart_task

/** * /brief UART task * * This task runs in the background to handle the queued, incoming terminal * characters and write them to the terminal text buffer. It does not print * anything to the display -- that is done by /ref terminal_task(). * * /param params Parameters for the task. (Not used.) */static void uart_task(void *params){    uint8_t *current_line_ptr;    uint8_t *current_char_ptr;    uint8_t current_column = 0;    for (;;) {        // Show that task is executing        oled1_set_led_state(&oled1, OLED1_LED1_ID, true);        // Grab terminal mutex        xSemaphoreTake(terminal_mutex, portMAX_DELAY);        current_line_ptr = terminal_buffer[terminal_line_offset];        current_char_ptr = current_line_ptr + current_column;        // Any characters queued? Handle them!        while (xQueueReceive(terminal_in_queue, current_char_ptr, 0)) {            /* Newline-handling is difficult because all terminal emulators             * seem to do it their own way. The method below seems to work             * with Putty and Realterm out of the box.             */            switch (*current_char_ptr) {            case '/r':                // Replace /r with /0 and move head to next line                *current_char_ptr = '/0';                current_column = 0;                terminal_line_offset = (terminal_line_offset + 1)                                       % TERMINAL_BUFFER_LINES;                current_line_ptr = terminal_buffer[terminal_line_offset];                current_char_ptr = current_line_ptr + current_column;                break;            case '/n':                // For /n, do nothing -- it is replaced with /0 later                break;            default:                // For all other characters, just move head to next char                current_column++;                if (current_column >= TERMINAL_COLUMNS) {                    current_column = 0;                    terminal_line_offset = (terminal_line_offset + 1)                                           % TERMINAL_BUFFER_LINES;                    current_line_ptr = terminal_buffer[terminal_line_offset];                }                current_char_ptr = current_line_ptr + current_column;            }            // Set zero-terminator at head            *current_char_ptr = '/0';        }        xSemaphoreGive(terminal_mutex);        oled1_set_led_state(&oled1, OLED1_LED1_ID, false);        vTaskDelay(UART_TASK_DELAY);    }}
开发者ID:ThucVD2704,项目名称:femto-usb-blink-example,代码行数:70,


示例22: lock_spi

void lock_spi() {    xSemaphoreTake(spiLock, portMAX_DELAY);}
开发者ID:jrwiebe,项目名称:RaceCapture-Pro_firmware,代码行数:3,


示例23: APP_MutexSPI0Take

void APP_MutexSPI0Take(void){	// This must block as we aren't telling the calling process that the semaphore couldn't be obtained!	while( xSemaphoreTake(xSPI0Semaphore, (portTickType)1) != pdTRUE ); 	return;	}
开发者ID:gillspice,项目名称:mios32,代码行数:6,


示例24: mp_thread_mutex_lock

int mp_thread_mutex_lock(mp_thread_mutex_t *mutex, int wait) {    return (pdTRUE == xSemaphoreTake(mutex->handle, wait ? portMAX_DELAY : 0));}
开发者ID:simonliu009,项目名称:MaixPy,代码行数:3,


示例25: Test_Manager

// Test manager task, in charge of running and deleting tests.void Test_Manager(){	char cReceived;	// State list for test manager.	typedef enum states {IDLE, TEST0, TEST1, TEST2, TEST3, TEST4,		TEST5, TEST6, TEST7, TEST8, TEST9} CurrState;				CurrState state = IDLE;	xTestMutex = xSemaphoreCreateMutex();	//Semaphore is taken in order to lower the value from 1 to 0.	xSemaphoreTake (xTEST_DONE, (portTickType)100);	//Checking mutex exists.	if (xTestMutex == NULL)	{		RIT128x96x4StringDraw("Mutex issue", 5, 20, 30);	}	Test_res* results_ptr;	Test_res results = {NULL,NULL,NULL,NULL,NULL};	for( ;; )	{		switch(state)		{		case IDLE:			if (xCOMMS_FROM_PC_Queue !=0)			{				if (xQueueReceive(xCOMMS_FROM_PC_Queue, &cReceived, (portTickType)10))				{					switch(cReceived)					{					case TEST0_REQ :						test_uart_a_startup();						state = TEST0;						break;					case TEST1_REQ :						// Test not implemented.						//test_uart_b_startup();						state = TEST1;						break;					case TEST2_REQ :						test_uart_ci_startup();						state = TEST2;						break;					case TEST3_REQ :						test_uart_cii_startup();						state = TEST3;						break;					case TEST4_REQ :						test_uart_d_startup();						state = TEST4;						break;					case TEST5_REQ :						test_gpio_a_startup();						state = TEST5;						break;					case TEST6_REQ :						test_gpio_b_startup();						state = TEST6;						break;					case TEST7_REQ :						test_gpio_c_startup();						state  = TEST7;						break;					case TEST8_REQ:						test_gpio_d_startup();						state = TEST8;						break;					case TEST9_REQ:						test_gpio_e_startup();						state = TEST9;						break;					default:						RIT128x96x4StringDraw("Invalid test number", 5, 20, 30);						break;					}				}			}			break;		case TEST0 :			if (xSemaphoreTake (xTEST_DONE, (portTickType)100) == pdTRUE)			{				test_uart_a_shutdown();				state = IDLE;			}			break;		case TEST1 :			results.test_type = '2';			results_ptr = &results;			results.test_string = "Test does not exist";			results.test_string_len = strlen(results.test_string);;			xQueueSendToBack( xSEND_RESULTS_Queue, (void*)&results_ptr, (portTickType)10);			if (xSemaphoreTake (xPC_SENT, (portTickType)100) == pdTRUE)			{//.........这里部分代码省略.........
开发者ID:ithinkthatmaybe,项目名称:ENCE463-test-bench,代码行数:101,


示例26: vuIP_Task

//.........这里部分代码省略.........	uip_ipaddr( xIPAddr, configIP_ADDR0, configIP_ADDR1, configIP_ADDR2, configIP_ADDR3 );	uip_sethostaddr( xIPAddr );	/* Initialise the WEB server. */	httpd_init();	/* Initialise the Ethernet controller peripheral. */	vFECInit();	for( ;; )	{		/* Is there received data ready to be processed? */		uip_len = usFECGetRxedData();		if( uip_len > 0 )		{			/* Standard uIP loop taken from the uIP manual. */			if( xHeader->type == htons( UIP_ETHTYPE_IP ) )			{				uip_arp_ipin();				uip_input();				/* If the above function invocation resulted in data that				should be sent out on the network, the global variable				uip_len is set to a value > 0. */				if( uip_len > 0 )				{					uip_arp_out();					vFECSendData();				}				else				{					/* If we are not sending data then let the FEC driver know					the buffer is no longer required. */					vFECRxProcessingCompleted();				}			}			else if( xHeader->type == htons( UIP_ETHTYPE_ARP ) )			{				uip_arp_arpin();				/* If the above function invocation resulted in data that				should be sent out on the network, the global variable				uip_len is set to a value > 0. */				if( uip_len > 0 )				{					vFECSendData();				}				else				{					/* If we are not sending data then let the FEC driver know					the buffer is no longer required. */					vFECRxProcessingCompleted();				}			}			else			{				/* If we are not sending data then let the FEC driver know				the buffer is no longer required. */				vFECRxProcessingCompleted();			}		}		else		{			if( timer_expired( &periodic_timer ) )			{				timer_reset( &periodic_timer );				for( i = 0; i < UIP_CONNS; i++ )				{					uip_periodic( i );					/* If the above function invocation resulted in data that					should be sent out on the network, the global variable					uip_len is set to a value > 0. */					if( uip_len > 0 )					{						uip_arp_out();						vFECSendData();					}				}				/* Call the ARP timer function every 10 seconds. */				if( timer_expired( &arp_timer ) )				{					timer_reset( &arp_timer );					uip_arp_timer();				}			}			else			{				/* We did not receive a packet, and there was no periodic				processing to perform.  Block for a fixed period.  If a packet				is received during this period we will be woken by the ISR				giving us the Semaphore. */				xSemaphoreTake( xFECSemaphore, configTICK_RATE_HZ / 2 );			}		}	}}
开发者ID:bleuelotus,项目名称:SweepRobot_Testing_Host,代码行数:101,


示例27: obp_uds

void obp_uds(void *pvParameters){//>>>> oobdtemple protocol initmain  >>>>    int keeprunning = 1;    data_packet *dp;    data_packet actDataPacket;    UBaseType_t busToUse = *(UBaseType_t *) pvParameters;/* function pointers to the bus interface */    extern bus_init actBus_init;    extern bus_send actBus_send;    extern bus_flush actBus_flush;    extern bus_param actBus_param;    extern bus_close actBus_close;    extern QueueHandle_t protocolQueue;    extern QueueHandle_t outputQueue;    extern QueueHandle_t inputQueue;    MsgData *msg;    MsgData *ownMsg;    param_data *args;    extern SemaphoreHandle_t protocollBinarySemaphore;    UBaseType_t msgType;    UBaseType_t timeout = 0;    UBaseType_t showBusTransfer = 0;    int i;    //catch the "Protocoll is running" Semaphore    xSemaphoreTake(protocollBinarySemaphore, portMAX_DELAY);    DEBUGPRINT("Start Bus nr %ld/n", busToUse);    /* activate the bus... */    odbarr[busToUse] ();    actBus_init();    ODPBuffer *protocolBuffer;    protocolBuffer = NULL;    // start with the protocol specific initalisation//<<<< oobdtemple protocol initmain <<<<    extern print_cbf printdata_CAN;    UBaseType_t sequenceCounter;    UBaseType_t remainingBytes;    UBaseType_t actBufferPos;    UBaseType_t actFrameLen;    UBaseType_t separationTime_ST = 0;    UBaseType_t actBlockSize_BS = 0;    UBaseType_t actSeparationTime_STTicks = 0;    UBaseType_t stateMachine_state = 0;    unsigned char telegram[8];    struct TPElement *tpList = NULL;	//!< keeps the list of testerPresents    /* tell the Rx-ISR about the function to use for received data */    busControl(ODB_CMD_RECV, odp_uds_recvdata);    protocolBuffer = createODPBuffer(UDSSIZE);    if (protocolBuffer == NULL) {	keeprunning = 0;    } else {	protocolBuffer->len = 0;    }    extern protocolConfigPtr actProtConfigPtr;    struct UdsConfig *protocolConfig;    protocolConfig = pvPortMalloc(sizeof(struct UdsConfig));    if (protocolConfig == NULL) {	keeprunning = 0;    } else {	actProtConfigPtr = protocolConfig;	/* Init default parameters */	protocolConfig->recvID = 0x7DF;	protocolConfig->sendID = 0x00;	// 0 disables special sendID	protocolConfig->timeout = 6;	protocolConfig->timeoutPending = 150;	protocolConfig->blockSize = 0;	protocolConfig->separationTime = 0;	protocolConfig->tpFreq = 250;	protocolConfig->tpType = 0x80;    }//>>>> oobdtemple protocol mainloop_start  >>>>        for (; keeprunning;) {	if (MSG_NONE != (msgType = waitMsg(protocolQueue, &msg, portMAX_DELAY)))	// portMAX_DELAY	    /* handle message */	{	    switch (msgType) {//<<<< oobdtemple protocol mainloop_start <<<<//>>>> oobdtemple protocol MSG_BUS_RECV  >>>>    	    case MSG_BUS_RECV:		dp = msg->addr;//<<<< oobdtemple protocol MSG_BUS_RECV <<<<		if (showBusTransfer > 0) {		    odp_uds_dumpFrame(dp, printdata_CAN);		}		if (((protocolConfig->sendID == 0 ? dp->recv == (protocolConfig->recvID | 8) : dp->recv == protocolConfig->sendID)) || protocolConfig->recvID == 0x7DF) {	/* Tester Address correct / we sendes a broadcast (protocolConfig->recvID==0x7DF)? */		    if (dp->data[0] == 0x03 && dp->data[1] == 0x7f && dp->data[3] == 0x78)	//Response pending		    {			timeout = protocolConfig->timeoutPending;		    } else {			if (stateMachine_state == SM_UDS_WAIT_FOR_FC) {			    if ((dp->data[0] & 0xF0) == 0x30) {	/* FlowControl */				DEBUGPRINT("FlowControl received/n", 'a');				/* as we now probably have to send many frames first before we receive any				   new answer from the module, we have to disable the timeout as long as we've sent the last frame				 */				timeout = 0;				//! /todo how to correctly support "wait" if LowNibble of PCI is 1?//.........这里部分代码省略.........
开发者ID:fkuppens,项目名称:oobd,代码行数:101,



注:本文中的xSemaphoreTake函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ xSemaphoreTakeRecursive函数代码示例
C++ xSemaphoreGiveRecursive函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。