void main_full( void ) { TimerHandle_t 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, "Reg1", configMINIMAL_STACK_SIZE, ( void * ) NULL, tskIDLE_PRIORITY, NULL ); xTaskCreate( vRegTest2Task, "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( "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( ;; ); }
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 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); } } }
void soundInit(void) { if (isInit) return; neffect = sizeof(effects)/sizeof(effects[0])-1; timer = xTimerCreate("SoundTimer", M2T(10), pdTRUE, NULL, soundTimer); xTimerStart(timer, 100); isInit = true; }
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); } } }
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); } } }
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"); } } }
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); } } }
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); } } }
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); } } }
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 ); }
uint32_t app_timer_start(app_timer_id_t timer_id, uint32_t timeout_ticks, void * p_context) { app_timer_info_t * pinfo = (app_timer_info_t*)(timer_id); TimerHandle_t hTimer = pinfo->osHandle; uint32_t rtc_prescaler = portNRF_RTC_REG->PRESCALER + 1; /* Get back the microseconds to wait */ uint32_t timeout_corrected = ROUNDED_DIV(timeout_ticks * m_prescaler, rtc_prescaler); if (hTimer == NULL) { return NRF_ERROR_INVALID_STATE; } if (pinfo->active && (xTimerIsTimerActive(hTimer) != pdFALSE)) { // Timer already running - exit silently return NRF_SUCCESS; } pinfo->argument = p_context; if (__get_IPSR() != 0) { BaseType_t yieldReq = pdFALSE; if (xTimerChangePeriodFromISR(hTimer, timeout_corrected, &yieldReq) != pdPASS) { return NRF_ERROR_NO_MEM; } if ( xTimerStartFromISR(hTimer, &yieldReq) != pdPASS ) { return NRF_ERROR_NO_MEM; } portYIELD_FROM_ISR(yieldReq); } else { if (xTimerChangePeriod(hTimer, timeout_corrected, APP_TIMER_WAIT_FOR_QUEUE) != pdPASS) { return NRF_ERROR_NO_MEM; } if (xTimerStart(hTimer, APP_TIMER_WAIT_FOR_QUEUE) != pdPASS) { return NRF_ERROR_NO_MEM; } } pinfo->active = true; return NRF_SUCCESS; }
void startProductionControl(){ // Initialize xpre and xhat int i; for(i = 0; i < 4; ++i){ plantParams.xpre[i] = 0.; // precomputed state vector plantParams.xhat[i] = 0.; // state vector [theta, alpha, thetadot, alphadot] } plantParams.cycle_count = 0; // Make sure tick_count is set to 1000 so that each tick is 1 millisecond as seen bellow ProductionControlTimer = xTimerCreate((const signed char *)"Production Controller Timer",1,pdTRUE,(void *) NULL, production_control_timer); xTimerStart(ProductionControlTimer, 0); xil_printf("Production Controller Timer started\n"); }
wiced_result_t wiced_rtos_start_timer( wiced_timer_t* timer ) { if ( xTimerReset( timer->handle, WICED_WAIT_FOREVER ) != pdPASS ) { return WICED_ERROR; } if ( xTimerStart( timer->handle, WICED_WAIT_FOREVER ) != pdPASS ) { return WICED_ERROR; } return WICED_SUCCESS; }
void APP_Initialize ( void ) { /* Place the App state machine in its initial state. */ appData.state = APP_STATE_INIT; /* TODO: Initialize your application's state machine and other * parameters. */ // uart initialization // The following code snippet shows an example USART driver initialization. // The driver is initialized for normal mode and a baud of 300. The // receive queue size is set to 2 and transmit queue size is set to 3. usartInit.baud = 57600; usartInit.mode = DRV_USART_OPERATION_MODE_NORMAL; usartInit.flags = DRV_USART_INIT_FLAG_NONE; usartInit.usartID = USART_ID_1; usartInit.brgClock = 80000000; usartInit.handshake = DRV_USART_HANDSHAKE_NONE; usartInit.lineControl = DRV_USART_LINE_CONTROL_8NONE1; usartInit.interruptError = INT_SOURCE_USART_1_ERROR; usartInit.interruptReceive = INT_SOURCE_USART_1_RECEIVE; usartInit.queueSizeReceive = 2; usartInit.queueSizeTransmit = 3; usartInit.interruptTransmit = INT_SOURCE_USART_1_TRANSMIT; usartInit.moduleInit.value = SYS_MODULE_POWER_RUN_FULL; // objectHandle = DRV_USART_Initialize(DRV_USART_INDEX_1, (SYS_MODULE_INIT*)&usartInit); // if (SYS_MODULE_OBJ_INVALID == objectHandle) // { // // Handle error // } handle = DRV_USART_Open(DRV_USART_INDEX_0, DRV_IO_INTENT_NONBLOCKING | DRV_IO_INTENT_WRITE); if (DRV_HANDLE_INVALID == handle) { // Unable to open the driver // May be the driver is not initialized or the initialization // is not complete. } // timer setup xTimer = xTimerCreate("Timer", 10, pdTRUE, 0, vTimerCallback); xTimerStart(xTimer, 0); vTaskStartScheduler(); }
void lineTimerCallback( TimerHandle_t pxTimer ) { outputEvent(LINE_READING_START); if(!wait) if( xTimerStart( lineTimer, 0 ) != pdPASS ) outputEvent(LINETIMER_NOT_STARTED); //Set Pins to digital output and HIGH SYS_PORTS_PinDirectionSelect(PORTS_ID_0, SYS_PORTS_DIRECTION_OUTPUT, PORT_CHANNEL_B, PORTS_BIT_POS_11); SYS_PORTS_PinDirectionSelect(PORTS_ID_0, SYS_PORTS_DIRECTION_OUTPUT, PORT_CHANNEL_B, PORTS_BIT_POS_12); SYS_PORTS_PinDirectionSelect(PORTS_ID_0, SYS_PORTS_DIRECTION_OUTPUT, PORT_CHANNEL_B, PORTS_BIT_POS_13); SYS_PORTS_PinDirectionSelect(PORTS_ID_0, SYS_PORTS_DIRECTION_OUTPUT, PORT_CHANNEL_G, PORTS_BIT_POS_8); SYS_PORTS_PinDirectionSelect(PORTS_ID_0, SYS_PORTS_DIRECTION_OUTPUT, PORT_CHANNEL_A, PORTS_BIT_POS_10); SYS_PORTS_PinDirectionSelect(PORTS_ID_0, SYS_PORTS_DIRECTION_OUTPUT, PORT_CHANNEL_F, PORTS_BIT_POS_0); SYS_PORTS_PinDirectionSelect(PORTS_ID_0, SYS_PORTS_DIRECTION_OUTPUT, PORT_CHANNEL_F, PORTS_BIT_POS_1); SYS_PORTS_PinDirectionSelect(PORTS_ID_0, SYS_PORTS_DIRECTION_OUTPUT, PORT_CHANNEL_D, PORTS_BIT_POS_6); SYS_PORTS_PinSet(PORTS_ID_0, PORT_CHANNEL_B, PORTS_BIT_POS_11); SYS_PORTS_PinSet(PORTS_ID_0, PORT_CHANNEL_B, PORTS_BIT_POS_13); SYS_PORTS_PinSet(PORTS_ID_0, PORT_CHANNEL_B, PORTS_BIT_POS_12); SYS_PORTS_PinSet(PORTS_ID_0, PORT_CHANNEL_G, PORTS_BIT_POS_8); SYS_PORTS_PinSet(PORTS_ID_0, PORT_CHANNEL_A, PORTS_BIT_POS_10); SYS_PORTS_PinSet(PORTS_ID_0, PORT_CHANNEL_F, PORTS_BIT_POS_0); SYS_PORTS_PinSet(PORTS_ID_0, PORT_CHANNEL_F, PORTS_BIT_POS_1); SYS_PORTS_PinSet(PORTS_ID_0, PORT_CHANNEL_D, PORTS_BIT_POS_6); //Start timer to charge cap and read data validData = false; if( xTimerStart( readTimer, 0 ) != pdPASS ){ outputEvent(READTIMER_NOT_STARTED); } }
int main(void) { initx(); xTimerHandle timer = xTimerCreate((const signed char *) "timer", 1000 / portTICK_RATE_MS, pdTRUE, NULL, toggleLedCallback); send_string_uart("timer created\n"); queue = xQueueCreate(20, 1); xTaskCreate(acceleration_task, (signed char*)"acceleration_task", 128, NULL, tskIDLE_PRIORITY+1, NULL); send_string_uart("queue created\n"); xTimerStart(timer, 0); send_string_uart("timer started\n"); send_string_uart("INIT DONE, Starting\n"); vTaskStartScheduler(); return 0; }
void vModeAstroStart(uint8_t motor_mask, uint8_t dir, float_t gear, float_t fact) { if (state != MODE_ASTRO_STATE_STOP) return; taskENTER_CRITICAL(); { state = MODE_ASTRO_STATE_WAKE_SM; motors = motor_mask; direction = dir; gear_reduction = gear; factor = fact; xTimerStart(xModeAstroControlTimer, 0); } taskEXIT_CRITICAL(); }
void main_blinky( void ) { xTimerHandle xTimer; xQueueHandle xQueue; /* Create the queue. */ xQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( unsigned long ) ); if( xQueue != NULL ) { /* Start the two tasks as described in the comments at the top of this file. */ xTaskCreate( prvQueueReceiveTask, /* The function that implements the task. */ ( signed char * ) "Rx", /* The text name assigned to the task - for debug only as it is not used by the kernel. */ configMINIMAL_STACK_SIZE, /* The size of the stack to allocate to the task. */ ( void * ) xQueue, /* Pass the queue into the task using the task parameter. */ mainQUEUE_RECEIVE_TASK_PRIORITY, /* The priority assigned to the task. */ NULL ); /* The task handle is not required, so NULL is passed. */ xTaskCreate( prvQueueSendTask, ( signed char * ) "TX", configMINIMAL_STACK_SIZE, ( void * ) xQueue, mainQUEUE_SEND_TASK_PRIORITY, NULL ); /* Create the blinky software timer as described at the top of this file. */ xTimer = xTimerCreate( ( const signed char * ) "Blinky",/* A text name, purely to help debugging. */ ( mainBLINKY_TIMER_PERIOD ), /* The timer period. */ 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. */ prvBlinkyTimerCallback ); /* The callback function that inspects the status of all the other tasks. */ configASSERT( xTimer ); if( xTimer != NULL ) { xTimerStart( xTimer, mainDONT_BLOCK ); } /* Start the tasks and timer running. */ 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( ;; ); }
void main(void) { xTimerHandle xTimer; /* Turn all LEDs off. */ vParTestInitialise(); /* Create the queue. */ xQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( unsigned long ) ); /* Create the software timer, as described at the top of this file. */ xTimer = xTimerCreate( "BlinkyTimer", /* Just a text name to make debugging easier - not used by the scheduler. */ mainSOFTWARE_TIMER_PERIOD_MS, /* The timer period. */ pdTRUE, /* Set to pdTRUE for periodic timer, or pdFALSE for one-shot timer. */ NULL, /* The timer ID is not required. */ prvBlinkyTimerCallback ); /* The function executed when the timer expires. */ if( xTimer != NULL ) { /* Start the timer - it will not actually start running until the scheduler has started. The block time is set to 0, although, because xTimerStart() is being called before the scheduler has been started, the any block time specified would be ignored anyway. */ xTimerStart( xTimer, 0UL ); } if( xQueue != NULL ) { /* Start the two tasks as described at the top of this file. */ xTaskCreate( prvQueueReceiveTask, /* The function that implements the task. */ "Rx", /* Just a text name to make debugging easier - not used by the scheduler. */ configMINIMAL_STACK_SIZE, /* The size of the task stack, in words. */ NULL, /* The task parameter is not used. */ configQUEUE_RECEIVE_TASK_PRIORITY, /* The priority assigned to the task when it is created. */ NULL ); /* The task handle is not used. */ xTaskCreate( prvQueueSendTask, "TX", configMINIMAL_STACK_SIZE, NULL, configQUEUE_SEND_TASK_PRIORITY, NULL ); /* Start the tasks running. */ vTaskStartScheduler(); } /* If all is well we will never reach here as the scheduler will now be running. If we do reach here then it is likely that there was insufficient heap available for the idle task to be created. */ for( ;; ); }
void vFullDemoIdleHook( void ) { static TimerHandle_t xCheckTimer = NULL; if( xCheckTimer == NULL ) { /* Create the software timer that performs the 'check' functionality, in the full demo. This is not done before the scheduler is started as to do so would prevent the standard demo timer tasks from passing their tests (they expect the timer command queue to be empty. */ xCheckTimer = xTimerCreate( "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 ); } /* Also start some timers that just flash LEDs. */ vStartLEDFlashTimers( mainNUM_FLASH_TIMER_LEDS ); } /* If the file system is only going to be accessed from one task then F_FS_THREAD_AWARE can be set to 0 and the set of example files is created before the RTOS scheduler is started. If the file system is going to be access from more than one task then F_FS_THREAD_AWARE must be set to 1 and the set of sample files are created from the idle task hook function. */ #if( F_FS_THREAD_AWARE == 1 ) { static portBASE_TYPE xCreatedSampleFiles = pdFALSE; /* Initialise the drive and file system, then create a few example files. The output from this function just goes to the stdout window, allowing the output to be viewed when the UDP command console is not connected. */ if( xCreatedSampleFiles == pdFALSE ) { vCreateAndVerifySampleFiles(); xCreatedSampleFiles = pdTRUE; } } #endif }
extern "C" int main(void) { #if !defined(ARDUINO) // To use Teensy 3.0 without Arduino, simply put your code here. // For example: pinMode(13, OUTPUT); serial.begin(9600); while (1) { digitalWriteFast(13, HIGH); delay(500); digitalWriteFast(13, LOW); delay(500); } #else #ifdef TEENSY_FREERTOS pinMode(13, OUTPUT); pinMode(12, OUTPUT); xTaskCreate( prvQueueReceiveTask, "Rx", configMINIMAL_STACK_SIZE, NULL, mainQUEUE_RECEIVE_TASK_PRIORITY, NULL ); xTaskCreate( UARTLogTask, "ULog", configMINIMAL_STACK_SIZE, NULL, UARTLog_Task_Priority, NULL ); xLEDTimer = xTimerCreate( "LEDTimer", /* A text name, purely to help debugging. */ ( mainLED_TIMER_PERIOD_MS ), /* The timer period, in this case 5000ms (5s). */ pdTRUE, /* This is a one shot timer, so xAutoReload is set to pdFALSE. */ ( void * ) 0, /* The ID is not used, so can be set to anything. */ prvLEDTimerCallback /* The callback function that switches the LED off. */ ); xTimerStart( xLEDTimer, mainDONT_BLOCK ); vTaskStartScheduler(); #else // Arduino's main() function just calls setup() and loop().... setup(); while (1) { loop(); yield(); } #endif /* TEENSY_FREERTOS */ #endif }
void IIS328DQ::start() { /* make sure we are stopped first */ //stop(); /* reset the report ring */ ringbuf_flush(_reports); /* start polling at the specified rate */ int ticks = USEC2TICK(_call_interval); if(ticks == 0) ticks = 1;//定时器时间间隔不可为0 /* reset the report ring and state machine */ _call = xTimerCreate("accel timer", USEC2TICK(_call_interval), pdTRUE, this, &IIS328DQ::measure_trampoline); xTimerStart(_call, portMAX_DELAY); }
/** * @brief Begin connect to MQTT broker * @param client: MQTT_Client reference * @retval None */ void ICACHE_FLASH_ATTR MQTT_Connect(MQTT_Client *mqttClient) { if (mqttClient->pCon) { // Clean up the old connection forcefully - using MQTT_Disconnect // does not actually release the old connection until the // disconnection callback is invoked. mqtt_tcpclient_delete(mqttClient); } mqttClient->pCon = (struct espconn *)calloc(1, sizeof(struct espconn)); mqttClient->pCon->type = ESPCONN_TCP; mqttClient->pCon->state = ESPCONN_NONE; mqttClient->pCon->proto.tcp = (esp_tcp *)calloc(1, sizeof(esp_tcp)); mqttClient->pCon->proto.tcp->local_port = espconn_port(); mqttClient->pCon->proto.tcp->remote_port = mqttClient->port; mqttClient->pCon->reserve = mqttClient; espconn_regist_connectcb(mqttClient->pCon, mqtt_tcpclient_connect_cb); espconn_regist_reconcb(mqttClient->pCon, mqtt_tcpclient_recon_cb); mqttClient->keepAliveTick = 0; mqttClient->reconnectTick = 0; xTimerReset(mqttClient->mqttTimer, portMAX_DELAY); xTimerStart(mqttClient->mqttTimer, portMAX_DELAY); if (UTILS_StrToIP(mqttClient->host, &mqttClient->pCon->proto.tcp->remote_ip)) { INFO("TCP: Connect to ip %s:%d\r\n", mqttClient->host, mqttClient->port); if (mqttClient->security) { #ifdef MQTT_SSL_ENABLE espconn_secure_connect(mqttClient->pCon); #else INFO("TCP: Do not support SSL\r\n"); #endif } else { espconn_connect(mqttClient->pCon); } } else { INFO("TCP: Connect to domain %s:%d\r\n", mqttClient->host, mqttClient->port); espconn_gethostbyname(mqttClient->pCon, mqttClient->host, &mqttClient->ip, mqtt_dns_found); } mqttClient->connState = TCP_CONNECTING; }
void vModeSmsStartExposeNow(void) { if (state != MODE_SMS_STATE_STOP) return; taskENTER_CRITICAL(); { test_mode = mode_smsTEST_EXPOSE_NOW; current_step = 0; current_loop = 0; step_timer = 0; interval_timer = 0; state = MODE_SMS_STATE_WAIT_PRE_TIME; xTimerStart(xModeSmsControlTimer, 0); } taskEXIT_CRITICAL(); }
void task_starttimer(void* p) { TimerHandle_t t = xTimerCreate("Toggle LED timer", pdMS_TO_TICKS(500), pdTRUE, NULL, ToggleLEDTimer); if (t == NULL) { ESP_LOGE(tag, "Unable to create timer"); } else { ESP_LOGI(tag, "Timer created"); xTimerStart(t, 1); } while (1) { vTaskDelay(pdMS_TO_TICKS(20000)); } }
int main( void ) { prvInitializeExceptions(); /* Create Binary Semaphore */ vSemaphoreCreateBinary(xSemaphore_led); configASSERT( xSemaphore_led ); /* Setup the GPIO Hardware. */ prvSetGpioHardware(); /* Create the task */ xTaskCreate( prvLed_Task, ( signed char * ) "LED_TASK", configMINIMAL_STACK_SIZE, NULL, mainLED_TASK_PRIORITY, &xTask ); /* Create timer. Starting the timer before the scheduler has been started means the timer will start running immediately that the scheduler starts. */ xTimer = xTimerCreate ( (const signed char *) "LedTimer", TIMER_PERIOD, pdTRUE, /* auto-reload when expires */ (void *) TIMER_ID, /* unique id */ vTimerCallback /* Callback */ ); if ( xTimer == NULL ) { /* The timer was not created. */ xil_printf("Failed to create timer\n\r"); prvShutdown(); return 0; } else { /* Start the timer */ xTimerStart( xTimer, 0 ); } /* Starting the scheduler will start the timers running as it is already been set into the active state. */ vTaskStartScheduler(); /* Should not reach here. */ for( ;; ); }
void sw_timers_init(void) { //for(u8 i=0; i<2; i++) //{ xTimers[0] = xTimerCreate ( /* Just a text name, not used by the RTOS kernel. */ "Timer", /* The timer period in ticks. */ ( 250 * 1 ), /* The timers will auto-reload themselves when they expire. */ pdTRUE, /* Assign each timer a unique id equal to its array index. */ ( void * ) 0, /* Each timer calls the same callback when it expires. */ vTimerCallback ); //} xTimers[1] = xTimerCreate ( /* Just a text name, not used by the RTOS kernel. */ "Timer", /* The timer period in ticks. */ ( 250 * 2 ), /* The timers will auto-reload themselves when they expire. */ pdTRUE, /* Assign each timer a unique id equal to its array index. */ ( void * ) 1, /* Each timer calls the same callback when it expires. */ vTimerCallback ); #if 0 if( xTimers != NULL ) { if( xTimerStart( xTimers, 0 ) != pdPASS ) { /* The timer could not be set into the Active state. */ } } #endif }
/** * \brief Main code entry point. */ int main( void ) { xTimerHandle xMonitorTimer; /* Prepare the hardware */ prvSetupHardware(); /* Init Prime Stack */ vPrimeStackInitTask(); /* Configure console */ configure_dbg_console(); puts(STRING_HEADER); /* Debug port for AppEmu */ if (!pio_get(PIN_APPEMU_PIO, PIN_APPEMU_TYPE, PIN_APPEMU_MASK)) { /* Init AppEmu Application */ vAppEmuInitTask(); } /* Create timer to monitor tasks execution */ xMonitorTimer = xTimerCreate( (const signed char *const)"Monitor timer", SIGNALLING_TIMER_RATE, pdTRUE, NULL, _prime_signalling ); configASSERT(xMonitorTimer); xTimerStart(xMonitorTimer, SIGNALLING_TIMER_RATE); /* Start the tasks and timer running. */ 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 (;;) { } }
static void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len, void * priv, unsigned long src) { if ((*(int *) data) == SHUTDOWN_MSG) { remoteproc_resource_deinit(proc); #ifdef USE_FREERTOS int TempTimerId; stop_scheduler = xTimerCreate("TMR", DELAY_200MSEC, pdFALSE, (void *)&TempTimerId, StopSchedulerTmrCallBack); xTimerStart(stop_scheduler, 0); #endif }else{ recv_mat_data.data = data; recv_mat_data.length = len; #ifdef USE_FREERTOS xQueueSend(mat_mul_queue , &recv_mat_data, portMAX_DELAY ); #else pq_enqueue(mat_mul_queue, &recv_mat_data); #endif } }