当前位置: 首页>>代码示例>>C++>>正文


C++ xSemaphoreCreateBinary函数代码示例

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


在下文中一共展示了xSemaphoreCreateBinary函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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,代码来源:sensors_mpu9250_lps25h.c

示例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,代码来源:main.c

示例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,代码来源:sensors_bmi088_bmp388.c

示例4: xSemaphoreCreateBinary

bool example_alarm::init(void)
{
    mAlarmSec = xSemaphoreCreateBinary();
    mAlarmMin = xSemaphoreCreateBinary();

    return (mAlarmSec != NULL && mAlarmMin != NULL);
}
开发者ID:PWDawgy,项目名称:lpc1758_freertos,代码行数:7,代码来源:examples.cpp

示例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,代码来源:semtest.c

示例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,代码来源:Globales.c

示例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,代码来源:examples.cpp

示例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,代码来源:power-management-comms.c

示例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,代码来源:ipc.c

示例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,代码来源:Application.c

示例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,代码来源:systemLedTask.c

示例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,代码来源:buttonTask.c

示例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,代码来源:i2c_base.cpp

示例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,代码来源:leuart.cpp

示例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,代码来源:bt.c


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