Exemple #1
0
void main_full( void )
{
xTimerHandle xCheckTimer = NULL;

	/* Start all the other standard demo/test tasks.  The have not particular
	functionality, but do demonstrate how to use the FreeRTOS API and test the
	kernel port. */
	vStartIntegerMathTasks( tskIDLE_PRIORITY );
	vStartDynamicPriorityTasks();
	vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
	vCreateBlockTimeTasks();
	vStartCountingSemaphoreTasks();
	vStartGenericQueueTasks( tskIDLE_PRIORITY );
	vStartRecursiveMutexTasks();
	vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
	vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
	vStartMathTasks( mainFLOP_TASK_PRIORITY );
	
	/* Create the register check tasks, as described at the top of this
	file */
	xTaskCreate( vRegTest1Task, ( signed char * ) "Reg1", configMINIMAL_STACK_SIZE, ( void * ) NULL, tskIDLE_PRIORITY, NULL );
	xTaskCreate( vRegTest2Task, ( signed char * ) "Reg2", configMINIMAL_STACK_SIZE, ( void * ) NULL, tskIDLE_PRIORITY, NULL );

	/* Create the software timer that performs the 'check' functionality,
	as described at the top of this file. */
	xCheckTimer = xTimerCreate( ( const signed char * ) "CheckTimer",/* A text name, purely to help debugging. */
								( mainCHECK_TIMER_PERIOD_MS ),		/* The timer period, in this case 3000ms (3s). */
								pdTRUE,								/* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */
								( void * ) 0,						/* The ID is not used, so can be set to anything. */
								prvCheckTimerCallback				/* The callback function that inspects the status of all the other tasks. */
							  );	
	
	if( xCheckTimer != NULL )
	{
		xTimerStart( xCheckTimer, mainDONT_BLOCK );
	}

	/* The set of tasks created by the following function call have to be 
	created last as they keep account of the number of tasks they expect to see 
	running. */
	vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );

	/* Start the scheduler. */
	vTaskStartScheduler();
	
	/* If all is well, the scheduler will now be running, and the following line
	will never be reached.  If the following line does execute, then there was
	insufficient FreeRTOS heap memory available for the idle and/or timer tasks
	to be created.  See the memory management section on the FreeRTOS web site
	for more details. */
	for( ;; )
	{
		__asm volatile( "NOP" );
	}
}
static void buzzerInit(DeckInfo *info)
{
  piezoInit();

  neffect = sizeof(effects)/sizeof(effects[0])-1;
  nmelody = sizeof(melodies)/sizeof(melodies[0])-1;

  timer = xTimerCreate( "buzztimer", M2T(10),
                                     pdTRUE, NULL, buzzTimer );
  xTimerStart(timer, 100);
}
// Initializes timer to specified period in ms
void timer_initialize(int ms)
{
    TimerHandle_t myTimer1;
    myTimer1 = xTimerCreate("test",
                           (ms/portTICK_PERIOD_MS),
                           pdTRUE, 
                           (void *)0,
                           timerCallback);
    if (xTimerStart(myTimer1,10) == pdFAIL)
        error('a');
}
FreeRTOSTimer::FreeRTOSTimer(tmrTIMER_CALLBACK pFunction, TIME_MS t, TimerType type)
{
	// xTimerCreate() copies the pointer for the name, so the tName variable
	// cannot simply be on the stack, it should be global or static
	static signed char tName[] = "Tmr";

	mTimerHandle = xTimerCreate(tName, OS_MS(t),
								type == TimerOneShot ? pdFALSE : pdTRUE,
								0,
								pFunction);
}
Exemple #5
0
/// Create a timer.
/// \param[in]     timer_def     timer object referenced with \ref osTimer.
/// \param[in]     type          osTimerOnce for one-shot or osTimerPeriodic for periodic behavior.
/// \param[in]     argument      argument to the timer call back function.
/// \return timer ID for reference by other functions or NULL in case of error.
/// \note MUST REMAIN UNCHANGED: \b osTimerCreate shall be consistent in every CMSIS-RTOS.
osTimerId osTimerCreate (const osTimerDef_t *timer_def, os_timer_type type, void *argument)
{
    timer_def->custom->argument = argument;

    return xTimerCreate((const portCHAR *)"",
                        1,  //Set later when timer is started
                        (type == osTimerPeriodic) ? pdTRUE : pdFALSE,
                        (void *)timer_def,
                        _osTimerCallbackFreeRTOS
                        );
}
Exemple #6
0
void vTask4(void *pvParameters) {
	// Remove compiler warnings.
	(void) pvParameters;
	
	xTimer1 = xTimerCreate( "Timer 1",( 4000 ), pdTRUE,( void * ) 41, vTimerCallback1);
	xTimerStart(xTimer1,0);
	
	vTaskDelay(2000);
	xTimer2 = xTimerCreate( "Timer 2",( 4000 ), pdTRUE,( void * ) 42, vTimerCallback2);
	xTimerStart(xTimer2,0);
	
	vTaskDelay(1000);
	xTimer3 = xTimerCreate( "Timer 3",( 2000 ), pdTRUE,( void * ) 43, vTimerCallback3);
	xTimerStart(xTimer3,0);
	
	while (1) {
		vTaskSuspend(NULL);
	}
	vTaskDelete(NULL);
}
Exemple #7
0
static void prvOptionallyCreateComprehensveTestApplication( void )
{
	#if ( mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY == 0 )
	{
	xTimerHandle xCheckTimer = NULL;

		/* Start all the other standard demo/test tasks. */
		vStartIntegerMathTasks( tskIDLE_PRIORITY );
		vStartDynamicPriorityTasks();
		vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
		vCreateBlockTimeTasks();
		vStartCountingSemaphoreTasks();
		vStartGenericQueueTasks( tskIDLE_PRIORITY );
		vStartRecursiveMutexTasks();
		vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
		vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );

		/* Most importantly, start the tasks that use the FPU. */
		vStartMathTasks( mainFLOP_TASK_PRIORITY );
		
		/* Create the register check tasks, as described at the top of this
		file */
		xTaskCreate( vRegTest1Task, ( signed char * ) "Reg1", configMINIMAL_STACK_SIZE, ( void * ) NULL, tskIDLE_PRIORITY, NULL );
		xTaskCreate( vRegTest2Task, ( signed char * ) "Reg2", configMINIMAL_STACK_SIZE, ( void * ) NULL, tskIDLE_PRIORITY, NULL );

		/* Create the software timer that performs the 'check' functionality,
		as described at the top of this file. */
		xCheckTimer = xTimerCreate( ( const signed char * ) "CheckTimer",/* A text name, purely to help debugging. */
									( mainCHECK_TIMER_PERIOD_MS ),		/* The timer period, in this case 3000ms (3s). */
									pdTRUE,								/* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */
									( void * ) 0,						/* The ID is not used, so can be set to anything. */
									prvCheckTimerCallback				/* The callback function that inspects the status of all the other tasks. */
								  );	
		
		if( xCheckTimer != NULL )
		{
			xTimerStart( xCheckTimer, mainDONT_BLOCK );
		}

		/* This task has to be created last as it keeps account of the number of
		tasks it expects to see running. */
		vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
	}
	#else /* mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY */
	{
		/* Just to prevent compiler warnings when the configuration options are
		set such that these static functions are not used. */
		( void ) vRegTest1Task;
		( void ) vRegTest2Task;
		( void ) prvCheckTimerCallback;
		( void ) prvSetupNestedFPUInterruptsTest;
	}
	#endif /* mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY */
}
Exemple #8
0
void APP_Initialize ( void )
{
    //stopEverything();
    /* Place the App state machine in its initial state. */
    appData.state = APP_STATE_INIT;
    
    /* TODO: Initialize your application's state machine and other
     * parameters.
     */
    //Create the queue
    appData.local_q = xQueueCreate(10, sizeof(unsigned int));
    //Ensure queue was created. If not, do not continue and turn on LED
    if(appData.local_q == 0)
    {
        stopEverything();
    }
    appData.sensor1_q = xQueueCreate(100, sizeof(unsigned char));
    if(appData.sensor1_q == 0)
    {
        stopEverything();
    }
    //stopEverything();
    //Create the timer
    appData.local_timer = xTimerCreate( "50msTimer",
                50 / portTICK_PERIOD_MS,
                pdTRUE,
                0,
                vTimerCallback );
    
    //Ensure timer was created. If not, do not continue and turn on LED
    if(appData.local_timer == 0)
    {
        stopEverything();
    }
    BaseType_t started = xTimerStart(appData.local_timer, 0);
    
    //Ensure the timer started successfully. If not, do not continue and turn
    // on LED
    if(started == pdFAIL)
    {
        stopEverything();
    }   
    
    //Setup AD Driver
    SYS_INT_SourceEnable(INT_SOURCE_ADC_1);
    DRV_ADC_Initialize();
    DRV_ADC_Open();
    DRV_ADC_ChannelScanInputsAdd(ADC_INPUT_SCAN_AN0 | ADC_INPUT_SCAN_AN1|ADC_INPUT_SCAN_AN2);
    PLIB_ADC_MuxAInputScanEnable(ADC_ID_1);
    DRV_ADC_Start();
    
    /* Initialization is done, allow the state machine to continue */
    appData.state = APP_STATE_OUTPUT;
}
Exemple #9
0
/**@brief Function for the Timer initialization.
 *
 * @details Initializes the timer module. This creates and starts application timers.
 */
static void timers_init(void)
{
    // Initialize timer module.
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);

    // Create timers.
    m_battery_timer        = xTimerCreate("BATT", BATTERY_LEVEL_MEAS_INTERVAL     , pdTRUE, NULL, battery_level_meas_timeout_handler     );
    m_heart_rate_timer     = xTimerCreate("HRT" , HEART_RATE_MEAS_INTERVAL        , pdTRUE, NULL, heart_rate_meas_timeout_handler        );
    m_rr_interval_timer    = xTimerCreate("RRT" , RR_INTERVAL_INTERVAL            , pdTRUE, NULL, rr_interval_timeout_handler            );
    m_sensor_contact_timer = xTimerCreate("SCT" , SENSOR_CONTACT_DETECTED_INTERVAL, pdTRUE, NULL, sensor_contact_detected_timeout_handler);

    /* Error checking */
    if( (NULL == m_battery_timer)
     || (NULL == m_heart_rate_timer)
     || (NULL == m_rr_interval_timer)
     || (NULL == m_sensor_contact_timer) )
    {
        APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
    }
}
Exemple #10
0
void ICACHE_FLASH_ATTR createTimer(char * ssid, char * pwd){
	sprintf(ssid_name, "%s\0", ssid);
	sprintf(password,"%s\0",pwd);
     xTimerHandle wifiTimer=xTimerCreate("r",200,pdFALSE, (void *)1,vTimerSCallback);
       if( xTimerStart( wifiTimer,0) == pdPASS )  {
          printf("timer STATION babe!!!!! \n");  
     }



}
void timer_initiaize_20(int ms){
        TimerHandle_t myTimer2;
    myTimer2 = xTimerCreate("test2",
                           (ms/portTICK_PERIOD_MS),
                           pdTRUE, 
                           (void *)0,
                           timerCallback_20);
    if (xTimerStart(myTimer2,10) == pdFAIL)
        error('a');
    
} 
Exemple #12
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main() {

    TimerHandle_t idTim1;
    idTim1=xTimerCreate("Timer1", 1000/portTICK_RATE_MS, pdTRUE, 0, led1_callback);
    xTimerStart(idTim1, 0);
    xTaskCreate(led2_thread, "Thread1", 1024, (void*) NULL, tskIDLE_PRIORITY + 1UL, NULL);

    vTaskStartScheduler();
    
    for(;;);
}
void queueMonitorInit() {
  ASSERT(!initialized);
  timer = xTimerCreate( "queueMonitorTimer", TIMER_PERIOD,
    pdTRUE, NULL, timerHandler );
  xTimerStart(timer, 100);

  data[0].fileName = "Na";
  data[0].queueName = "Na";

  initialized = true;
}
Exemple #14
0
static void prvInitialise_uIP( void )
{
uip_ipaddr_t xIPAddr;
xTimerHandle xARPTimer, xPeriodicTimer;

	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 queue used to sent TCP/IP events to the uIP stack. */
	xEMACEventQueue = xQueueCreate( uipEVENT_QUEUE_LENGTH, sizeof( unsigned long ) );

	/* Create and start the uIP timers. */
	xARPTimer = xTimerCreate( 	( signed char * ) "ARPTimer", /* Just a name that is helpful for debugging, not used by the kernel. */
								( 10000UL / portTICK_RATE_MS ), /* Timer period. */
								pdTRUE, /* Autor-reload. */
								( void * ) uipARP_TIMER,
								prvUIPTimerCallback
							);

	xPeriodicTimer = xTimerCreate( 	( signed char * ) "PeriodicTimer",
									( 500UL / portTICK_RATE_MS ),
									pdTRUE, /* Autor-reload. */
									( void * ) uipPERIODIC_TIMER,
									prvUIPTimerCallback
								);

	/* Sanity check that the timers were indeed created. */
	configASSERT( xARPTimer );
	configASSERT( xPeriodicTimer );
	configASSERT( xEMACEventQueue );

	/* These commands will block indefinitely until they succeed, so there is
	no point in checking their return values. */
	xTimerStart( xARPTimer, portMAX_DELAY );
	xTimerStart( xPeriodicTimer, portMAX_DELAY );
}
Exemple #15
0
void ad_rf_init(void)
{
        if (dg_configRF_RECALIBRATION_TIMER_TIMEOUT > 0) {
                /* Initialize timer */
                recalib_timer = xTimerCreate("RFRecalibTimer",
                        dg_configRF_RECALIBRATION_TIMER_TIMEOUT,
                        pdFALSE,
                        NULL,
                        recalib_timer_cb);
                OS_ASSERT(recalib_timer != NULL);
        }
}
static void setup_debug_tools()
{
        /* Only enable this code if we are doing debug work */
#if ! (ASL_DEBUG)
        return;
#endif
        const size_t timer_ticks = msToTicks(CHAR_CHECK_PERIOD_MS);
        const signed char* timer_name = (signed char*) "Dropped Char Check Timer";
        xTimerHandle timer_handle = xTimerCreate(timer_name, timer_ticks,
                                                 true, NULL, dropped_char_timer_cb);
        xTimerStart(timer_handle, timer_ticks);
}
Exemple #17
0
/**
* @brief  Create a timer.
* @param  timer_def     timer object referenced with \ref osTimer.
* @param  type          osTimerOnce for one-shot or osTimerPeriodic for periodic behavior.
* @param  argument      argument to the timer call back function.
* @retval  timer ID for reference by other functions or NULL in case of error.
* @note   MUST REMAIN UNCHANGED: \b osTimerCreate shall be consistent in every CMSIS-RTOS.
*/
osTimerId osTimerCreate (const osTimerDef_t *timer_def, os_timer_type type, void *argument)
{
#if (configUSE_TIMERS == 1)
  return xTimerCreate((const char *)"",
                      1, // period should be filled when starting the Timer using osTimerStart
                      (type == osTimerPeriodic) ? pdTRUE : pdFALSE,
                      (void *) argument,
                      (TaskFunction_t)timer_def->ptimer);
#else 
	return NULL;
#endif
}
Exemple #18
0
void SEND_Initialize ( void )
{
    sendData.state = SEND_STATE_INIT;
    sendData.sendCount = 0x55;
    sendData.testCount = 0;
    sendData.enqueueCount = 0;
    sendData.prevType = 'a';
    sendData.prevCount = 'a';
    
    strcpy(sendData.storedMessage, "~e8765432.");
    
    sendData.sendStoredMessage = 0;

    
    //Create a queue capable of holding 1000 characters
    sendData.transmitQ_SA = xQueueCreate( 1000, sizeof(char) );
    if( sendData.transmitQ_SA == 0 ) {
        dbgOutputVal(SEND_QUEUE_FAIL);
        stopAll();
    }
    
    // Create a queue capable of holding 250 messages
    sendData.sendQ_LR = xQueueCreate(250, MSG_LENGTH+1);
    if (sendData.sendQ_LR == 0) {
        dbgOutputVal(SEND_QUEUE_FAIL);
        stopAll();
    }
    
    //Create a timer
    sendData.sendTimer_SA = xTimerCreate(  
                     "SendTimer100ms", //Just a text name
                     ( 1000 / portTICK_PERIOD_MS ), //period is 100ms
                     pdTRUE, //auto-reload when expires
                     (void *) 24, //a unique id
                     sendTimerCallback ); //pointer to callback function
    
    
    //if SENSOR_DEBUG_NOACK is defined, then don't start the timer
    #ifndef SENSOR_DEBUG_NOACK
        //Start the timer
        if( sendData.sendTimer_SA == NULL ) {
            dbgOutputVal(SEND_TIMERINIT_FAIL);
            stopAll();
        }
        else if( xTimerStart( sendData.sendTimer_SA, 0 ) != pdPASS ) {
            dbgOutputVal(SEND_TIMERINIT_FAIL);
            stopAll();
        }
    #endif
    
     
}
void main( void )
{
	/* Configure the peripherals used by this demo application.  This includes
	configuring the joystick input select button to generate interrupts. */
	prvSetupHardware();

	/* Create the queue used by tasks and interrupts to send strings to the LCD
	task. */
	xLCDQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( xQueueMessage ) );

	/* If the queue could not be created then don't create any tasks that might
	attempt to use the queue. */
	if( xLCDQueue != NULL )
	{
		/* Create the standard demo tasks. */
		vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED );
		vStartDynamicPriorityTasks();
		vStartGenericQueueTasks( mainGENERIC_QUEUE_TEST_PRIORITY );
		vStartCountingSemaphoreTasks();
		
		/* Note that creating the timer test/demo tasks will fill the timer
		command queue.  This is intentional, and forms part of the test the tasks
		perform.  It does mean however that, after this function is called, no
		more timer commands can be sent until after the scheduler has been
		started (at which point the timer daemon will drained the timer command
		queue, freeing up space for more commands to be received). */
		vStartTimerDemoTask( mainTIMER_TEST_PERIOD );
		
		/* Create the LCD, button poll and register test tasks, as described at
		the top	of this	file. */
		xTaskCreate( prvLCDTask, ( signed char * ) "LCD", configMINIMAL_STACK_SIZE * 2, mainTASK_PARAMETER_CHECK_VALUE, mainLCD_TASK_PRIORITY, NULL );
		xTaskCreate( prvButtonPollTask, ( signed char * ) "BPoll", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
		xTaskCreate( vRegTest1Task, ( signed char * ) "Reg1", configMINIMAL_STACK_SIZE, NULL, 0, NULL );
		xTaskCreate( vRegTest2Task, ( signed char * ) "Reg2", configMINIMAL_STACK_SIZE, NULL, 0, NULL );

		/* Create the 'check' timer - the timer that periodically calls the
		check function as described at the top of this file.  Note that, for
		the reasons stated in the comments above the call to 
		vStartTimerDemoTask(), that the check timer is not actually started 
		until after the scheduler has been started. */
		xCheckTimer = xTimerCreate( ( const signed char * ) "Check timer", mainCHECK_TIMER_PERIOD, pdTRUE, ( void * ) 0, vCheckTimerCallback ); 

		/* Start the scheduler. */
		vTaskStartScheduler();
	}

	/* If all is well then this line will never be reached.  If it is reached
	then it is likely that there was insufficient (FreeRTOS) heap memory space
	to create the idle task.  This may have been trapped by the malloc() failed
	hook function, if one is configured. */	
	for( ;; );
}
Exemple #20
0
int main(void)
{
	int timerID = 1;
	int timerID1 = 2;

	/*A Timer used to count how long there is no signal come in*/
	xTimerNoSignal = xTimerCreate("TurnOffTime", 10000 / portTICK_RATE_MS, pdFALSE,  (void *) timerID, vTimerSystemIdle);

	xTimerSampleRate = xTimerCreate("SensorSampleRate", 4 / portTICK_RATE_MS, pdTRUE,  (void *) timerID1, vTimerSample);

	/*a queue for tansfer the senddate to USART task*/
	xQueueUARTSend = xQueueCreate(15, sizeof(serial_str_msg));
   	xQueueUARTRecvie = xQueueCreate(15, sizeof(serial_ch_msg));
   	xQueueShell2PWM = xQueueCreate(3, sizeof(pwm_ch_msg));

   	xQueuePitchdirection = xQueueCreate(3, sizeof(pitch_direction_msg));
   	xQueueRolldirection = xQueueCreate(3, sizeof(roll_direction_msg));

	/* initialize hardware... */
	prvSetupHardware();
	init_I2C1();
	xTimerStart(xTimerNoSignal, 0);


	/* Start the tasks defined within this file/specific to this demo. */
	xTaskCreate(vPWMctrlTask, ( signed portCHAR * ) "pwmctrl", configMINIMAL_STACK_SIZE, NULL,tskIDLE_PRIORITY, NULL );
	xTaskCreate(vUsartSendTask, ( signed portCHAR * ) "USART", configMINIMAL_STACK_SIZE, NULL,tskIDLE_PRIORITY, NULL);
	xTaskCreate(shell, ( signed portCHAR * ) "shell", configMINIMAL_STACK_SIZE, NULL,tskIDLE_PRIORITY + 5, NULL);
	xTaskCreate(vBalanceTask, ( signed portCHAR * ) "Balance", configMINIMAL_STACK_SIZE, NULL,tskIDLE_PRIORITY, NULL);

	xTaskCreate(vPitchctrlTask, ( signed portCHAR * ) "Pitchctrl", configMINIMAL_STACK_SIZE, NULL,tskIDLE_PRIORITY, NULL );
	xTaskCreate(vRollctrlTask, ( signed portCHAR * ) "Rollctrl", configMINIMAL_STACK_SIZE, NULL,tskIDLE_PRIORITY, NULL );

	/* Start the scheduler. */
	vTaskStartScheduler();

	/* Will only get here if there was not enough heap space to create the idle task. */
	return 0;  
}
Exemple #21
0
/**
 * @brief	The main task for the CAN2 channel
 * @param	pvParameters:
 * @retval	None
 */
void can2Task(void *pvParameters)
{
	/* Mutex semaphore to manage when it's ok to send and receive new data */
	xSemaphore = xSemaphoreCreateMutex();

	/* Mutex semaphore for accessing the settings for this channel */
	xSettingsSemaphore = xSemaphoreCreateMutex();

	/* Create software timers */
	prvBuffer1ClearTimer = xTimerCreate("Buf1ClearCan2", 10, pdFALSE, 0, prvBuffer1ClearTimerCallback);
	prvBuffer2ClearTimer = xTimerCreate("Buf2ClearCan2", 10, pdFALSE, 0, prvBuffer2ClearTimerCallback);

	/* Initialize hardware */
	prvHardwareInit();

	/* Wait to make sure the SPI FLASH is initialized */
	while (SPI_FLASH_Initialized() == false)
	{
		vTaskDelay(100 / portTICK_PERIOD_MS);
	}

	/* Try to read the settings from SPI FLASH */
	prvReadSettingsFromSpiFlash();

	can2Clear();

	/* The parameter in vTaskDelayUntil is the absolute time
	 * in ticks at which you want to be woken calculated as
	 * an increment from the time you were last woken. */
	TickType_t xNextWakeTime;
	/* Initialize xNextWakeTime - this only needs to be done once. */
	xNextWakeTime = xTaskGetTickCount();

	prvDoneInitializing = true;
	while (1)
	{
		vTaskDelayUntil(&xNextWakeTime, 1000 / portTICK_PERIOD_MS);
	}
}
Exemple #22
0
void ICACHE_FLASH_ATTR createTimerWifi(void){
	if(!restartActive){
	    restartActive=1;
             xTimerHandle wifiTimer2=xTimerCreate("s",200,pdFALSE, (void *)1,vTimerSACallback);
           if( xTimerStart( wifiTimer2,0) == pdPASS )  {
              printf("timer SOft AP babe!!!!! \n");  
           }


	}


}
static void prvInitialise_uIP( void )
{
    TimerHandle_t xARPTimer, xPeriodicTimer;
    uip_ipaddr_t xIPAddr;
    const unsigned long ul_uIPEventQueueLength = 10UL;

    /* Initialise the uIP stack. */
    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 queue used to sent TCP/IP events to the uIP stack. */
    xEMACEventQueue = xQueueCreate( ul_uIPEventQueueLength, sizeof( unsigned long ) );

    /* Create and start the uIP timers. */
    xARPTimer = xTimerCreate( 	"ARPTimer", /* Just a name that is helpful for debugging, not used by the kernel. */
                                ( 10000UL / portTICK_PERIOD_MS ), /* Timer period. */
                                pdTRUE, /* Autor-reload. */
                                ( void * ) uipARP_TIMER,
                                prvUIPTimerCallback
                            );

    xPeriodicTimer = xTimerCreate( 	"PeriodicTimer",
                                    ( 50 / portTICK_PERIOD_MS ),
                                    pdTRUE, /* Autor-reload. */
                                    ( void * ) uipPERIODIC_TIMER,
                                    prvUIPTimerCallback
                                 );

    configASSERT( xARPTimer );
    configASSERT( xPeriodicTimer );

    xTimerStart( xARPTimer, portMAX_DELAY );
    xTimerStart( xPeriodicTimer, portMAX_DELAY );
}
Exemple #24
0
void startTimerFori2c(myI2CStruct *i2cdata) {
	if (sizeof(long) != sizeof(myI2CStruct *)) {
		VT_HANDLE_FATAL_ERROR(TIMER_ERROR);
	}
	xTimerHandle i2cTimerHandle = xTimerCreate((const signed char *)"i2c Timer",i2cWRITE_RATE_BASE,pdTRUE,(void *) i2cdata,i2cTimerCallback);
	if (i2cTimerHandle == NULL) {
		VT_HANDLE_FATAL_ERROR(TIMER_ERROR);
	} else {
		if (xTimerStart(i2cTimerHandle,0) != pdPASS) {
			VT_HANDLE_FATAL_ERROR(TIMER_ERROR);
		}
	}
}
Exemple #25
0
void startTimerForNav(navigationStruct *navData){
	if (sizeof(long) != sizeof(navigationStruct *)) {
		VT_HANDLE_FATAL_ERROR(TIMER_ERROR);
	}
	xTimerHandle navTimerHandle = xTimerCreate((const signed char *)"Nav Timer",navWRITE_RATE_BASE,pdTRUE,(void *) navData,navTimerCallback);
	if (navTimerHandle == NULL) {
		VT_HANDLE_FATAL_ERROR(TIMER_ERROR);
	} else {
		if (xTimerStart(navTimerHandle,0) != pdPASS) {
			VT_HANDLE_FATAL_ERROR(TIMER_ERROR);
		}
	}
}
Exemple #26
0
void startTimerForMotor(motorControlStruct *motordata){
	if (sizeof(long) != sizeof(motorControlStruct *)) {
		VT_HANDLE_FATAL_ERROR(TIMER_ERROR);
	}
	xTimerHandle motorTimerHandle = xTimerCreate((const signed char *)"Motor Timer",motorWRITE_RATE_BASE,pdTRUE,(void *) motordata,motorTimerCallback);
	if (motorTimerHandle == NULL) {
		VT_HANDLE_FATAL_ERROR(TIMER_ERROR);
	} else {
		if (xTimerStart(motorTimerHandle,0) != pdPASS) {
			VT_HANDLE_FATAL_ERROR(TIMER_ERROR);
		}
	}
}
Exemple #27
0
void startTimerForTemperature(vtTempStruct *vtTempdata) {
	if (sizeof(long) != sizeof(vtTempStruct *)) {
		VT_HANDLE_FATAL_ERROR(0);
	}
	xTimerHandle TempTimerHandle = xTimerCreate((const signed char *)"Temp Timer",tempWRITE_RATE_BASE,pdTRUE,(void *) vtTempdata,TempTimerCallback);
	if (TempTimerHandle == NULL) {
		VT_HANDLE_FATAL_ERROR(0);
	} else {
		if (xTimerStart(TempTimerHandle,0) != pdPASS) {
			VT_HANDLE_FATAL_ERROR(0);
		}
	}
}
Exemple #28
0
void startTimerForADC(adcStruct *adcData) {
	if (sizeof(long) != sizeof(adcStruct *)) {
		VT_HANDLE_FATAL_ERROR(0);
	}
	xTimerHandle adcTimerHandle = xTimerCreate((const signed char *)"ADC Timer",adcWRITE_RATE_BASE,pdTRUE,(void *) adcData,adcTimerCallback);
	if (adcTimerHandle == NULL) {
		VT_HANDLE_FATAL_ERROR(0);
	} else {
		if (xTimerStart(adcTimerHandle,0) != pdPASS) {
			VT_HANDLE_FATAL_ERROR(0);
		}
	}
}
Exemple #29
0
void startTimerForLCD(vtLCDStruct *vtLCDdata) {
	if (sizeof(long) != sizeof(vtLCDStruct *)) {
		VT_HANDLE_FATAL_ERROR(0);
	}
	xTimerHandle LCDTimerHandle = xTimerCreate((const signed char *)"LCD Timer",lcdWRITE_RATE_BASE,pdTRUE,(void *) vtLCDdata,LCDTimerCallback);
	if (LCDTimerHandle == NULL) {
		VT_HANDLE_FATAL_ERROR(0);
	} else {
		if (xTimerStart(LCDTimerHandle,0) != pdPASS) {
			VT_HANDLE_FATAL_ERROR(0);
		}
	}
}
/*-------------------------------------------
| Name:rttmr_create
| Description:
| Parameters:
| Return Type:
| Comments:
| See:
---------------------------------------------*/
int rttmr_create(tmr_t* tmr,rttmr_attr_t* rttmr_attr){
   if(!tmr || !rttmr_attr)
      return -1;
#ifdef __KERNEL_UCORE_FREERTOS
   //OS_CreateTimer(tmr,rttmr_attr->func,rttmr_attr->tm_msec);
   xTimerCreate( "timer",
                (portTickType)(rttmr_attr->tm_msec/portTICK_RATE_MS),
                pdFALSE,
                tmr,
                (tmrTIMER_CALLBACK) rttmr_attr->func );
#endif
   return 0;
}