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


C++ xTaskGetSchedulerState函数代码示例

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


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

示例1: xSemaphoreTake

int CharDev::printf(const char *format, ...)
{
    if (taskSCHEDULER_RUNNING == xTaskGetSchedulerState()) {
        xSemaphoreTake(mPrintfSemaphore, portMAX_DELAY);
    }

        int len = 0;
        va_list args;
        va_start(args, format);

        do {
            va_list args_copy;
            va_copy(args_copy, args);
            len = vsnprintf(mpPrintfMem, mPrintfMemSize, format, args_copy);
            va_end(args_copy);

            if (len >= mPrintfMemSize) {
                const int align = 16;
                mPrintfMemSize = (align + ((len/align) * align));
                /* TO DO :
                 * Do not know why realloc() doesn't work.  It is a combination of C++ class
                 * use combined with va_args and realloc itself.  It seems to work in vector
                 * and str classes though.
                 */
                if (0) {
                    if (mpPrintfMem) {
                        free(mpPrintfMem);
                    }
                    mpPrintfMem = (char*) malloc(mPrintfMemSize);
                }
                else {
                    mpPrintfMem = (char*) realloc(mpPrintfMem, mPrintfMemSize);
                }
            }
            else {
                break;
            }
        } while (mpPrintfMem);

        va_end(args);
        this->put(mpPrintfMem);

    if (taskSCHEDULER_RUNNING == xTaskGetSchedulerState()) {
        xSemaphoreGive(mPrintfSemaphore);
    }

    return len;
}
开发者ID:dhruvkakadiya,项目名称:Self_Driving_Car_TopGun,代码行数:48,代码来源:char_dev.cpp

示例2: putChar

bool UartDev::putChar(char out, unsigned int timeout)
{
    /* If OS not running, just send data using polling and return */
    if (taskSCHEDULER_RUNNING != xTaskGetSchedulerState()) {
        mpUARTRegBase->THR = out;
        while(! (mpUARTRegBase->LSR & (1 << 6)));
        return true;
    }

    /* FreeRTOS running, so send to queue and if queue is full, return false */
    if(! xQueueSend(mTxQueue, &out, timeout)) {
        return false;
    }

    /* If transmitter is not busy, send out the oldest char from the queue,
     * and let the transmitter empty interrupt empty out the queue thereafter.
     */
    const int uart_tx_is_idle = (1 << 6);
    if (mpUARTRegBase->LSR & uart_tx_is_idle)
    {
        if (xQueueReceive(mTxQueue, &out, 0)) {
            mpUARTRegBase->THR = out;
        }
    }

    return true;
}
开发者ID:liveusr,项目名称:selfdriving,代码行数:27,代码来源:uart_dev.cpp

示例3: SDCardSendCommand

int SDCardSendCommand(uint8_t command, uint32_t param, uint8_t crc, void* buffer, size_t recvSize) {
	Chip_GPIO_SetPinState(LPC_GPIO, 0, 2, !Chip_GPIO_GetPinState(LPC_GPIO, 0, 2));
	if (xTaskGetSchedulerState() == taskSCHEDULER_RUNNING)
		xSemaphoreTake(xMutexSDCard, portMAX_DELAY);
	int result = SDCARD_ERROR_GENERIC;
	int wait = SDCARD_SPI_MAX_WAIT;
	int i;
	uint8_t read = 0;
	uint8_t* data = (uint8_t*) buffer;
	command += 0x40;
	SDCardSetSS();
	for (i = 0; i < SDCARD_IDLE_PRE_WAIT_ATTEMPTS; i++) {
		if (spi_transceive_byte(SDCARD_SPI_DEVICE, 0xff) == 0xff) break;
	}

	result = SDCARD_ERROR_TRANSMIT_INTERRUPTED;

	CommandBuffer[0] = command;
	CommandBuffer[1] = param >> 24;
	CommandBuffer[2] = param >> 16;
	CommandBuffer[3] = param >> 8;
	CommandBuffer[4] = param;
	CommandBuffer[5] = (crc_crc7(CommandBuffer, 5) << 1) | 1;

	spi_transceive(SDCARD_SPI_DEVICE, CommandBuffer, 6);

	for (i = 0; i < 6; i++) {
		if (CommandBuffer[i] != 0xff) {
//			MSS_GPIO_set_output(MSS_GPIO_27, 0);
			__asm volatile ("nop");
//			MSS_GPIO_set_output(MSS_GPIO_27, 1);
			goto fail;
		}
	}
开发者ID:jmeed,项目名称:teamRocket,代码行数:34,代码来源:sdcard.c

示例4: mmem_init

/**
 * \brief      Initialize the managed memory module
 * \author     Adam Dunkels
 *
 *             This function initializes the managed memory module and
 *             should be called before any other function from the
 *             module.
 *
 */
int
mmem_init(void)
{
	/* Only execute the initalisation before the scheduler was started.
	 * So there exists only one thread and
	 * no locking is needed for the initialisation
	 */
	configASSERT(xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED);

	/* cancle, if initialisation was already done */
	if(mutex != NULL) {
		return -1;
	}
	/* Do not use an recursive mutex,
	 * because mmem_check() will not work vital then.
	 */
	mutex = xSemaphoreCreateMutex();
	if(mutex == NULL) {
		return -2;
	}

	list_init(mmemlist);
	avail_memory = MMEM_SIZE;

	return 0;
}
开发者ID:twischer,项目名称:miniDTN,代码行数:35,代码来源:mmem.c

示例5: ASSERT

/*------------------------------------------------------------------------------
 * MSS_I2C_wait_complete()
 * See "mss_i2c.h" for details of how to use this function.
 */
mss_i2c_status_t MSS_I2C_wait_complete
(
    mss_i2c_instance_t * this_i2c
)
{
    ASSERT( (this_i2c == &g_mss_i2c0) || (this_i2c == &g_mss_i2c1) );

#ifdef USE_OLD_I2C_POLLING_CODE
    while ( this_i2c->status == MSS_I2C_IN_PROGRESS ) {
        /* Wait for transaction to compltete.*/
        ;
    }
#else
    configASSERT( ( this_i2c->xI2CCompleteSemaphore ) );
    if( xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED ) {
        while ( this_i2c->status == MSS_I2C_IN_PROGRESS ) {
            /* Wait for transaction to compltete.*/
            ;
        }
    } else {
        xSemaphoreTake( this_i2c->xI2CCompleteSemaphore, portMAX_DELAY );
    }
#endif

    return this_i2c->status;
}
开发者ID:peterliu2,项目名称:FreeRTOS,代码行数:30,代码来源:i2c.c

示例6: wireless_service

void wireless_service(void)
{
    /*
     * If FreeRTOS is running, then a task should be calling us, so we can block on
     * the nordic activity semaphore.
     *
     * There are three cases of block time :
     *  1 - If nordic interrupt signal is still pending, then we haven't read
     *      all Nordic FIFO, so we don't block on semaphore at all.
     *  2 - There are pending packets that need either ACK or retry, so we
     *      block just for one tick to carry out mesh logic.
     *  3 - No RX and no TX, so block until either a packet is sent, or until
     *      we receive a packet; both cases will give the semaphore.
     */
    if (taskSCHEDULER_RUNNING == xTaskGetSchedulerState()) {
        if (!nordic_intr_signal()) {
            const TickType_t blockTime = mesh_get_pnd_pkt_count() ? 1 : portMAX_DELAY;
            xSemaphoreTake(g_nrf_activity_sem, blockTime);
        }
        mesh_service();
    }
    /* A timer ISR is calling us, so we can't use FreeRTOS API, hence we poll */
    else {
        if (nordic_intr_signal() || mesh_get_pnd_pkt_count() > 0) {
            mesh_service();
        }
    }
}
开发者ID:PWDawgy,项目名称:lpc1758_freertos,代码行数:28,代码来源:wireless.c

示例7: SysTick_Handler

/**
  * @brief  This function handles SysTick Handler.
  * @param  None
  * @retval None
  */
void SysTick_Handler(void)
{
  if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED)
  {
    xPortSysTickHandler();
  }
}
开发者ID:EarnestHein89,项目名称:STM32Cube_FW_F4,代码行数:12,代码来源:stm32f4xx_it.c

示例8: while

char I2C_Base::writeReg(char deviceAddress, char registerAddress, char value)
{
    if(mDisableOperation) {
        return 0;
    }

    // If scheduler not running , perform polling transaction
    if(taskSCHEDULER_RUNNING != xTaskGetSchedulerState())
    {
        NVIC_DisableIRQ(mIRQ);
        {
            i2cKickOffTransfer(i2cWrite, deviceAddress, registerAddress, &value, 1);
            do {
                // Wait until SI flag is set, then call i2cStateMachine()
                while(! (mpI2CRegs->I2CONSET & (1 << 3)) )
                {
                    ;
                }
            }while (writeComplete != i2cStateMachine());
        }
        NVIC_EnableIRQ(mIRQ);
        return true;
    }

    // Wait for I2C Access, and just return, I2C Lock will be given by ISR()
    xSemaphoreTake(mI2CMutex, portMAX_DELAY);
    i2cKickOffTransfer(i2cWrite, deviceAddress, registerAddress, &value, 1);
    return 0;
}
开发者ID:montoya332,项目名称:Solar-Panel-Tracker,代码行数:29,代码来源:i2c_base.cpp

示例9: hl_periodic_service

/* If FreeRTOS is not running, then we rely on RIT service to call this function,
 * otherwise we rely on FreeRTOS tick hook to provide system timer
 */
static void hl_periodic_service(void)
{
    sys_watchdog_feed();

    /* If FreeRTOS is running, user should use a dedicated task to call mesh service,
     * so we will not call it if freertos is running
     */
    if (taskSCHEDULER_RUNNING == xTaskGetSchedulerState()) {
        g_system_uptime_ms += MS_PER_TICK();

        /* We don't need RIT if FreeRTOS is running */
        if (sys_rit_running()) {
            sys_rit_disable();

            /* The timer value so far may be an odd number, and if MS_PER_TICK() is not 1
             * then we may increment it like 12, 22, 32, etc. so round this number once.
             */
            g_system_uptime_ms = (g_system_uptime_ms / 10) * 10;
        }
    }
    else {
        g_system_uptime_ms += g_time_per_rit_isr_ms;
        wireless_service();

        /**
         * Small hack to support interrupts if FreeRTOS is not running :
         * FreeRTOS API resets our base priority register, then all
         * interrupts higher priority than IP_SYSCALL will not get locked out.
         *   @see more notes at isr_priorities.h.  @see IP_SYSCALL
         */
        __set_BASEPRI(0);
    }
}
开发者ID:Bento007,项目名称:SJSU-Superway-2014,代码行数:36,代码来源:high_level_init.cpp

示例10: __malloc_unlock

extern "C" void __malloc_unlock ( struct _reent *_r )
{
	if (xTaskGetSchedulerState() == taskSCHEDULER_RUNNING)		// don't release mutex if scheduler not started or suspended
	{
		mallocMutex.Release();
	}
}
开发者ID:dc42,项目名称:RepRapFirmware,代码行数:7,代码来源:Tasks.cpp

示例11: prvTraceIsSchedulerSuspended

unsigned char prvTraceIsSchedulerSuspended(void)
{
    /* Assumed to be available in FreeRTOS. According to the FreeRTOS docs, 
	INCLUDE_xTaskGetSchedulerState or configUSE_TIMERS must be set to 1 in
	FreeRTOSConfig.h for this function to be available. */

	return xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED;
}
开发者ID:ErichStyger,项目名称:McuOnEclipse_PEx,代码行数:8,代码来源:trcKernelPort.c

示例12: isFreeRtosRunning

char isFreeRtosRunning()
{
    if (!critialRegionSemaphore) {
        critialRegionSemaphore = xSemaphoreCreateMutex();
    }

    return (taskSCHEDULER_RUNNING == xTaskGetSchedulerState());
}
开发者ID:montoya332,项目名称:Solar-Panel-Tracker,代码行数:8,代码来源:utilities.cpp

示例13: ff_rel_grant

void ff_rel_grant (
	_SYNC_t sobj	/* Sync object to be signaled */
)
{
    if(taskSCHEDULER_RUNNING == xTaskGetSchedulerState())
    {
        xSemaphoreGive(sobj);	/* FreeRTOS */
    }
}
开发者ID:Bento007,项目名称:SJSU-Superway-2014,代码行数:9,代码来源:reentrant.c

示例14: __env_unlock

void __env_unlock ( struct _reent *_r )
{
#if OS_THREAD_SAFE_NEWLIB
	if (!xTaskGetSchedulerState())
		return;
	  
	xSemaphoreGiveRecursive(alt_envsem);
#endif /* OS_THREAD_SAFE_NEWLIB */
}
开发者ID:AlexShiLucky,项目名称:FreeLwIP-Nios-II,代码行数:9,代码来源:alt_env_lock.c

示例15: SysTick_Handler

/**
  * @brief  This function handles SysTick Handler.
  * @param  None
  * @retval None
  */
void SysTick_Handler (void)
{
  HAL_IncTick();
  if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED)
  {
    xPortSysTickHandler();
  }
  Toggle_Leds();
}
开发者ID:ClintHaerinck,项目名称:STM32Cube_FW_F4,代码行数:14,代码来源:stm32f4xx_it.c


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