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

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

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

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

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

示例1: sensorsInterruptInit

static void sensorsInterruptInit(void){  GPIO_InitTypeDef GPIO_InitStructure;  EXTI_InitTypeDef EXTI_InitStructure;  sensorsDataReady = xSemaphoreCreateBinary();  dataReady = xSemaphoreCreateBinary();  // FSYNC "shall not be floating, must be set high or low by the MCU"  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14;  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;  GPIO_Init(GPIOC, &GPIO_InitStructure);  GPIO_ResetBits(GPIOC, GPIO_Pin_14);  // Enable the MPU6500 interrupt on PC13  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;  GPIO_Init(GPIOC, &GPIO_InitStructure);  SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOC, EXTI_PinSource13);  EXTI_InitStructure.EXTI_Line = EXTI_Line13;  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;  EXTI_InitStructure.EXTI_LineCmd = ENABLE;  portDISABLE_INTERRUPTS();  EXTI_Init(&EXTI_InitStructure);  EXTI_ClearITPendingBit(EXTI_Line13);  portENABLE_INTERRUPTS();}
开发者ID:whoenig,项目名称:crazyflie-firmware,代码行数:34,


示例2: main

int main(void){	gpio_setup();	interrupts_setup();	motor_pwm_setup();	empty_sem = xSemaphoreCreateBinary();	configASSERT( empty_sem );	full_sem = xSemaphoreCreateBinary();	configASSERT( full_sem );	xTaskCreate(led_blink, "led_bliker", configMINIMAL_STACK_SIZE, NULL, 1, &blink_handler);	configASSERT( blink_handler );	vTaskSuspend(blink_handler);	xTaskCreate(start_filling, "start_filling", configMINIMAL_STACK_SIZE, NULL, 2, &start_filling_hanlder);	configASSERT( start_filling_hanlder );	xTaskCreate(stop_filling, "stop_filling", configMINIMAL_STACK_SIZE, NULL, 3, &stop_filling_handler);	configASSERT( stop_filling_handler );	recue_tim_handler = xTimerCreate("recue_timer", (1000/portTICK_PERIOD_MS), pdFALSE, (void *) 0, recue_tim_func );	configASSERT(recue_tim_handler);	vTaskStartScheduler();	return 1;}
开发者ID:romanjoe,项目名称:CoffeeAuto,代码行数:26,


示例3: sensorsInterruptInit

static void sensorsInterruptInit(void){  GPIO_InitTypeDef GPIO_InitStructure;  EXTI_InitTypeDef EXTI_InitStructure;  sensorsDataReady = xSemaphoreCreateBinary();  dataReady = xSemaphoreCreateBinary();  // Enable the interrupt on PC14  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14;  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; //GPIO_PuPd_DOWN;  GPIO_Init(GPIOC, &GPIO_InitStructure);  SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOC, EXTI_PinSource14);  EXTI_InitStructure.EXTI_Line = EXTI_Line14;  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;  EXTI_InitStructure.EXTI_LineCmd = ENABLE;  portDISABLE_INTERRUPTS();  EXTI_Init(&EXTI_InitStructure);  EXTI_ClearITPendingBit(EXTI_Line14);  portENABLE_INTERRUPTS();}
开发者ID:whoenig,项目名称:crazyflie-firmware,代码行数:25,


示例4: xSemaphoreCreateBinary

bool example_alarm::init(void){    mAlarmSec = xSemaphoreCreateBinary();    mAlarmMin = xSemaphoreCreateBinary();    return (mAlarmSec != NULL && mAlarmMin != NULL);}
开发者ID:PWDawgy,项目名称:lpc1758_freertos,代码行数:7,


示例5: vStartSemaphoreTasks

void vStartSemaphoreTasks( UBaseType_t uxPriority ){xSemaphoreParameters *pxFirstSemaphoreParameters, *pxSecondSemaphoreParameters;const TickType_t xBlockTime = ( TickType_t ) 100;	/* Create the structure used to pass parameters to the first two tasks. */	pxFirstSemaphoreParameters = ( xSemaphoreParameters * ) pvPortMalloc( sizeof( xSemaphoreParameters ) );	if( pxFirstSemaphoreParameters != NULL )	{		/* Create the semaphore used by the first two tasks. */		pxFirstSemaphoreParameters->xSemaphore = xSemaphoreCreateBinary();		xSemaphoreGive( pxFirstSemaphoreParameters->xSemaphore );		if( pxFirstSemaphoreParameters->xSemaphore != NULL )		{			/* Create the variable which is to be shared by the first two tasks. */			pxFirstSemaphoreParameters->pulSharedVariable = ( uint32_t * ) pvPortMalloc( sizeof( uint32_t ) );			/* Initialise the share variable to the value the tasks expect. */			*( pxFirstSemaphoreParameters->pulSharedVariable ) = semtstNON_BLOCKING_EXPECTED_VALUE;			/* The first two tasks do not block on semaphore calls. */			pxFirstSemaphoreParameters->xBlockTime = ( TickType_t ) 0;			/* Spawn the first two tasks.  As they poll they operate at the idle priority. */			xTaskCreate( prvSemaphoreTest, "PolSEM1", semtstSTACK_SIZE, ( void * ) pxFirstSemaphoreParameters, tskIDLE_PRIORITY, ( TaskHandle_t * ) NULL );			xTaskCreate( prvSemaphoreTest, "PolSEM2", semtstSTACK_SIZE, ( void * ) pxFirstSemaphoreParameters, tskIDLE_PRIORITY, ( TaskHandle_t * ) NULL );		}	}	/* Do exactly the same to create the second set of tasks, only this time 	provide a block time for the semaphore calls. */	pxSecondSemaphoreParameters = ( xSemaphoreParameters * ) pvPortMalloc( sizeof( xSemaphoreParameters ) );	if( pxSecondSemaphoreParameters != NULL )	{		pxSecondSemaphoreParameters->xSemaphore = xSemaphoreCreateBinary();		xSemaphoreGive( pxSecondSemaphoreParameters->xSemaphore );		if( pxSecondSemaphoreParameters->xSemaphore != NULL )		{			pxSecondSemaphoreParameters->pulSharedVariable = ( uint32_t * ) pvPortMalloc( sizeof( uint32_t ) );			*( pxSecondSemaphoreParameters->pulSharedVariable ) = semtstBLOCKING_EXPECTED_VALUE;			pxSecondSemaphoreParameters->xBlockTime = xBlockTime / portTICK_PERIOD_MS;			xTaskCreate( prvSemaphoreTest, "BlkSEM1", semtstSTACK_SIZE, ( void * ) pxSecondSemaphoreParameters, uxPriority, ( TaskHandle_t * ) NULL );			xTaskCreate( prvSemaphoreTest, "BlkSEM2", semtstSTACK_SIZE, ( void * ) pxSecondSemaphoreParameters, uxPriority, ( TaskHandle_t * ) 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 ) pxFirstSemaphoreParameters->xSemaphore, "Counting_Sem_1" );	vQueueAddToRegistry( ( QueueHandle_t ) pxSecondSemaphoreParameters->xSemaphore, "Counting_Sem_2" );}
开发者ID:UTAT-SpaceSystems,项目名称:CDH-OBC_PhaseI,代码行数:59,


示例6: vInicializar_globales

/* * Variables globales * */void vInicializar_globales(){	xSem_OK = xSemaphoreCreateBinary();	xSem_Fin_mov = xSemaphoreCreateBinary();	xCola_mov = FRTOS1_xQueueCreate(MAX_MOVIMIENTOS, sizeof(uint8));	xCola_US = FRTOS1_xQueueCreate(1, sizeof(portCHAR));	sensar = FALSE;	distancia_objeto = 999;}
开发者ID:asCii88,项目名称:RoboTito,代码行数:11,


示例7: scheduler_task

/** * Queueset example shows how to use FreeRTOS to block on MULTIPLE semaphores or queues. * The idea is that we want to call our run() when EITHER of mSec, or mMin semaphore is ready. * This example also shows how to log information to "log" file on flash memory. */example_logger_qset::example_logger_qset() :    scheduler_task("ex_log_qset", 4 * 512, PRIORITY_LOW),    mSec(NULL),    mMin(NULL){    mSec = xSemaphoreCreateBinary();    mMin = xSemaphoreCreateBinary();}
开发者ID:PWDawgy,项目名称:lpc1758_freertos,代码行数:13,


示例8: initComms

void initComms(void){/* Setup the queues to use */    commsSendQueue = xQueueCreate(COMMS_QUEUE_SIZE,1);    commsReceiveQueue = xQueueCreate(COMMS_QUEUE_SIZE,1);    commsSendSemaphore = xSemaphoreCreateBinary();    xSemaphoreGive(commsSendSemaphore);    commsEmptySemaphore = xSemaphoreCreateBinary();    xSemaphoreGive(commsEmptySemaphore);}
开发者ID:ksarkies,项目名称:Battery-Management-System,代码行数:10,


示例9: esp_ipc_init

void esp_ipc_init(){    s_ipc_mutex = xSemaphoreCreateMutex();    s_ipc_ack = xSemaphoreCreateBinary();    const char* task_names[2] = {"ipc0", "ipc1"};    for (int i = 0; i < portNUM_PROCESSORS; ++i) {        s_ipc_sem[i] = xSemaphoreCreateBinary();        portBASE_TYPE res = xTaskCreatePinnedToCore(ipc_task, task_names[i], CONFIG_IPC_TASK_STACK_SIZE, (void*) i,                                                    configMAX_PRIORITIES - 1, &s_ipc_tasks[i], i);        assert(res == pdTRUE);    }}
开发者ID:mr-nice,项目名称:esp-idf,代码行数:12,


示例10: APP_Init

void APP_Init(void) {  //DbgConsole_Printf("hello world./r/n");#if PL_CONFIG_HAS_SHELL_QUEUE  SQUEUE_Init();#endif  semSW2 = xSemaphoreCreateBinary();  if (semSW2==NULL) { /* semaphore creation failed */    for(;;){} /* error */  }  vQueueAddToRegistry(semSW2, "Sem_SW2");  semSW3 = xSemaphoreCreateBinary();  if (semSW3==NULL) { /* semaphore creation failed */    for(;;){} /* error */  }  vQueueAddToRegistry(semSW3, "Sem_SW3");  semLED = xSemaphoreCreateBinary();  if (semLED==NULL) { /* semaphore creation failed */    for(;;){} /* error */  }  vQueueAddToRegistry(semLED, "Sem_LED");  semMouse = xSemaphoreCreateBinary();  if (semMouse==NULL) { /* semaphore creation failed */    for(;;){} /* error */  }  vQueueAddToRegistry(semMouse, "Sem_Mouse");  semKbd = xSemaphoreCreateBinary();  if (semKbd==NULL) { /* semaphore creation failed */    for(;;){} /* error */  }  vQueueAddToRegistry(semKbd, "Sem_Kbd");#if 0  /*! /todo 1 Increase stack size by 50 */  if (xTaskCreate(ButtonTask, "Buttons", configMINIMAL_STACK_SIZE+50, NULL, tskIDLE_PRIORITY+2, NULL) != pdPASS) { /*! /todo 1 Increase stack size by 50 */#else    if (xTaskCreate(ButtonTask, "Buttons", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+2, NULL) != pdPASS) {#endif    for(;;){} /* error */  }  if (xTaskCreate(AppTask, "App", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, NULL) != pdPASS) {    for(;;){} /* error */  }#if configUSE_TRACE_HOOKS  vTraceSetISRProperties("ISR_USB", TRACE_PRIO_ISR_USB);#endif}
开发者ID:SISommer,项目名称:mcuoneclipse,代码行数:48,


示例11: vStartSystemLEDTask

void vStartSystemLEDTask( UBaseType_t uxPriority){	if(xStatusSemaphore==NULL)		{			xStatusSemaphore = xSemaphoreCreateBinary();		}		xTaskCreate(vSystemLEDTask, "Status LED", systemledSTACK_SIZE, NULL, uxPriority, (TaskHandle_t *) NULL );}
开发者ID:jakubszlendak,项目名称:modbus_sensor,代码行数:7,


示例12: vStartButtonTask

void vStartButtonTask( UBaseType_t uxPriority){	if(xButtonSemaphore==NULL)	{		xButtonSemaphore = xSemaphoreCreateBinary();	}	xTaskCreate(vButtonTask, "Button", buttonSTACK_SIZE, NULL, uxPriority, (TaskHandle_t *) NULL );}
开发者ID:jakubszlendak,项目名称:modbus_sensor,代码行数:7,


示例13: mpI2CRegs

I2C_Base::I2C_Base(LPC_I2C_TypeDef* pI2CBaseAddr) :        mpI2CRegs(pI2CBaseAddr),        mDisableOperation(false){    mI2CMutex = xSemaphoreCreateMutex();    mTransferCompleteSignal = xSemaphoreCreateBinary();    /// Binary semaphore needs to be taken after creating it    xSemaphoreTake(mTransferCompleteSignal, 0);    if((unsigned int)mpI2CRegs == LPC_I2C0_BASE)    {        mIRQ = I2C0_IRQn;    }    else if((unsigned int)mpI2CRegs == LPC_I2C1_BASE)    {        mIRQ = I2C1_IRQn;    }    else if((unsigned int)mpI2CRegs == LPC_I2C2_BASE)    {        mIRQ = I2C2_IRQn;    }    else {        mIRQ = (IRQn_Type)99; // Using invalid IRQ on purpose    }}
开发者ID:BrzTit,项目名称:Tricopter-4,代码行数:26,


示例14: leuartInit

static void leuartInit(void){    LEUART_Init_TypeDef leuart0Init;    leuart0Init.enable = leuartEnable;       /* Activate data reception on LEUn_TX pin. */    leuart0Init.refFreq = 0;                 /* Inherit the clock frequenzy from the LEUART clock source */    leuart0Init.baudrate = LEUART0_BAUDRATE; /* Baudrate = 9600 bps */    leuart0Init.databits = leuartDatabits8;  /* Each LEUART frame containes 8 databits */    leuart0Init.parity = leuartNoParity;     /* No parity bits in use */    leuart0Init.stopbits = leuartStopbits2;  /* Setting the number of stop bits in a frame to 2 bitperiods */    CMU_ClockEnable(cmuClock_CORELE, true);    CMU_ClockEnable(cmuClock_LEUART0, true);    LEUART_Reset(LEUART0);    LEUART_Init(LEUART0, &leuart0Init);    LEUART0->SIGFRAME = '/n';    /* Enable LEUART Signal Frame Interrupt */    LEUART_IntEnable(LEUART0, LEUART_IEN_SIGF);    /* Enable LEUART0 interrupt vector */    NVIC_SetPriority(LEUART0_IRQn, LEUART0_INT_PRIORITY);    LEUART0->ROUTE = LEUART_ROUTE_RXPEN | LEUART_ROUTE_TXPEN | LEUART0_LOCATION;    GPIO_PinModeSet(LEUART0_PORT, LEUART0_TX, gpioModePushPull, 1);    GPIO_PinModeSet(LEUART0_PORT, LEUART0_RX, gpioModeInputPull, 1);    lineEndReceived = xSemaphoreCreateBinary();    DMADRV_AllocateChannel(&dmaChannel, NULL);}
开发者ID:PW-Sat2,项目名称:PWSat2OBC,代码行数:33,


示例15: esp_bt_controller_init

esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg){    BaseType_t ret;    if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {        return ESP_ERR_INVALID_STATE;    }    if (cfg == NULL) {        return ESP_ERR_INVALID_ARG;    }    btdm_init_sem = xSemaphoreCreateBinary();    if (btdm_init_sem == NULL) {        return ESP_ERR_NO_MEM;    }    memcpy(&btdm_cfg_opts, cfg, sizeof(esp_bt_controller_config_t));    ret = xTaskCreatePinnedToCore(bt_controller_task, "btController",                            ESP_TASK_BT_CONTROLLER_STACK, NULL,                            ESP_TASK_BT_CONTROLLER_PRIO, &btControllerTaskHandle, CONFIG_BTDM_CONTROLLER_RUN_CPU);    if (ret != pdPASS) {        memset(&btdm_cfg_opts, 0x0, sizeof(esp_bt_controller_config_t));        vSemaphoreDelete(btdm_init_sem);        return ESP_ERR_NO_MEM;    }    xSemaphoreTake(btdm_init_sem, BTDM_INIT_PERIOD/portTICK_PERIOD_MS);    vSemaphoreDelete(btdm_init_sem);    return ESP_OK;}
开发者ID:Exchizz,项目名称:esp-idf,代码行数:34,


示例16: ws2812_setColors

void ws2812_setColors(uint16_t length, rgbVal *array){  uint16_t i;  ws2812_len = (length * 3) * sizeof(uint8_t);  ws2812_buffer = malloc(ws2812_len);  for (i = 0; i < length; i++) {    ws2812_buffer[0 + i * 3] = array[i].g;    ws2812_buffer[1 + i * 3] = array[i].r;    ws2812_buffer[2 + i * 3] = array[i].b;  }  ws2812_pos = 0;  ws2812_half = 0;  ws2812_copy();  if (ws2812_pos < ws2812_len)    ws2812_copy();  ws2812_sem = xSemaphoreCreateBinary();  RMT.conf_ch[RMTCHANNEL].conf1.mem_rd_rst = 1;  RMT.conf_ch[RMTCHANNEL].conf1.tx_start = 1;  xSemaphoreTake(ws2812_sem, portMAX_DELAY);  vSemaphoreDelete(ws2812_sem);  ws2812_sem = NULL;  free(ws2812_buffer);  return;}
开发者ID:wouterdevinck,项目名称:clonos-knob-firmware,代码行数:35,


示例17: mac_init

void mac_init(void){#ifdef NODE_TYPE_DETECTOR    lora_init(UART_4, 9600);#endif    #ifdef NODE_TYPE_GATEWAY    lora_init(UART_1, 9600);#endif        portBASE_TYPE res = pdTRUE;    res = xTaskCreate(mac_task,                   //*< task body                      "MacTask",                  //*< task name                      200,                        //*< task heap                      NULL,                       //*< tasK handle param                      configMAX_PRIORITIES - 2,   //*< task prio                      NULL);                      //*< task pointer    if (res != pdTRUE)    {        DBG_LOG(DBG_LEVEL_ERROR, "mac task init failed/r/n");    }    mac_queue = xQueueCreate(10, sizeof(osel_event_t));    if (mac_queue == NULL)    {        DBG_LOG(DBG_LEVEL_ERROR, "mac_queue init failed/r/n");    }    mac_sent = xSemaphoreCreateBinary();    if (mac_sent == NULL)    {        DBG_LOG(DBG_LEVEL_ERROR, "mac_set init failed/r/n");    }}
开发者ID:utopiaprince,项目名称:esn,代码行数:35,


示例18: main

int main(){    //unsigned int delay_1 = 5000, delay_2 = 4000;    bsp_init();    xSemaphore = xSemaphoreCreateBinary();    /* Create the tasks defined within this file. */    //xTaskCreate(CDecoder, "CDecoder", configMINIMAL_STACK_SIZE, NULL, 4, NULL );    //xTaskCreate(loop_test_01, "loop_test_01", configMINIMAL_STACK_SIZE, (void*)&delay_1, 6, NULL );    //xTaskCreate(loop_test_02, "loop_test_02", configMINIMAL_STACK_SIZE, (void*)&delay_2, 3, NULL );    xTaskCreate(led_update, "led_update", configMINIMAL_STACK_SIZE, NULL, 3, &xHandle[led_task] );    xTaskCreate(key_scan, "key_scan", configMINIMAL_STACK_SIZE, NULL, 5, &xHandle[key_task] );    xTaskCreate(audio_play, "audio_play", configMINIMAL_STACK_SIZE, NULL, 4, &xHandle[audio_task] );        /* In this port, to use preemptive scheduler define configUSE_PREEMPTION	as 1 in portmacro.h.  To use the cooperative scheduler define	configUSE_PREEMPTION as 0. */    vTaskStartScheduler();             // RunSchedular fail!!    while(1)    {    	reset_watchdog();      }        return 0;}
开发者ID:Alicia29,项目名称:TOY,代码行数:29,


示例19: main

/**@brief Function for application main entry. */int main(void){    // Do not start any interrupt that uses system functions before system initialisation.    // The best solution is to start the OS before any other initalisation.    // Init a semaphore for the BLE thread.    m_ble_event_ready = xSemaphoreCreateBinary();    if(NULL == m_ble_event_ready)    {        APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);    }    // Start execution.    if(pdPASS != xTaskCreate(ble_stack_thread, "BLE", 256, NULL, 1, &m_ble_stack_thread))    {        APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);    }    /* Activate deep sleep mode */    SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;    // Start FreeRTOS scheduler.    vTaskStartScheduler();    while (true)    {        APP_ERROR_HANDLER(NRF_ERROR_FORBIDDEN);    }}
开发者ID:IOIOI,项目名称:nRF51,代码行数:31,


示例20: I2C_Master_Initialise

/****************************************************************************Call this function to set up the TWI master to its initial standby state.Remember to enable interrupts from the main application after initialising the TWI.****************************************************************************/void I2C_Master_Initialise( uint8_t I2C_ownAddress ){	// The Semaphore has to be created to allow the I2C bus to be shared.	// Assuming the I2C bus will be shared.	// Use this semaphore  (take, give) when calling I2C functions, and it can ensure single access.    if( xI2CSemaphore == NULL ) 					// Check to see if the semaphore has not been created.    {		xI2CSemaphore = xSemaphoreCreateBinary();	// binary semaphore for I2C bus		if( ( xI2CSemaphore ) != NULL )			xSemaphoreGive( ( xI2CSemaphore ) );	// make the I2C bus available    }	I2C_PORT_DIR &= ~(I2C_BIT_SCL | I2C_BIT_SDA);	// set the I2C SDA & SCL inputs.													// Pull up resistors	I2C_PORT |= (I2C_BIT_SCL | I2C_BIT_SDA);		// only need these set at one place, usually Master.													// Initialise TWI clock    TWSR = 0;                         				// no prescaler    TWBR = ((F_CPU/SCL_CLOCK)-16)/2;  				// must be > 10 for stable operation	TWAR = I2C_ownAddress;                     		// Set own TWI slave address, in case it is called.													// Accept TWI General Calls if ODD address.	TWDR = 0xff;                               		// Default content = SDA released.	TWCR = (1<<TWEN)|                           	// Enable TWI-interface and release TWI pins.		   (0<<TWIE)|(0<<TWINT)|                	// Disable Interrupt.		   (0<<TWEA)|(0<<TWSTA)|(0<<TWSTO)|     	// No Signal requests.		   (0<<TWWC);}
开发者ID:boutboutnico,项目名称:Arduino_HW_lib,代码行数:34,


示例21: rsa_isr_initialise

static void rsa_isr_initialise(){    if (op_complete_sem == NULL) {        op_complete_sem = xSemaphoreCreateBinary();        esp_intr_alloc(ETS_RSA_INTR_SOURCE, 0, rsa_complete_isr, NULL, NULL);    }}
开发者ID:jchunhua163,项目名称:esp-idf-zh,代码行数:7,


示例22: TASK_SPI

void TASK_SPI( void *pvParameters ){    UNUSED( pvParameters );    spi_configureLED();        /* Create a semaphore */    rxSemaphoreLED = xSemaphoreCreateBinary();    /* Ensure that semaphore is valid */    Assert( rxSemaphoreLED );    /* Start DMA reception */    dma_start_transfer_job( &zDMA_LEDResourceRx );    for(;;)    {        /* Block task until DMA read complete */        xSemaphoreTake( rxSemaphoreLED, portMAX_DELAY );        /* Do something */        /* Respond..? */        dma_start_transfer_job( &zDMA_LEDResourceTx );        /* Yield to oncoming traffic */        taskYIELD();    }}
开发者ID:MDob,项目名称:Audio-Spectrum-Analyzer,代码行数:28,


示例23: vStartUART_NAVITask

void vStartUART_NAVITask(unsigned portBASE_TYPE uxPriority){	/* Creating semaphore related to this task */	xSemaphoreUART_NAVIRX = NULL;	xSemaphoreUART_NAVIRX = xSemaphoreCreateBinary();	xSemaphoreUART_NAVITX = NULL;	xSemaphoreUART_NAVITX = xSemaphoreCreateMutex();	/* Creating queue which is responsible for handling IMU_t typedef data */	xQueueUART_1xIMU_t = xQueueCreate(1, sizeof(IMU_t) );	/* Creating queue which is responsible for handling SENSOR_t typedef data */	xQueueUART_1xSENSOR_t = xQueueCreate(1, sizeof(SENSOR_t) );	/* Creating task [sending IMU data frames] 25 Hz task */	xTaskHandle xHandleTaskUART_NAVIimu;	xTaskCreate( vTaskUART_NAVIimu, "UART_NAVI_TXimu", configMINIMAL_STACK_SIZE,			NULL, uxPriority, &xHandleTaskUART_NAVIimu );	/* Creating task [sending SENSOR data frames] 10 Hz task*/	xTaskHandle xHandleTaskUART_NAVIsns;	xTaskCreate( vTaskUART_NAVIsns, "UART_NAVI_TXsns", configMINIMAL_STACK_SIZE,			NULL, uxPriority, &xHandleTaskUART_NAVIsns );}
开发者ID:torcek,项目名称:AUTOPILOT,代码行数:25,


示例24: lwip_network_init

void lwip_network_init(uint8_t opmode){    lwip_tcpip_config_t tcpip_config = {{0}, {0}, {0}, {0}, {0}, {0}};    ip4addr_aton(STA_IPADDR, &(tcpip_config.sta_addr));    ip4addr_aton(STA_NETMASK, &tcpip_config.sta_mask);    ip4addr_aton(STA_GATEWAY, &tcpip_config.sta_gateway);    ip4addr_aton(AP_IPADDR, &(tcpip_config.ap_addr));    ip4addr_aton(AP_NETMASK, &tcpip_config.ap_mask);    ip4addr_aton(AP_GATEWAY, &tcpip_config.ap_gateway);    wifi_connected = xSemaphoreCreateBinary();#if USE_DHCP    ip_ready = xSemaphoreCreateBinary();#endif    lwip_tcpip_init(&tcpip_config, opmode);}
开发者ID:Mediatek-Cloud,项目名称:mcs.c,代码行数:16,


示例25: main

int main(void){    // turn on the serial port for setting or querying the time .	xSerialPort = xSerialPortInitMinimal( USART0, 115200, portSERIAL_BUFFER_TX, portSERIAL_BUFFER_RX); //  serial port: WantedBaud, TxQueueLength, RxQueueLength (8n1)    // Memory shortages mean that we have to minimise the number of    // threads, hence there are no longer multiple threads using a resource.    // Still, semaphores are useful to stop a thread proceeding, where it should be stopped because it is using a resource.    if( xADCSemaphore == NULL ) 					// Check to see if the ADC semaphore has not been created.    {    	xADCSemaphore = xSemaphoreCreateBinary();	// binary semaphore for ADC - Don't sample temperature when hands are moving (voltage droop).		if( ( xADCSemaphore ) != NULL )			xSemaphoreGive( ( xADCSemaphore ) );	// make the ADC available    }	// initialise I2C master interface, need to do this once only.	// If there are two I2C processes, then do it during the system initiation.	I2C_Master_Initialise((ARDUINO<<I2C_ADR_BITS) | (pdTRUE<<I2C_GEN_BIT));	avrSerialxPrint_P(&xSerialPort, PSTR("/r/nHello World!/r/n")); // Ok, so we're alive...    xTaskCreate(		TaskWriteLCD		,  (const portCHAR *)"WriteLCD"		,  192		,  NULL		,  2		,  NULL ); // */   xTaskCreate(		TaskWriteRTCRetrograde		,  (const portCHAR *)"WriteRTCRetrograde"		,  120		,  NULL		,  1		,  &xTaskWriteRTCRetrograde ); // */   xTaskCreate(		TaskMonitor		,  (const portCHAR *)"SerialMonitor"		,  256		,  NULL		,  3		,  NULL ); // */	avrSerialPrintf_P(PSTR("/r/nFree Heap Size: %u/r/n"), xPortGetFreeHeapSize() ); // needs heap_1, heap_2 or heap_4 for this function to succeed.    vTaskStartScheduler();	avrSerialPrint_P(PSTR("/r/n/nGoodbye... no space for idle task!/r/n")); // Doh, so we're dead...#if defined (portHD44780_LCD)	lcd_Locate (0, 1);	lcd_Print_P(PSTR("DEAD BEEF!"));#endif}
开发者ID:niesteszeck,项目名称:avrfreertos,代码行数:59,


示例26: xTaskCreate

void ProgramManager::startManager(){  if(xManagerHandle == NULL)    xTaskCreate(runManagerTask, "Manager", MANAGER_TASK_STACK_SIZE, NULL, MANAGER_TASK_PRIORITY, &xManagerHandle);#if defined AUDIO_TASK_SEMAPHORE  if(xSemaphore == NULL)    xSemaphore = xSemaphoreCreateBinary();#endif // AUDIO_TASK_SEMAPHORE}
开发者ID:olilarkin,项目名称:OwlWare,代码行数:8,


示例27: watchdog_init

void watchdog_init( void ){    wdt_init();    wdt_config();    wdt_set_timeout(((WATCHDOG_TIMEOUT/1000)*WATCHDOG_CLK_FREQ));    watchdog_smphr = xSemaphoreCreateBinary();    xTaskCreate( WatchdogTask, (const char *) "Watchdog Task", 60, (void * ) NULL, tskWATCHDOG_PRIORITY, ( TaskHandle_t * ) NULL);}
开发者ID:lnls-dig,项目名称:openMMC,代码行数:8,


示例28: scheduler_task

periodicSchedulerTask::periodicSchedulerTask(void) :    scheduler_task("dispatcher", 512 * 3, PRIORITY_CRITICAL + PRIORITY_CRITICAL + 5){    setRunDuration(1);    setStatUpdateRate(0);    // Create the semaphores first before creating the actual periodic tasks    sems[prd_1Hz] = xSemaphoreCreateBinary();    sems[prd_10Hz] = xSemaphoreCreateBinary();    sems[prd_100Hz] = xSemaphoreCreateBinary();    sems[prd_1000Hz] = xSemaphoreCreateBinary();    // Create the FreeRTOS tasks, these will only run once we start giving their semaphores    xTaskCreate(period_task_1Hz, "1Hz", PERIOD_TASKS_STACK_SIZE_BYTES/4, NULL, PRIORITY_CRITICAL + 1, NULL);    xTaskCreate(period_task_10Hz, "10Hz", PERIOD_TASKS_STACK_SIZE_BYTES/4, NULL, PRIORITY_CRITICAL + 2, NULL);    xTaskCreate(period_task_100Hz, "100Hz", PERIOD_TASKS_STACK_SIZE_BYTES/4, NULL, PRIORITY_CRITICAL + 3, NULL);    xTaskCreate(period_task_1000Hz, "1000Hz", PERIOD_TASKS_STACK_SIZE_BYTES/4, NULL, PRIORITY_CRITICAL + 4, NULL);}
开发者ID:chen0510566,项目名称:Self-Driving-Car-1,代码行数:18,


示例29: ivory_freertos_binary_semaphore_create

void ivory_freertos_binary_semaphore_create(struct binary_semaphore* bs_handle) {	bs_handle->v = xSemaphoreCreateBinary();	if ( bs_handle->v == NULL ) {		/* Die: semaphore not created successfully */		ASSERTS(0);	}}
开发者ID:GaloisInc,项目名称:ivory-tower-stm32,代码行数:9,


示例30: prvTestAbortingSemaphoreTake

static void prvTestAbortingSemaphoreTake( void ){TickType_t xTimeAtStart;BaseType_t xReturn;SemaphoreHandle_t xSemaphore;	#if( configSUPPORT_STATIC_ALLOCATION == 1 )	{		static StaticSemaphore_t xSemaphoreBuffer;		/* Create the semaphore.  Statically allocated memory is used so the		creation cannot fail. */		xSemaphore = xSemaphoreCreateBinaryStatic( &xSemaphoreBuffer );	}	#else	{		xSemaphore = xSemaphoreCreateBinary();	}	#endif	/* Note the time before the delay so the length of the delay is known. */	xTimeAtStart = xTaskGetTickCount();	/* This first delay should just time out. */	xReturn = xSemaphoreTake( xSemaphore, xMaxBlockTime );	if( xReturn != pdFALSE )	{		xErrorOccurred = pdTRUE;	}	prvCheckExpectedTimeIsWithinAnAcceptableMargin( xTimeAtStart, xMaxBlockTime );	/* Note the time before the delay so the length of the delay is known. */	xTimeAtStart = xTaskGetTickCount();	/* This second delay should be aborted by the primary task half way	through. */	xReturn = xSemaphoreTake( xSemaphore, xMaxBlockTime );	if( xReturn != pdFALSE )	{		xErrorOccurred = pdTRUE;	}	prvCheckExpectedTimeIsWithinAnAcceptableMargin( xTimeAtStart, xHalfMaxBlockTime );	/* Note the time before the delay so the length of the delay is known. */	xTimeAtStart = xTaskGetTickCount();	/* This third delay should just time out again. */	xReturn = xSemaphoreTake( xSemaphore, xMaxBlockTime );	if( xReturn != pdFALSE )	{		xErrorOccurred = pdTRUE;	}	prvCheckExpectedTimeIsWithinAnAcceptableMargin( xTimeAtStart, xMaxBlockTime );	/* Not really necessary in this case, but for completeness. */	vSemaphoreDelete( xSemaphore );}
开发者ID:bryanclark90,项目名称:Autonomous-Car,代码行数:57,



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


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