这篇教程C++ xSemaphoreCreateCounting函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中xSemaphoreCreateCounting函数的典型用法代码示例。如果您正苦于以下问题:C++ xSemaphoreCreateCounting函数的具体用法?C++ xSemaphoreCreateCounting怎么用?C++ xSemaphoreCreateCounting使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了xSemaphoreCreateCounting函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: vStartCountingSemaphoreTasksvoid vStartCountingSemaphoreTasks( void ){ /* Create the semaphores that we are going to use for the test/demo. The first should be created such that it starts at its maximum count value, the second should be created such that it starts with a count value of zero. */ xParameters[ 0 ].xSemaphore = xSemaphoreCreateCounting( countMAX_COUNT_VALUE, countMAX_COUNT_VALUE ); xParameters[ 0 ].uxExpectedStartCount = countSTART_AT_MAX_COUNT; xParameters[ 0 ].uxLoopCounter = 0; xParameters[ 1 ].xSemaphore = xSemaphoreCreateCounting( countMAX_COUNT_VALUE, 0 ); xParameters[ 1 ].uxExpectedStartCount = 0; xParameters[ 1 ].uxLoopCounter = 0; /* Were the semaphores created? */ if( ( xParameters[ 0 ].xSemaphore != NULL ) || ( xParameters[ 1 ].xSemaphore != NULL ) ) { /* vQueueAddToRegistry() adds the semaphore to the registry, if one is in use. The registry is provided as a means for kernel aware debuggers to locate semaphores and has no purpose if a kernel aware debugger is not being used. The call to vQueueAddToRegistry() will be removed by the pre-processor if configQUEUE_REGISTRY_SIZE is not defined or is defined to be less than 1. */ vQueueAddToRegistry( ( QueueHandle_t ) xParameters[ 0 ].xSemaphore, "Counting_Sem_1" ); vQueueAddToRegistry( ( QueueHandle_t ) xParameters[ 1 ].xSemaphore, "Counting_Sem_2" ); /* Create the demo tasks, passing in the semaphore to use as the parameter. */ xTaskCreate( prvCountingSemaphoreTask, "CNT1", configMINIMAL_STACK_SIZE, ( void * ) &( xParameters[ 0 ] ), tskIDLE_PRIORITY, NULL ); xTaskCreate( prvCountingSemaphoreTask, "CNT2", configMINIMAL_STACK_SIZE, ( void * ) &( xParameters[ 1 ] ), tskIDLE_PRIORITY, NULL ); }}
开发者ID:bryanclark90,项目名称:Autonomous-Car,代码行数:30,
示例2: EFBuart0Init/* ----------------------------------------------------------------------------- * EFBuart0Init * * Initilizes an activates UART0 at given Baud Rate (in BPS). * Also defines a byte that should be watched during reception * ----------------------------------------------------------------------------- */void EFBuart0Init (uint32_t baudRate, tEFBboolean doubleTransmissionSpeed, uint8_t byteToWatch){ EFBInitUartControlStruct (gEFBuartControl0); sEFBuart0ByteToWatch = byteToWatch; if (doubleTransmissionSpeed) { // Enable double transmission speed EFBoutPort (UART0_STATUS_CTRL_A, _BV (UART0_BIT_U2X)); // Configure bitRate EFBoutPort (UBRR0L, (byte)EFBuartConvertDoubleSpeedBaudRate (baudRate, F_CPU)); } else { // Configure bitRate EFBoutPort (UBRR0L, (byte)EFBuartConvertBaudRate (baudRate, F_CPU)); } // Enable UART receiver, transmitter, and enable RX Complete Interrupt EFBoutPort (UART0_STATUS_CTRL_B, _BV (UART0_BIT_RXCIE) | _BV (UART0_BIT_TXEN) | _BV (UART0_BIT_RXEN)); /* Set frame format: asynchronous, 8data, no parity, 1stop bit */ // Configure UART frame to asyncronous, 1-bit stop, no parity, 8 bit data EFBoutPort (UART0_STATUS_CTRL_C, _BV (UART0_BIT_UCSZ0) | _BV (UART0_BIT_UCSZ1)); #if defined (EFBGENE_FREERTOS) UART0_RxSemaphore = xSemaphoreCreateCounting (UART0_RX_BUFFER_SIZE, 0); #endif // EFBGENE_FREERTOS} // EFBuart0Init
开发者ID:ORiGiNe,项目名称:asserv,代码行数:39,
示例3: xNetworkInterfaceInitialiseBaseType_t xNetworkInterfaceInitialise( void ){const TickType_t x5_Seconds = 5000UL; if( xEMACTaskHandle == NULL ) { prvGMACInit(); /* Wait at most 5 seconds for a Link Status in the PHY. */ xGMACWaitLS( pdMS_TO_TICKS( x5_Seconds ) ); /* The handler task is created at the highest possible priority to ensure the interrupt handler can return directly to it. */ xTaskCreate( prvEMACHandlerTask, "EMAC", configEMAC_TASK_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, &xEMACTaskHandle ); configASSERT( xEMACTaskHandle ); } if( xTxBufferQueue == NULL ) { xTxBufferQueue = xQueueCreate( GMAC_TX_BUFFERS, sizeof( void * ) ); configASSERT( xTxBufferQueue ); } if( xTXDescriptorSemaphore == NULL ) { xTXDescriptorSemaphore = xSemaphoreCreateCounting( ( UBaseType_t ) GMAC_TX_BUFFERS, ( UBaseType_t ) GMAC_TX_BUFFERS ); configASSERT( xTXDescriptorSemaphore ); } /* When returning non-zero, the stack will become active and start DHCP (in configured) */ return ( ulPHYLinkStatus & BMSR_LINK_STATUS ) != 0;}
开发者ID:unnamet,项目名称:Repo,代码行数:32,
示例4: main int main(){ PINSEL0 = 0x00000000; // Reset all pins as GPIO PINSEL1 = 0x00000000; PINSEL2 = 0x00000000; Init_Peripherals(); UART0_SendStr("/t/tCounting Semaphore/n"); xSemaphore = xSemaphoreCreateCounting( 5, 5 ); if( xSemaphore != NULL ) { UART0_SendStr("/tSemaphore Created/n"); xTaskCreate(vfork,"Philospher 1", 300 ,"P1", tskIDLE_PRIORITY + 1, NULL);//Task CreationxTaskCreate(vfork,"Philospher 2", 300 ,"P2", tskIDLE_PRIORITY + 1, NULL);//Task CreationxTaskCreate(vfork,"Philospher 3", 300 ,"P3", tskIDLE_PRIORITY + 1, NULL);//Task CreationxTaskCreate(vfork,"Philospher 4", 300 ,"P4", tskIDLE_PRIORITY + 1, NULL);//Task CreationxTaskCreate(vfork,"Philospher 5", 300 ,"P5", tskIDLE_PRIORITY + 1, NULL);//Task Creation vTaskStartScheduler(); //Task Scheduling } while(1)//Never reaches this Part of the main {UART0_SendStr("/t/tSemaphore not Created/n"); }}
开发者ID:Avilashm,项目名称:RTOS_LPC2148,代码行数:29,
示例5: mainint main( void ){ /* Before a semaphore is used it must be explicitly created. In this example a counting semaphore is created. The semaphore is created to have a maximum count value of 10, and an initial count value of 0. */ xCountingSemaphore = xSemaphoreCreateCounting( 10, 0 ); /* Check the semaphore was created successfully. */ if( xCountingSemaphore != NULL ) { /* Enable the software interrupt and set its priority. */ prvSetupSoftwareInterrupt(); /* Create the 'handler' task. This is the task that will be synchronized with the interrupt. The handler task is created with a high priority to ensure it runs immediately after the interrupt exits. In this case a priority of 3 is chosen. */ xTaskCreate( vHandlerTask, "Handler", 240, NULL, 3, NULL ); /* Create the task that will periodically generate a software interrupt. This is created with a priority below the handler task to ensure it will get preempted each time the handler task exist the Blocked state. */ xTaskCreate( vPeriodicTask, "Periodic", 240, NULL, 1, NULL ); /* Start the scheduler so the created tasks start executing. */ vTaskStartScheduler(); } /* If all is well we will never reach here as the scheduler will now be running the tasks. If we do reach here then it is likely that there was insufficient heap memory available for a resource to be created. */ for( ;; ); return 0;}
开发者ID:Lzyuan,项目名称:STE-LPC1768-,代码行数:34,
示例6: kernel_sem_init/*--------------------------------------------| Name: kernel_sem_init| Description:| Parameters: none| Return Type: none| Comments:| See:----------------------------------------------*/int kernel_sem_init(kernel_sem_t* kernel_sem, int pshared, unsigned int value){ if(!kernel_sem) return -1;#ifdef __KERNEL_UCORE_FREERTOS kernel_sem->sem = xSemaphoreCreateCounting( (unsigned portBASE_TYPE) (-1), (unsigned portBASE_TYPE) value);#endif return 0;}
开发者ID:lepton-distribution,项目名称:lepton-root.scions,代码行数:16,
示例7: xNetworkBuffersInitialiseBaseType_t xNetworkBuffersInitialise( void ){BaseType_t xReturn, x; /* Only initialise the buffers and their associated kernel objects if they have not been initialised before. */ if( xNetworkBufferSemaphore == NULL ) { xNetworkBufferSemaphore = xSemaphoreCreateCounting( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS, ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS ); configASSERT( xNetworkBufferSemaphore ); #if ( configQUEUE_REGISTRY_SIZE > 0 ) { vQueueAddToRegistry( xNetworkBufferSemaphore, "NetBufSem" ); } #endif /* configQUEUE_REGISTRY_SIZE */ /* If the trace recorder code is included name the semaphore for viewing in FreeRTOS+Trace. */ #if( ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS == 1 ) { extern QueueHandle_t xNetworkEventQueue; vTraceSetQueueName( xNetworkEventQueue, "IPStackEvent" ); vTraceSetQueueName( xNetworkBufferSemaphore, "NetworkBufferCount" ); } #endif /* ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS == 1 */ if( xNetworkBufferSemaphore != NULL ) { vListInitialise( &xFreeBuffersList ); /* Initialise all the network buffers. No storage is allocated to the buffers yet. */ for( x = 0; x < ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS; x++ ) { /* Initialise and set the owner of the buffer list items. */ xNetworkBufferDescriptors[ x ].pucEthernetBuffer = NULL; vListInitialiseItem( &( xNetworkBufferDescriptors[ x ].xBufferListItem ) ); listSET_LIST_ITEM_OWNER( &( xNetworkBufferDescriptors[ x ].xBufferListItem ), &xNetworkBufferDescriptors[ x ] ); /* Currently, all buffers are available for use. */ vListInsert( &xFreeBuffersList, &( xNetworkBufferDescriptors[ x ].xBufferListItem ) ); } uxMinimumFreeNetworkBuffers = ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS; } } if( xNetworkBufferSemaphore == NULL ) { xReturn = pdFAIL; } else { xReturn = pdPASS; } return xReturn;}
开发者ID:ttzeng,项目名称:lpcopen,代码行数:58,
示例8: sys_sem_newsys_sem_t sys_sem_new(u8_t count){ xSemaphoreHandle handle = xSemaphoreCreateCounting(255, count); if (handle == NULL) return SYS_SEM_NULL; return handle;}
开发者ID:go2starr,项目名称:ece453,代码行数:9,
示例9: xSemaphoreCreateCountingvoid AnalyzerControl::StartTask(){ _semaphore = xSemaphoreCreateCounting(1, 1); _needconfiguration = false; _needanalysis = 0; _analysiscomplete = false; xTaskCreate(vAnalyzerControlTask, "analyzercontrol", 512, NULL, 2 /* priority */, NULL);}
开发者ID:rpc-fw,项目名称:analyzer,代码行数:9,
示例10: Lock_Initializevoid Lock_Initialize( Lock *m ){ /* * sm = new Semaphore( ); * sm.count = 1; * sm.limit = 1; */ m->sm = xSemaphoreCreateCounting( 1, 1 );}
开发者ID:119,项目名称:bcm-wiced-sdk,代码行数:9,
示例11: SEM_Init/*! /brief Initializes module */void SEM_Init(void) { SemaphoreHandle_t xSemaphore = NULL; MySem = xSemaphoreCreateCounting(AS1_INP_BUF_SIZE/NOF_BYTES_IN_TICKET,0); //vSemaphoreCreateBinary(MySem); if (MySem == NULL) { for(;;); /* creation failed */ } FRTOS1_vQueueAddToRegistry(MySem,"Semaphore")}
开发者ID:davidhuwyler,项目名称:UniversellerSensorknoten_OpenHAB,代码行数:10,
示例12: low_level_init/** * In this function, the hardware should be initialized. * Called from ethernetif_init(). * * @param netif the already initialized lwip network interface structure * for this ethernetif */static voidlow_level_init(struct netif *netif){ portBASE_TYPE result;// struct ethernetif *ethernetif = netif->state; /* set MAC hardware address length */ netif->hwaddr_len = ETHARP_HWADDR_LEN; /* set MAC hardware address */ netif->hwaddr[5] = MYMAC_1; netif->hwaddr[4] = MYMAC_2; netif->hwaddr[3] = MYMAC_3; netif->hwaddr[2] = MYMAC_4; netif->hwaddr[1] = MYMAC_5; netif->hwaddr[0] = MYMAC_6; /* maximum transfer unit */ netif->mtu = ETH_MTU; /* device capabilities */ /* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */ netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP; /* Do whatever else is needed to initialize interface. */ semEthTx = xSemaphoreCreateCounting((unsigned portBASE_TYPE) NUM_TX_FRAG,(unsigned portBASE_TYPE) NUM_TX_FRAG); semEthRx = xSemaphoreCreateCounting((unsigned portBASE_TYPE) NUM_RX_FRAG,(unsigned portBASE_TYPE) 0); if(semEthTx == NULL) { LWIP_DEBUGF(NETIF_DEBUG,("Semaphore for ETH transmit created failed !/n/r")); }; if(semEthRx == NULL) { LWIP_DEBUGF(NETIF_DEBUG,("Semaphore for ETH recive created failed !/n/r")); }; result = xTaskCreate( ethernetif_input, ( signed portCHAR * ) "EhtTsk", sizeEthif, (void *)netif, prioEthif, &xETHTsk ); if(result != pdPASS) { LWIP_DEBUGF(NETIF_DEBUG,("Task for ETH recive created failed !/n/r ")); }; Init_EMAC();}
开发者ID:sunjiangbo,项目名称:stream-radio-v3,代码行数:49,
示例13: CreatorSemaphore_NewCreatorSemaphore CreatorSemaphore_New(uint tokensTotal, uint tokensTaken){ xSemaphoreHandle result; Creator_Assert(tokensTaken <= tokensTotal, "Bad initial number of tokens"); if (tokensTaken > tokensTotal) { tokensTaken = tokensTotal; } result = xSemaphoreCreateCounting(tokensTotal, (tokensTotal - tokensTaken)); return result;}
开发者ID:TonyWalsworthImg,项目名称:creator-wifire-app,代码行数:11,
示例14: OSA_SemaCreate/*FUNCTION********************************************************************** * * Function Name : OSA_SemaCreate * Description : This function is used to create a semaphore. Return * kStatus_OSA_Success if create successfully, otherwise return kStatus_OSA_Error. * *END**************************************************************************/osa_status_t OSA_SemaCreate(semaphore_t *pSem, uint8_t initValue){ assert(pSem); *pSem = xSemaphoreCreateCounting(0xFF, initValue); if (*pSem==NULL) { return kStatus_OSA_Error; /* creating semaphore failed */ } return kStatus_OSA_Success;}
开发者ID:ADeadCat,项目名称:mcuoneclipse,代码行数:18,
示例15: osCreateSemaphorebool_t osCreateSemaphore(OsSemaphore *semaphore, uint_t count){ //Create a semaphore semaphore->handle = xSemaphoreCreateCounting(count, count); //Check whether the returned handle is valid if(semaphore->handle != NULL) return TRUE; else return FALSE;}
开发者ID:Velleman,项目名称:VM204-Firmware,代码行数:11,
示例16: osSemaphoreCreate/*** @brief Create and Initialize a Semaphore object used for managing resources* @param semaphore_def semaphore definition referenced with /ref osSemaphore.* @param count number of available resources.* @retval semaphore ID for reference by other functions or NULL in case of error.* @note MUST REMAIN UNCHANGED: /b osSemaphoreCreate shall be consistent in every CMSIS-RTOS.*/osSemaphoreId osSemaphoreCreate (osSemaphoreDef_t *semaphore_def, int32_t count){ (void) semaphore_def; osSemaphoreId sema; if (count == 1) { vSemaphoreCreateBinary(sema); return sema; } return xSemaphoreCreateCounting(count, count);}
开发者ID:timurey,项目名称:oryx_stm32f205,代码行数:19,
示例17: power_CreateBinSema/** * create the semaphore for signallizing wake-up source * @param semaphore pointer which should be pointed to the new semaphore * @return status flag */static osa_status_t power_CreateBinSema(semaphore_t* semaphore ){ assert( semaphore ); *semaphore = xSemaphoreCreateCounting( 0x1, 0 ); if ( NULL == *semaphore ) { return kStatus_OSA_Error; } return kStatus_OSA_Success;}
开发者ID:Btar,项目名称:HEXIWEAR,代码行数:17,
示例18: xSemaphoreCreateCountingbool CCountingSemaphore::Create(UBaseType_t uxMaxCount, UBaseType_t uxInitialCount) {#if (configUSE_COUNTING_SEMAPHORES == 1) SemaphoreHandle_t handle = NULL; handle = xSemaphoreCreateCounting(uxMaxCount, uxInitialCount); if (handle != NULL) Attach(handle);#endif return IsValid();}
开发者ID:stf12,项目名称:stf12,代码行数:12,
示例19: Condition_Initializevoid Condition_Initialize( Condition *c ){ if ( c->m == NULL ) { /* this.m = m; */ Lock *m = (Lock*) malloc ( sizeof( Lock ) ); FAIL( m == NULL, ( "Unable to allocate memory for Lock m./r/n" ), NULL ); IPERF_MEMALLOC_DEBUG_MSG( m, sizeof( Lock ) ); Lock_Initialize( m ); c->m = m; /* int waiters = 0; */ c->waiters = 0; /* * s = new Semaphore( ); * s.count = 0; * s.limit = 999999; */ c->s = xSemaphoreCreateCounting( portMAX_DELAY, 0 ); /* * x = new Semaphore( ); * x.count = 1; * x.limit = 1; */ c->x = xSemaphoreCreateCounting( 1, 1 ); /* * h = new Semaphore( ); * h.count = 0; * h.limit = 999999; */ c->h = xSemaphoreCreateCounting( portMAX_DELAY, 0 ); } else { fprintf( stderr, "Condition already has a lock. Unable to initialize a new lock./r/n" ); }}
开发者ID:119,项目名称:bcm-wiced-sdk,代码行数:40,
示例20: mainint main(){ pm_enable_osc0_crystal (&AVR32_PM, FOSC0); pm_enable_clk0 (&AVR32_PM, OSC0_STARTUP); pm_switch_to_clock (&AVR32_PM, AVR32_PM_MCSEL_OSC0); USART_Initialize (); usart_write_line (&AVR32_USART0, "USART initialized/n"); usart_write_line (&AVR32_USART0, "DIP204 initialized/n"); Item_Available_Count = xSemaphoreCreateCounting (Item_Buffer_Count, 0); Space_Available_Count = xSemaphoreCreateCounting (Item_Buffer_Count, Item_Buffer_Count - 1); xTaskCreate (Producer_Task_Function, "Producer", 512, NULL, tskIDLE_PRIORITY + 4, &Producer_Task_Handle); xTaskCreate (Consumer_Task_Function, "Consumer", 512, NULL, tskIDLE_PRIORITY + 4, &Consumer_Task_Handle); xTaskCreate (Blinker_Task_Function, "Blinker", 512, NULL, tskIDLE_PRIORITY + 4, NULL); vTaskStartScheduler ();}
开发者ID:johaa1993,项目名称:C-Examples,代码行数:22,
示例21: xNetworkBuffersInitialiseBaseType_t xNetworkBuffersInitialise( void ){BaseType_t xReturn, x; /* Only initialise the buffers and their associated kernel objects if they have not been initialised before. */ if( xNetworkBufferSemaphore == NULL ) { /* In case alternative locking is used, the mutexes can be initialised here */ ipconfigBUFFER_ALLOC_INIT( );/* * HT: The use of counting semaphores is perfect, good invention * It is just that I didn't find the time yet to adopt the newer FreeRTOS kernel * which supports it. I tried it and it crashed. Must dive into it some day */ xNetworkBufferSemaphore = xSemaphoreCreateCounting( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS, ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS ); configASSERT( xNetworkBufferSemaphore ); if( xNetworkBufferSemaphore != NULL ) { vListInitialise( &xFreeBuffersList ); /* Initialise all the network buffers. The buffer storage comes from the network interface, and different hardware has different requirements. */ vNetworkInterfaceAllocateRAMToBuffers( xNetworkBuffers ); for( x = 0; x < ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS; x++ ) { /* Initialise and set the owner of the buffer list items. */ vListInitialiseItem( &( xNetworkBuffers[ x ].xBufferListItem ) ); listSET_LIST_ITEM_OWNER( &( xNetworkBuffers[ x ].xBufferListItem ), &xNetworkBuffers[ x ] ); /* Currently, all buffers are available for use. */ vListInsert( &xFreeBuffersList, &( xNetworkBuffers[ x ].xBufferListItem ) ); } uxMinimumFreeNetworkBuffers = ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS; } } if( xNetworkBufferSemaphore == NULL ) { xReturn = pdFAIL; } else { xReturn = pdPASS; } return xReturn;}
开发者ID:oska874,项目名称:freertos,代码行数:51,
示例22: Application_Initunsigned char Application_Init(void){ unsigned int PWM_Max_Value = 0; PIDCoff Coff_MOTOR = {0, 0, 0}; TSVN_FOSC_Init(); TSVN_Led_Init(ALL); TSVN_ACS712_Init(); TSVN_QEI_TIM1_Init(400); TSVN_QEI_TIM3_Init(400); TSVN_QEI_TIM4_Init(400); TSVN_CAN_Init(); TSVN_USART_Init(); TSVN_TIM6_Init(2000); FIR_Init(); PWM_Max_Value = TSVN_PWM_TIM5_Init(5000); TSVN_PWM_TIM5_Set_Duty(0, MOTOR1_PWM); TSVN_PWM_TIM5_Set_Duty(0, MOTOR2_PWM); TSVN_PWM_TIM5_Set_Duty(0, MOTOR3_PWM); TSVN_PWM_TIM5_Start(); DIR_Init(); PID_Mem_Create(3); PID_WindUp_Init(MOTOR1, PWM_Max_Value); PID_WindUp_Init(MOTOR2, PWM_Max_Value); PID_WindUp_Init(MOTOR3, PWM_Max_Value); Coff_MOTOR.Kp = 4; Coff_MOTOR.Ki = 0.01; Coff_MOTOR.Kd = 0.0; PID_Init(MOTOR1, Coff_MOTOR); PID_Init(MOTOR2, Coff_MOTOR); PID_Init(MOTOR3, Coff_MOTOR); Pos_Queue = xQueueCreate(200, sizeof(Pos_TypeDef)); CanRxQueue = xQueueCreate(200, sizeof(CanRxMsg)); Moment_Queue = xQueueCreate(200, sizeof(Moment_Typedef)); RxQueue = xQueueCreate(200, sizeof(xData)); UART_xCountingSemaphore = xSemaphoreCreateCounting(200, 0); if (Pos_Queue != NULL && CanRxQueue != NULL && Moment_Queue != NULL && UART_xCountingSemaphore != NULL && RxQueue != NULL) return SUCCESS; return ERROR;}
开发者ID:NguyenTrongThinh,项目名称:FindPIDCoff,代码行数:50,
示例23: initOSDataStructs// This function simply creates a message queue and a semaphoreint initOSDataStructs(void){ thres_freq = 49.00; thres_delta = 25.00; load_stability_flag = 0; x_sem_loads = xSemaphoreCreateBinary(); Q_freq_data = xQueueCreate( 100, sizeof( struct freq_struct) ); stability_queue = xQueueCreate( MSG_QUEUE_SIZE, sizeof( int) ); load_mngmnt_queue = xQueueCreate( MSG_QUEUE_SIZE, sizeof( int) ); msgqueue = xQueueCreate( MSG_QUEUE_SIZE, sizeof( void* ) ); shared_resource_sem = xSemaphoreCreateCounting( 9999, 1 ); return 0;}
开发者ID:ravbrar,项目名称:cs723_Asig1,代码行数:15,
示例24: prvExerciseSemaphoreAPIstatic void prvExerciseSemaphoreAPI( void ){SemaphoreHandle_t xSemaphore;const UBaseType_t uxMaxCount = 5, uxInitialCount = 0; /* Most of the semaphore API is common to the queue API and is already being used. This function uses a few semaphore functions that are unique to the RTOS objects, rather than generic and used by queues also. First create and use a counting semaphore. */ xSemaphore = xSemaphoreCreateCounting( uxMaxCount, uxInitialCount ); configASSERT( xSemaphore ); /* Give the semaphore a couple of times and ensure the count is returned correctly. */ xSemaphoreGive( xSemaphore ); xSemaphoreGive( xSemaphore ); configASSERT( uxSemaphoreGetCount( xSemaphore ) == 2 ); vSemaphoreDelete( xSemaphore ); /* Create a recursive mutex, and ensure the mutex holder and count are returned returned correctly. */ xSemaphore = xSemaphoreCreateRecursiveMutex(); configASSERT( uxSemaphoreGetCount( xSemaphore ) == 1 ); configASSERT( xSemaphore ); xSemaphoreTakeRecursive( xSemaphore, mainDONT_BLOCK ); xSemaphoreTakeRecursive( xSemaphore, mainDONT_BLOCK ); configASSERT( xSemaphoreGetMutexHolder( xSemaphore ) == xTaskGetCurrentTaskHandle() ); configASSERT( xSemaphoreGetMutexHolder( xSemaphore ) == xTaskGetHandle( mainTASK_TO_DELETE_NAME ) ); xSemaphoreGiveRecursive( xSemaphore ); configASSERT( uxSemaphoreGetCount( xSemaphore ) == 0 ); xSemaphoreGiveRecursive( xSemaphore ); configASSERT( uxSemaphoreGetCount( xSemaphore ) == 1 ); configASSERT( xSemaphoreGetMutexHolder( xSemaphore ) == NULL ); vSemaphoreDelete( xSemaphore ); /* Create a normal mutex, and sure the mutex holder and count are returned returned correctly. */ xSemaphore = xSemaphoreCreateMutex(); configASSERT( xSemaphore ); xSemaphoreTake( xSemaphore, mainDONT_BLOCK ); xSemaphoreTake( xSemaphore, mainDONT_BLOCK ); configASSERT( uxSemaphoreGetCount( xSemaphore ) == 0 ); /* Not recursive so can only be 1. */ configASSERT( xSemaphoreGetMutexHolder( xSemaphore ) == xTaskGetCurrentTaskHandle() ); xSemaphoreGive( xSemaphore ); configASSERT( uxSemaphoreGetCount( xSemaphore ) == 1 ); configASSERT( xSemaphoreGetMutexHolder( xSemaphore ) == NULL ); vSemaphoreDelete( xSemaphore );}
开发者ID:sean93park,项目名称:freertos,代码行数:49,
示例25: feabhOS_counting_semaphore_create/* Counting semaphore functions*/feabhOS_error feabhOS_counting_semaphore_create(feabhOS_COUNTING_SEMAPHORE * const pSemaphore, num_elements_t max_count, num_elements_t init_count){ feabhOS_COUNTING_SEMAPHORE self; self = getCountingInstance(); if(self == NULL) return ERROR_MEMORY; self->semaphore = xSemaphoreCreateCounting((portBASE_TYPE)max_count, (portBASE_TYPE)init_count); if(self->semaphore == 0) return ERROR_MEMORY; *pSemaphore = self; return ERROR_OK;}
开发者ID:nscooling,项目名称:AC-401,代码行数:18,
示例26: start_web_servervoid start_web_server(){ printf("/r/nWEB:Enter start web server!/n"); webs_terminate = 0; if(webs_task == NULL) { if(xTaskCreate(vBasicWEBServer, (const char *)"web_server", STACKSIZE, NULL, tskIDLE_PRIORITY + 1, &webs_task) != pdPASS) printf("/n/rWEB: Create webserver task failed!/n"); } if(webs_sema == NULL) { webs_sema = xSemaphoreCreateCounting(0xffffffff, 0); //Set max count 0xffffffff } //printf("/r/nWEB:Exit start web server!/n");}
开发者ID:KuanYuChen,项目名称:ameba-sdk-gcc-make,代码行数:15,
示例27: xNetworkBuffersInitialiseBaseType_t xNetworkBuffersInitialise( void ){BaseType_t xReturn, x; /* Only initialise the buffers and their associated kernel objects if they have not been initialised before. */ if( xNetworkBufferSemaphore == NULL ) { /* In case alternative locking is used, the mutexes can be initialised here */ ipconfigBUFFER_ALLOC_INIT(); xNetworkBufferSemaphore = xSemaphoreCreateCounting( ( UBaseType_t ) ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS, ( UBaseType_t ) ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS ); configASSERT( xNetworkBufferSemaphore ); if( xNetworkBufferSemaphore != NULL ) { vListInitialise( &xFreeBuffersList ); /* Initialise all the network buffers. The buffer storage comes from the network interface, and different hardware has different requirements. */ vNetworkInterfaceAllocateRAMToBuffers( xNetworkBuffers ); for( x = 0; x < ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS; x++ ) { /* Initialise and set the owner of the buffer list items. */ vListInitialiseItem( &( xNetworkBuffers[ x ].xBufferListItem ) ); listSET_LIST_ITEM_OWNER( &( xNetworkBuffers[ x ].xBufferListItem ), &xNetworkBuffers[ x ] ); /* Currently, all buffers are available for use. */ vListInsert( &xFreeBuffersList, &( xNetworkBuffers[ x ].xBufferListItem ) ); } uxMinimumFreeNetworkBuffers = ( UBaseType_t ) ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS; } } if( xNetworkBufferSemaphore == NULL ) { xReturn = pdFAIL; } else { xReturn = pdPASS; } return xReturn;}
开发者ID:cjlano,项目名称:freertos,代码行数:48,
示例28: osUserDefinedSemaphoreCreate/*** @brief Create and Initialize a Semaphore object used for managing resources* @param semaphore_def semaphore definition referenced with /ref osSemaphore.* @param count number of available resources.* @retval semaphore ID for reference by other functions or NULL in case of error.* @note MUST REMAIN UNCHANGED: /b osSemaphoreCreate shall be consistent in every CMSIS-RTOS.*/osSemaphoreId osUserDefinedSemaphoreCreate (const osSemaphoreDef_t *semaphore_def, int32_t count){ (void) semaphore_def; osSemaphoreId sema; if (count == 1) { vSemaphoreCreateBinary(sema); return sema; }#if (configUSE_COUNTING_SEMAPHORES == 1 ) return xSemaphoreCreateCounting(count, count);#else return NULL;#endif}
开发者ID:chaichai222,项目名称:Telecontroller,代码行数:23,
示例29: prvCreateAndDeleteStaticallyAllocatedCountingSemaphoresstatic void prvCreateAndDeleteStaticallyAllocatedCountingSemaphores( void ){SemaphoreHandle_t xSemaphore;const UBaseType_t uxMaxCount = ( UBaseType_t ) 10;/* StaticSemaphore_t is a publicly accessible structure that has the same sizeand alignment requirements as the real semaphore structure. It is provided as amechanism for applications to know the size of the semaphore (which is dependenton the architecture and configuration file settings) without breaking the strictdata hiding policy by exposing the real semaphore internals. ThisStaticSemaphore_t variable is passed into the xSemaphoreCreateCountingStatic()function calls within this function. NOTE: In most usage scenarios now it isfaster and more memory efficient to use a direct to task notification instead ofa counting semaphore. http://www.freertos.org/RTOS-task-notifications.html */StaticSemaphore_t xSemaphoreBuffer; /* Create the semaphore. xSemaphoreCreateCountingStatic() has one more parameter than the usual xSemaphoreCreateCounting() function. The parameter is a pointer to the pre-allocated StaticSemaphore_t structure, which will hold information on the semaphore in an anonymous way. If the pointer is passed as NULL then the structure will be allocated dynamically, just as when xSemaphoreCreateCounting() is called. */ xSemaphore = xSemaphoreCreateCountingStatic( uxMaxCount, 0, &xSemaphoreBuffer ); /* The semaphore handle should equal the static semaphore structure passed into the xSemaphoreCreateBinaryStatic() function. */ configASSERT( xSemaphore == ( SemaphoreHandle_t ) &xSemaphoreBuffer ); /* Ensure the semaphore passes a few sanity checks as a valid semaphore. */ prvSanityCheckCreatedSemaphore( xSemaphore, uxMaxCount ); /* Delete the semaphore again so the buffers can be reused. */ vSemaphoreDelete( xSemaphore ); #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) { /* Now do the same but using dynamically allocated buffers to ensure the delete functions are working correctly in both the static and dynamic allocation cases. */ xSemaphore = xSemaphoreCreateCounting( uxMaxCount, 0 ); configASSERT( xSemaphore != NULL ); prvSanityCheckCreatedSemaphore( xSemaphore, uxMaxCount ); vSemaphoreDelete( xSemaphore ); } #endif}
开发者ID:radiolok,项目名称:RelayComputer2,代码行数:46,
注:本文中的xSemaphoreCreateCounting函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ xSemaphoreCreateMutex函数代码示例 C++ xSemaphoreCreateBinary函数代码示例 |