Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Test3(void *pParameters)
- {
- tm* time = (tm*) pParameters;
- for (;;)
- {
- vTaskSuspendAll();
- TickType_t xLastWakeTime = xTaskGetTickCount();
- unsigned int ms_left = microcontroller_burtc_get_alarm_time(time);
- TaskHandle_t handle = xTaskGetCurrentTaskHandle();
- char* name = pcTaskGetTaskName(handle);
- char str[50];
- sprintf(str, "%s ms: %u tickCount %u", name, ms_left, (unsigned int) xLastWakeTime);
- log_debug(str);
- microcontroller_burtc_busy_wait(2);
- xTaskResumeAll();
- vTaskDelayUntil(&xLastWakeTime, ms_left * 1.024);
- log_debug(name);
- microcontroller_burtc_busy_wait(2); // time for log to finish writing...
- }
- }
- static void Test4(void *pParameters)
- {
- tm* time = (tm*) pParameters;
- for (;;)
- {
- vTaskSuspendAll();
- TickType_t xLastWakeTime = xTaskGetTickCount();
- unsigned int ms_left = microcontroller_burtc_get_alarm_time(time);
- TaskHandle_t handle = xTaskGetCurrentTaskHandle();
- char* name = pcTaskGetTaskName(handle);
- char str[50];
- sprintf(str, "%s ms: %u tickCount %u", name, ms_left, (unsigned int) xLastWakeTime);
- log_debug(str);
- microcontroller_burtc_busy_wait(2);
- xTaskResumeAll();
- vTaskDelayUntil(&xLastWakeTime, ms_left * 1.024);
- log_debug(name);
- gpsmodule_task_store_and_collect_position_and_synchronize();
- microcontroller_burtc_busy_wait(2); // time for log to finish writing...
- }
- }
- //--------------------------------------------------------------------------------------------------
- int main()
- {
- init();
- log_debug("test");
- // FREERTOS
- SLEEP_Init(NULL, NULL);
- #if (configSLEEP_MODE < 3)
- /* do not let to sleep deeper than define */
- SLEEP_SleepBlockBegin((SLEEP_EnergyMode_t)(configSLEEP_MODE+1));
- #endif
- // tm is defined as { hour, minute, second, millisecond }
- static tm s_time1 = { -1, 0, 0, 118};
- //static tm s_time1 = { -1, 18, 0, 0};
- xTaskCreate(Test4, (const char *) "T1", STACK_SIZE_FOR_TASK, &s_time1, TASK_PRIORITY, NULL);
- static tm s_time2 = { -1, 3, 0, 117};
- xTaskCreate(Test3, (const char *) "T2", STACK_SIZE_FOR_TASK, &s_time2, TASK_PRIORITY, NULL);
- static tm s_time3 = { -1, 3, 0, 247};
- xTaskCreate(Test3, (const char *) "T3", STACK_SIZE_FOR_TASK, &s_time3, TASK_PRIORITY, NULL);
- static tm s_time4 = { -1, 3, 0, 372};
- xTaskCreate(Test3, (const char *) "T4", STACK_SIZE_FOR_TASK, &s_time4, TASK_PRIORITY, NULL);
- static tm s_time5 = { -1, 9, 4, 410};
- xTaskCreate(Test3, (const char *) "T5", STACK_SIZE_FOR_TASK, &s_time5, TASK_PRIORITY, NULL);
- static tm s_time6 = { -1, 9, 4, 535};
- xTaskCreate(Test3, (const char *) "T6", STACK_SIZE_FOR_TASK, &s_time6, TASK_PRIORITY, NULL);
- static tm s_time7 = { -1, 10, 0, 117};
- xTaskCreate(Test3, (const char *) "T7", STACK_SIZE_FOR_TASK, &s_time7, TASK_PRIORITY, NULL);
- static tm s_time8 = { -1, 10, 0, 247};
- xTaskCreate(Test3, (const char *) "T8", STACK_SIZE_FOR_TASK, &s_time8, TASK_PRIORITY, NULL);
- static tm s_time9 = { -1, 10, 50, 276};
- xTaskCreate(Test3, (const char *) "T9", STACK_SIZE_FOR_TASK, &s_time9, TASK_PRIORITY, NULL);
- static tm s_time15 = { -1, 13, 47, 120};
- xTaskCreate(Test3, (const char *) "T10", STACK_SIZE_FOR_TASK, &s_time15, TASK_PRIORITY, NULL);
- static tm s_time10 = { -1, 14, 48, 80};
- xTaskCreate(Test3, (const char *) "T11", STACK_SIZE_FOR_TASK, &s_time10, TASK_PRIORITY, NULL);
- static tm s_time11 = { -1, 14, 48, 120};
- xTaskCreate(Test3, (const char *) "T12", STACK_SIZE_FOR_TASK, &s_time11, TASK_PRIORITY, NULL);
- static tm s_time12 = { -1, 14, 48, 542};
- xTaskCreate(Test3, (const char *) "T13", STACK_SIZE_FOR_TASK, &s_time12, TASK_PRIORITY, NULL);
- static tm s_time13 = { -1, 14, 49, 169};
- xTaskCreate(Test3, (const char *) "T14", STACK_SIZE_FOR_TASK, &s_time13, TASK_PRIORITY, NULL);
- static tm s_time14 = { -1, 14, 49, 601};
- xTaskCreate(Test3, (const char *) "T15", STACK_SIZE_FOR_TASK, &s_time14, TASK_PRIORITY, NULL);
- static tm s_time16 = { -1, 21, 50, 401};
- xTaskCreate(Test3, (const char *) "T16", STACK_SIZE_FOR_TASK, &s_time16, TASK_PRIORITY, NULL);
- static tm s_time17 = { -1, 31, 50, 401};
- xTaskCreate(Test3, (const char *) "T17", STACK_SIZE_FOR_TASK, &s_time17, TASK_PRIORITY, NULL);
- static tm s_time18 = { -1, 41, 50, 401};
- xTaskCreate(Test3, (const char *) "T18", STACK_SIZE_FOR_TASK, &s_time18, TASK_PRIORITY, NULL);
- static tm s_time19 = { -1, 51, 50, 401};
- xTaskCreate(Test3, (const char *) "T19", STACK_SIZE_FOR_TASK, &s_time19, TASK_PRIORITY, NULL);
- log_debug("19");
- /*Start FreeRTOS Scheduler*/
- gpsmodule_task_store_and_collect_position_and_synchronize();
- vTaskStartScheduler();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement