Advertisement
KiviE

main.c

Aug 26th, 2015
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.74 KB | None | 0 0
  1. static void Test3(void *pParameters)
  2. {
  3.     tm* time = (tm*) pParameters;
  4.     for (;;)
  5.     {
  6.         vTaskSuspendAll();
  7.         TickType_t xLastWakeTime = xTaskGetTickCount();
  8.         unsigned int ms_left = microcontroller_burtc_get_alarm_time(time);
  9.  
  10.         TaskHandle_t handle = xTaskGetCurrentTaskHandle();
  11.         char* name = pcTaskGetTaskName(handle);
  12.  
  13.         char str[50];
  14.                 sprintf(str, "%s ms: %u tickCount %u", name, ms_left, (unsigned int) xLastWakeTime);
  15.             log_debug(str);
  16.             microcontroller_burtc_busy_wait(2);
  17.         xTaskResumeAll();
  18.         vTaskDelayUntil(&xLastWakeTime, ms_left * 1.024);
  19.         log_debug(name);
  20.         microcontroller_burtc_busy_wait(2); // time for log to finish writing...
  21.     }
  22. }
  23.  
  24. static void Test4(void *pParameters)
  25. {
  26.     tm* time = (tm*) pParameters;
  27.     for (;;)
  28.     {
  29.         vTaskSuspendAll();
  30.         TickType_t xLastWakeTime = xTaskGetTickCount();
  31.         unsigned int ms_left = microcontroller_burtc_get_alarm_time(time);
  32.  
  33.         TaskHandle_t handle = xTaskGetCurrentTaskHandle();
  34.         char* name = pcTaskGetTaskName(handle);
  35.  
  36.         char str[50];
  37.                 sprintf(str, "%s ms: %u tickCount %u", name, ms_left, (unsigned int) xLastWakeTime);
  38.             log_debug(str);
  39.             microcontroller_burtc_busy_wait(2);
  40.         xTaskResumeAll();
  41.         vTaskDelayUntil(&xLastWakeTime, ms_left * 1.024);
  42.         log_debug(name);
  43.         gpsmodule_task_store_and_collect_position_and_synchronize();
  44.         microcontroller_burtc_busy_wait(2); // time for log to finish writing...
  45.     }
  46. }
  47.  
  48. //--------------------------------------------------------------------------------------------------
  49. int main()
  50. {
  51.     init();
  52.  
  53.     log_debug("test");
  54.  
  55.     // FREERTOS
  56.     SLEEP_Init(NULL, NULL);
  57.  
  58. #if (configSLEEP_MODE < 3)
  59.   /* do not let to sleep deeper than define */
  60.   SLEEP_SleepBlockBegin((SLEEP_EnergyMode_t)(configSLEEP_MODE+1));
  61. #endif
  62.  
  63.     // tm is defined as { hour, minute, second, millisecond }
  64.     static tm s_time1 = { -1, 0, 0, 118};
  65.     //static tm s_time1 = { -1, 18, 0, 0};
  66.     xTaskCreate(Test4, (const char *) "T1", STACK_SIZE_FOR_TASK, &s_time1, TASK_PRIORITY, NULL);
  67.  
  68.     static tm s_time2 = { -1, 3, 0, 117};
  69.     xTaskCreate(Test3, (const char *) "T2", STACK_SIZE_FOR_TASK, &s_time2, TASK_PRIORITY, NULL);
  70.  
  71.     static tm s_time3 = { -1, 3, 0, 247};
  72.     xTaskCreate(Test3, (const char *) "T3", STACK_SIZE_FOR_TASK, &s_time3, TASK_PRIORITY, NULL);
  73.  
  74.     static tm s_time4 = { -1, 3, 0, 372};
  75.     xTaskCreate(Test3, (const char *) "T4", STACK_SIZE_FOR_TASK, &s_time4, TASK_PRIORITY, NULL);
  76.  
  77.     static tm s_time5 = { -1, 9, 4, 410};
  78.     xTaskCreate(Test3, (const char *) "T5", STACK_SIZE_FOR_TASK, &s_time5, TASK_PRIORITY, NULL);
  79.  
  80.     static tm s_time6 = { -1, 9, 4, 535};
  81.     xTaskCreate(Test3, (const char *) "T6", STACK_SIZE_FOR_TASK, &s_time6, TASK_PRIORITY, NULL);
  82.  
  83.     static tm s_time7 = { -1, 10, 0, 117};
  84.     xTaskCreate(Test3, (const char *) "T7", STACK_SIZE_FOR_TASK, &s_time7, TASK_PRIORITY, NULL);
  85.  
  86.     static tm s_time8 = { -1, 10, 0, 247};
  87.     xTaskCreate(Test3, (const char *) "T8", STACK_SIZE_FOR_TASK, &s_time8, TASK_PRIORITY, NULL);
  88.  
  89.     static tm s_time9 = { -1, 10, 50, 276};
  90.     xTaskCreate(Test3, (const char *) "T9", STACK_SIZE_FOR_TASK, &s_time9, TASK_PRIORITY, NULL);
  91.  
  92.     static tm s_time15 = { -1, 13, 47, 120};
  93.     xTaskCreate(Test3, (const char *) "T10", STACK_SIZE_FOR_TASK, &s_time15, TASK_PRIORITY, NULL);
  94.  
  95.     static tm s_time10 = { -1, 14, 48, 80};
  96.     xTaskCreate(Test3, (const char *) "T11", STACK_SIZE_FOR_TASK, &s_time10, TASK_PRIORITY, NULL);
  97.  
  98.     static tm s_time11 = { -1, 14, 48, 120};
  99.     xTaskCreate(Test3, (const char *) "T12", STACK_SIZE_FOR_TASK, &s_time11, TASK_PRIORITY, NULL);
  100.  
  101.     static tm s_time12 = { -1, 14, 48, 542};
  102.     xTaskCreate(Test3, (const char *) "T13", STACK_SIZE_FOR_TASK, &s_time12, TASK_PRIORITY, NULL);
  103.  
  104.     static tm s_time13 = { -1, 14, 49, 169};
  105.     xTaskCreate(Test3, (const char *) "T14", STACK_SIZE_FOR_TASK, &s_time13, TASK_PRIORITY, NULL);
  106.  
  107.     static tm s_time14 = { -1, 14, 49, 601};
  108.     xTaskCreate(Test3, (const char *) "T15", STACK_SIZE_FOR_TASK, &s_time14, TASK_PRIORITY, NULL);
  109.  
  110.     static tm s_time16 = { -1, 21, 50, 401};
  111.     xTaskCreate(Test3, (const char *) "T16", STACK_SIZE_FOR_TASK, &s_time16, TASK_PRIORITY, NULL);
  112.  
  113.     static tm s_time17 = { -1, 31, 50, 401};
  114.     xTaskCreate(Test3, (const char *) "T17", STACK_SIZE_FOR_TASK, &s_time17, TASK_PRIORITY, NULL);
  115.  
  116.     static tm s_time18 = { -1, 41, 50, 401};
  117.     xTaskCreate(Test3, (const char *) "T18", STACK_SIZE_FOR_TASK, &s_time18, TASK_PRIORITY, NULL);
  118.  
  119.     static tm s_time19 = { -1, 51, 50, 401};
  120.     xTaskCreate(Test3, (const char *) "T19", STACK_SIZE_FOR_TASK, &s_time19, TASK_PRIORITY, NULL);
  121.  
  122.     log_debug("19");
  123.  
  124.     /*Start FreeRTOS Scheduler*/
  125.     gpsmodule_task_store_and_collect_position_and_synchronize();
  126.     vTaskStartScheduler();
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement