示例#1
0
void setup(void)
{
    /* Start serial port at 9600 bps. */
    Serial.begin(9600);
    Serial.println("\n" RTOS_RTUINOS_STARTUP_MSG);

    /* All tasks are set up. */
    
    /* Task 0 of priority class 0 */
    rtos_initializeTask( /* idxTask */          0
                       , /* taskFunction */     task00_class00
                       , /* prioClass */        0
                       , /* pStackArea */       &_taskStack00_C0[0]
                       , /* stackSize */        sizeof(_taskStack00_C0)
                       , /* startEventMask */   RTOS_EVT_DELAY_TIMER
                       , /* startByAllEvents */ false
                       , /* startTimeout */     5
                       );

    /* Task 1 of priority class 0 */
    rtos_initializeTask( /* idxTask */          1
                       , /* taskFunction */     task01_class00
                       , /* prioClass */        0
                       , /* pStackArea */       &_taskStack01_C0[0]
                       , /* stackSize */        sizeof(_taskStack01_C0)
                       , /* startEventMask */   RTOS_EVT_DELAY_TIMER
                       , /* startByAllEvents */ false
                       , /* startTimeout */     15
                       );

    /* Task 0 of priority class 1 */
    rtos_initializeTask( /* idxTask */          2
                       , /* taskFunction */     task00_class01
                       , /* prioClass */        1
                       , /* pStackArea */       &_taskStack00_C1[0]
                       , /* stackSize */        sizeof(_taskStack00_C1)
                       , /* startEventMask */   RTOS_EVT_DELAY_TIMER
                       , /* startByAllEvents */ false
                       , /* startTimeout */     5
                       );
    
    /* Initialize the digital pin as an output. The LED is used for most basic feedback about
       operability of code. */
    pinMode(LED, OUTPUT);
    
} /* End of setup */
示例#2
0
void dcf_initializeTask(uint8_t idxTask, uint8_t prioClass)
{
#ifdef DEBUG
    printf( "Task time: %u us = %u tics\n"
          , (uint16_t)(1e6 * ACTUAL_TASK_TIME_IN_S + 0.5)
          , TASK_TIME_IN_TICS
          );
    printf( "A bit cycle needs to be in the range [%u, %u] tics = 1 s + [%i, %i] us\n"
          , MIN_LEN_BIT_CYCLE_IN_TICS, MAX_LEN_BIT_CYCLE_IN_TICS
          , (int16_t)(1e6*((float)MIN_LEN_BIT_CYCLE_IN_TICS*ACTUAL_TASK_TIME_IN_S - 1.0) + 0.5)
          , (int16_t)(1e6*((float)MAX_LEN_BIT_CYCLE_IN_TICS*ACTUAL_TASK_TIME_IN_S - 1.0) + 0.5)
          );
    printf( "A time telegram ends with a pause of at least %u tics.\n"
            "Pauses longer than %u * 0.1 ms could be recognized as end of telegram\n"
            "Pauses longer than %u * 0.1 ms are surely recognized as end of telegram\n"
          , MIN_PAUSE_AT_START_OF_MIN_IN_TICS
          , (uint16_t)(1e4*(float)(MIN_PAUSE_AT_START_OF_MIN_IN_TICS-1)
                       *ACTUAL_TASK_TIME_IN_S
                       + 0.5
                      )
          , (uint16_t)(1e4*(float)MIN_PAUSE_AT_START_OF_MIN_IN_TICS
                       *ACTUAL_TASK_TIME_IN_S
                       + 0.5
                      )
          );
    printf( "A null bit needs to be in the range [%u, %u] tics.\n"
            "Impulses in the range (%u, %u) * 0.1 ms could be recognized as null bit\n"
            "Impulses in the range (%u, %u) * 0.1 ms are surely recognized as null bit\n"
          , MIN_LEN_BIT_0_IN_TICS, MAX_LEN_BIT_0_IN_TICS
          , (uint16_t)(1e4*(float)(MIN_LEN_BIT_0_IN_TICS-1)*ACTUAL_TASK_TIME_IN_S + 0.5)
          , (uint16_t)(1e4*(float)(MAX_LEN_BIT_0_IN_TICS+1)*ACTUAL_TASK_TIME_IN_S + 0.5)
          , (uint16_t)(1e4*(float)MIN_LEN_BIT_0_IN_TICS*ACTUAL_TASK_TIME_IN_S + 0.5)
          , (uint16_t)(1e4*(float)MAX_LEN_BIT_0_IN_TICS*ACTUAL_TASK_TIME_IN_S + 0.5)
          );
    printf( "A one bit needs to be in the range [%u, %u] tics.\n"
            "Impulses in the range (%u, %u) * 0.1 ms could be recognized as one bit\n"
            "Impulses in the range (%u, %u) * 0.1 ms are surely recognized as one bit\n"
          , MIN_LEN_BIT_1_IN_TICS, MAX_LEN_BIT_1_IN_TICS
          , (uint16_t)(1e4*(float)(MIN_LEN_BIT_1_IN_TICS-1)*ACTUAL_TASK_TIME_IN_S + 0.5)
          , (uint16_t)(1e4*(float)(MAX_LEN_BIT_1_IN_TICS+1)*ACTUAL_TASK_TIME_IN_S + 0.5)
          , (uint16_t)(1e4*(float)MIN_LEN_BIT_1_IN_TICS*ACTUAL_TASK_TIME_IN_S + 0.5)
          , (uint16_t)(1e4*(float)MAX_LEN_BIT_1_IN_TICS*ACTUAL_TASK_TIME_IN_S + 0.5)
          );
#endif

    rtos_initializeTask( idxTask
                       , /* taskFunction     */ taskDcf
                       , prioClass
                       , /* pStackArea       */ _stackTSampleAndDecodeDcfSignal
                       , /* stackSize        */ sizeof(_stackTSampleAndDecodeDcfSignal)
                       , /* startEventMask   */ RTOS_EVT_DELAY_TIMER
                       , /* startByAllEvents */ false
                       , /* startTimeout     */ 50
                       );

} /* End of dcf_initializeTask */
示例#3
0
void setup(void)
{
    /* Start serial port at 9600 bps. */
    Serial.begin(9600);
    Serial.println("\n" RTOS_RTUINOS_STARTUP_MSG);

    /* Initialize the digital pin as an output. The LED is used for most basic feedback about
       operability of code. */
    pinMode(LED, OUTPUT);

    uint8_t idxTask = 0
          , idxClass = 0;
    rtos_initializeTask( /* idxTask */          idxTask++
                       , /* taskFunction */     taskEntryC0
                       , /* prioClass */        idxClass
#if RTOS_ROUND_ROBIN_MODE_SUPPORTED == RTOS_FEATURE_ON
                       , /* timeRoundRobin */   23
#endif
                       , /* pStackArea */       &_stackT0_C0[0]
                       , /* stackSize */        sizeof(_stackT0_C0)
                       , /* startEventMask */   EVT_START_TASK_T0_C0
                       , /* startByAllEvents */ false
                       , /* startTimeout */     0
                       );
    rtos_initializeTask( /* idxTask */          idxTask++
                       , /* taskFunction */     taskEntryC0
                       , /* prioClass */        idxClass
#if RTOS_ROUND_ROBIN_MODE_SUPPORTED == RTOS_FEATURE_ON
                       , /* timeRoundRobin */   29
#endif
                       , /* pStackArea */       &_stackT1_C0[0]
                       , /* stackSize */        sizeof(_stackT1_C0)
                       , /* startEventMask */   EVT_START_TASK_T1_C0
                       , /* startByAllEvents */ false
                       , /* startTimeout */     0
                       );
    rtos_initializeTask( /* idxTask */          idxTask++
                       , /* taskFunction */     taskEntryC0
                       , /* prioClass */        idxClass
#if RTOS_ROUND_ROBIN_MODE_SUPPORTED == RTOS_FEATURE_ON
                       , /* timeRoundRobin */   31
#endif
                       , /* pStackArea */       &_stackT2_C0[0]
                       , /* stackSize */        sizeof(_stackT2_C0)
                       , /* startEventMask */   EVT_START_TASK_T2_C0
                       , /* startByAllEvents */ false
                       , /* startTimeout */     0
                       );
    
    /* Initialization of tasks of next priority class starts here. */
    ++ idxClass;
    rtos_initializeTask( /* idxTask */          idxTask++
                       , /* taskFunction */     taskT0_C1
                       , /* prioClass */        idxClass
#if RTOS_ROUND_ROBIN_MODE_SUPPORTED == RTOS_FEATURE_ON
                       , /* timeRoundRobin */   0
#endif
                       , /* pStackArea */       &_stackT0_C1[0]
                       , /* stackSize */        sizeof(_stackT0_C1)
                       , /* startEventMask */   RTOS_EVT_DELAY_TIMER
                       , /* startByAllEvents */ false
                       , /* startTimeout */     0
                       );
    ASSERT(idxTask == RTOS_NO_TASKS  &&  idxClass+1 == RTOS_NO_PRIO_CLASSES);

} /* End of setup */
示例#4
0
void setup()
{
#ifdef DEBUG
    /* Start serial port at 9600 bps. */
    Serial.begin(9600);

    /* Redirect stdout into Serial. */
    init_stdout();

    /* Print greeting to the console window. */
    puts_progmem(rtos_rtuinosStartupMsg);
#endif

    /* Print greeting on the LCD. */
    dpy_display.printGreeting();

    /* Initialize the digital pin as an output. The LED is used for most basic feedback about
       operability of code. */
    pinMode(LED, OUTPUT);

#ifdef DEBUG
//    printf( "ADC configuration at startup:\n"
//            "  ADMUX  = 0x%02x\n"
//            "  ADCSRB = 0x%02x\n"
//          , ADMUX
//          , ADCSRB
//          );
#endif

    /* Write the invariant parts of the display once. This needs to be done here, before
       multitasking begins. */
    dpy_display.printBackground();

    /* Configure the interrupt task of highest priority class. */
    ASSERT(noTasks == RTOS_NO_TASKS);
    rtos_initializeTask( /* idxTask */          idxTaskOnADCComplete
                       , /* taskFunction */     taskOnADCComplete
                       , /* prioClass */        RTOS_NO_PRIO_CLASSES-1
                       , /* pStackArea */       &_stackTaskOnADCComplete[0]
                       , /* stackSize */        sizeof(_stackTaskOnADCComplete)
                       , /* startEventMask */   EVT_ADC_CONVERSION_COMPLETE
                       , /* startByAllEvents */ false
                       , /* startTimeout */     0
                       );

    /* Configure the real time clock task of lowest priority class. */
    rtos_initializeTask( /* idxTask */          idxTaskRTC
                       , /* taskFunction */     taskRTC
                       , /* prioClass */        0
                       , /* pStackArea */       &_stackTaskRTC[0]
                       , /* stackSize */        sizeof(_stackTaskRTC)
                       , /* startEventMask */   RTOS_EVT_ABSOLUTE_TIMER
                       , /* startByAllEvents */ false
                       , /* startTimeout */     CLK_TASK_TIME_RTUINOS_STANDARD_TICS
                       );

    /* Configure the idle follower task of lowest priority class. */
    rtos_initializeTask( /* idxTask */          idxTaskIdleFollower
                       , /* taskFunction */     taskIdleFollower
                       , /* prioClass */        0
                       , /* pStackArea */       &_stackTaskIdleFollower[0]
                       , /* stackSize */        sizeof(_stackTaskIdleFollower)
                       , /* startEventMask */   EVT_TRIGGER_IDLE_FOLLOWER_TASK
                       , /* startByAllEvents */ false
                       , /* startTimeout */     0
                       );

    /* Configure the button evaluation task. Its priority is below the interrupt but - as
       it implements user interaction - above the priority of the display tasks. */
    rtos_initializeTask( /* idxTask */          idxTaskButton
                       , /* taskFunction */     taskButton
                       , /* prioClass */        1
                       , /* pStackArea */       &_stackTaskButton[0]
                       , /* stackSize */        sizeof(_stackTaskButton)
                       , /* startEventMask */   EVT_TRIGGER_TASK_BUTTON
                       , /* startByAllEvents */ false
                       , /* startTimeout */     0
                       );

    /* Configure the result display task. */
    rtos_initializeTask( /* idxTask */          idxTaskDisplayVoltage
                       , /* taskFunction */     taskDisplayVoltage
                       , /* prioClass */        0
                       , /* pStackArea */       &_stackTaskDisplayVoltage[0]
                       , /* stackSize */        sizeof(_stackTaskDisplayVoltage)
                       , /* startEventMask */   EVT_TRIGGER_TASK_DISPLAY_VOLTAGE
                       , /* startByAllEvents */ false
                       , /* startTimeout */     0
                       );
    
    /* Configure the DCF task. Its priority is higher than that of the real time clock and
       the display tasks. DCF reception benefits from task time accuracy. If the priority
       is high enough for proper timing then the task cycle time (which is the DCF signal
       sample time at the same time) can be chosen relatively low and this saves CPU
       consumption. */
    dcf_initializeTask( /* idxTask */ idxTaskDcf
                      , /* prioClass */ 1
                      );
    
    /* Initialize other modules. */
    adc_initAfterPowerUp();
    
} /* End of setup */