Exemplo n.º 1
0
/*..........................................................................*/
void QF_run(void) {
    struct sched_param sparam;
    struct timeval timeout = { 0 };                 /* timeout for select() */

    QF_onStartup();                              /* invoke startup callback */

           /* try to maximize the priority of the ticker thread, see NOTE01 */
    sparam.sched_priority = sched_get_priority_max(SCHED_FIFO);
    if (pthread_setschedparam(pthread_self(), SCHED_FIFO, &sparam) == 0) {
                     /* success, this application has sufficient privileges */
    }
    else {
         /* setting priority failed, probably due to insufficient privieges */
    }

    QS_OBJ_DICTIONARY(&l_ticker);       /* the QS dictionary for the ticker */

    l_running = (uint8_t)1;
    while (l_running) {
        QF_TICK(&l_ticker);                          /* process a time tick */

        timeout.tv_usec = 8000;
        select(0, 0, 0, 0, &timeout);   /* sleep for the full tick , NOTE05 */
    }
    QF_onCleanup();                              /* invoke cleanup callback */
    pthread_mutex_destroy(&QF_pThreadMutex_);
}
Exemplo n.º 2
0
/*..........................................................................*/
void SysTick_Handler(void) {
    static uint32_t btn_debounced  = USR_SW1;
    static uint8_t  debounce_state = 0U;
    uint32_t btn;

    QK_ISR_ENTRY();                      /* infrom QK about entering an ISR */

#ifdef Q_SPY
    {
        uint32_t dummy = SysTick->CTRL;     /* clear SysTick_CTRL_COUNTFLAG */
        QS_tickTime_ += QS_tickPeriod_;   /* account for the clock rollover */
    }
#endif

    QF_TICK(&l_SysTick_Handler);           /* process all armed time events */

                                              /* debounce the SW1 button... */
    btn = GPIOF->DATA_Bits[USR_SW1];                   /* read the push btn */
    switch (debounce_state) {
        case 0:
            if (btn != btn_debounced) {
                debounce_state = 1U;        /* transition to the next state */
            }
            break;
        case 1:
            if (btn != btn_debounced) {
                debounce_state = 2U;        /* transition to the next state */
            }
            else {
                debounce_state = 0U;          /* transition back to state 0 */
            }
            break;
        case 2:
            if (btn != btn_debounced) {
                debounce_state = 3U;        /* transition to the next state */
            }
            else {
                debounce_state = 0U;          /* transition back to state 0 */
            }
            break;
        case 3:
            if (btn != btn_debounced) {
                btn_debounced = btn;     /* save the debounced button value */

                if (btn == 0U) {                /* is the button depressed? */
                    static QEvt const pauseEvt = { PAUSE_SIG, 0U, 0U};
                    QF_PUBLISH(&pauseEvt, &l_SysTick_Handler);
                }
                else {
                    static QEvt const pauseEvt = { PAUSE_SIG, 0U, 0U};
                    QF_PUBLISH(&pauseEvt, &l_SysTick_Handler);
                }
            }
            debounce_state = 0U;              /* transition back to state 0 */
            break;
    }

    QK_ISR_EXIT();                        /* infrom QK about exiting an ISR */
}
Exemplo n.º 3
0
Arquivo: bsp.c Projeto: voileravi/zen
/*..........................................................................*/
interrupt void TINT_isr(void) {
    CSL_SYSCTRL_REGS->TIAFR |= 0x0001U;                 /* clear Timer0 bit */

    QK_ISR_ENTRY();                 /* inform the QK kernel about ISR entry */

    QF_TICK(&l_TINT_isr);                      /* handle the QF time events */

    QK_ISR_EXIT();                   /* inform the QK kernel about ISR exit */
}
void  __attribute__((__interrupt__, auto_psv)) _T2Interrupt(void) {
    _T2IF = 0;                              /* clear Timer 2 interrupt flag */

#ifdef Q_SPY
    l_tickTime += BSP_TMR2_PERIOD;             /* account for TMR2 overflow */
#endif

    QF_TICK(&l_T2Interrupt);          /* handle all armed time events in QF */
}
/*..........................................................................*/
void SysTick_Handler(void) {
    static uint32_t btn_debounced  = 0;
    static uint8_t  debounce_state = 0;
    uint32_t volatile tmp;

    QK_ISR_ENTRY();                            /* inform QK about ISR entry */

    ++l_nTicks;                          /* count the number of clock ticks */

#ifdef Q_SPY
    tmp = SysTick->CTRL;                    /* clear SysTick_CTRL_COUNTFLAG */
    QS_tickTime_ += QS_tickPeriod_;       /* account for the clock rollover */
#endif

    QF_TICK(&l_SysTick_Handler);           /* process all armed time events */

    tmp = GPIOF->DATA_Bits[USER_BTN];               /* read the User Button */
    switch (debounce_state) {
        case 0:
            if (tmp != btn_debounced) {
                debounce_state = 1;         /* transition to the next state */
            }
            break;
        case 1:
            if (tmp != btn_debounced) {
                debounce_state = 2;         /* transition to the next state */
            }
            else {
                debounce_state = 0;           /* transition back to state 0 */
            }
            break;
        case 2:
            if (tmp != btn_debounced) {
                debounce_state = 3;         /* transition to the next state */
            }
            else {
                debounce_state = 0;           /* transition back to state 0 */
            }
            break;
        case 3:
            if (tmp != btn_debounced) {
                btn_debounced = tmp;     /* save the debounced button value */
                if (tmp == 0) {                 /* is the button depressed? */
                    static QEvt const bd = { BTN_DOWN_SIG, 0 };
                    QF_PUBLISH(&bd, &l_SysTick_Handler);
                }
                else {
                    static QEvt const bu = { BTN_UP_SIG, 0 };
                    QF_PUBLISH(&bu, &l_SysTick_Handler);
                }
            }
            debounce_state = 0;               /* transition back to state 0 */
            break;
    }

    QK_ISR_EXIT();                              /* inform QK about ISR exit */
}
void SysTick_Handler(void) {
#ifdef Q_SPY
    {
        uint32_t dummy = SysTick->CTRL;    /* clear NVIC_ST_CTRL_COUNT flag */
        QS_tickTime_ += QS_tickPeriod_;   /* account for the clock rollover */
    }
#endif

    QF_TICK(&l_SysTick_Handler);           /* process all armed time events */
}
Exemplo n.º 7
0
/*..........................................................................*/
void interrupt ISR_tmr(void) {
    QF_ISR_ENTRY();                                /* QF-specific ISR entry */

    QF_TICK(&l_tmr);          /* call QF_tick() outside of critical section */
#ifdef Q_SPY
    l_tickTime += 0x10000;                           /* add 16-bit rollover */
#endif

    QF_ISR_EXIT();                                  /* QF-specific ISR exit */
}
//;0x0070  CMTU0_CMT0
void  INT_Excep_CMTU0_CMI0(void) {
    QK_ISR_ENTRY();          /* inform the QK kernel about entering the ISR */

#ifdef Q_SPY
    QS_tickTime_ += QS_tickPeriod_;       /* account for the clock rollover */
#endif
    QF_TICK(&QS_Excep_CMTU0_CMT0);         /* process all armed time events */

    QK_ISR_EXIT();            /* inform the QK kernel about exiting the ISR */
}
void SysTick_Handler(void) {
    QK_ISR_ENTRY();                       /* inform QK-nano about ISR entry */
#ifdef Q_SPY
    uint32_t dummy = SysTick->CTRL;        /* clear NVIC_ST_CTRL_COUNT flag */
    QS_tickTime_ += QS_tickPeriod_;       /* account for the clock rollover */
#endif

    QF_TICK(&l_SysTick_Handler);           /* process all armed time events */

    QK_ISR_EXIT();                         /* inform QK-nano about ISR exit */
}
QK_ISR(no_auto_psv) _T2Interrupt() {
    _T2IF = 0;                              /* clear Timer 2 interrupt flag */

#ifdef Q_SPY
    l_tickTime += BSP_TMR2_PERIOD;             /* account for TMR2 overflow */
#endif

    QF_TICK(&l_T2Interrupt);          /* handle all armed time events in QF */

    QK_ISR_EXIT();                  /* inform QK-nano about exiting the ISR */
}
/*..........................................................................*/
void QF_onClockTick(void) {
    QF_TICK(&l_clock_tick);         /* perform the QF clock tick processing */
    if (_kbhit()) {                                     /* any key pressed? */
        int ch = _getch();
        if (ch == '\33') {                    /* see if the ESC key pressed */
            QF_PUBLISH(Q_NEW(QEvt, TERMINATE_SIG), &l_clock_tick);
        }
        else if (ch == 'p') {
            QF_PUBLISH(Q_NEW(QEvt, PAUSE_SIG), &l_clock_tick);
        }
    }
}
__interrupt void timerA_ISR(void) {
    QK_ISR_ENTRY();                     /* inform QK about entering the ISR */

#ifdef Q_SPY
    TACTL &= ~TAIFG;                    /* clear the interrupt pending flag */
    QS_tickTime_ +=
       (((BSP_SMCLK / 8) + BSP_TICKS_PER_SEC/2) / BSP_TICKS_PER_SEC) + 1;
#endif

    QF_TICK(&l_timerA_ISR);

    QK_ISR_EXIT();                       /* inform QK about exiting the ISR */
}
Exemplo n.º 13
0
__interrupt void timerA_ISR(void) {
#ifdef NDEBUG
    __low_power_mode_off_on_exit();
#endif

#ifdef Q_SPY
    TACTL &= ~TAIFG;                    /* clear the interrupt pending flag */
    QS_tickTime_ +=
       (((BSP_SMCLK / 8) + BSP_TICKS_PER_SEC/2) / BSP_TICKS_PER_SEC) + 1;
#endif

    QF_TICK(&l_timerA_ISR);
}
Exemplo n.º 14
0
/*..........................................................................*/
static void interrupt ISR_tmr() {
    static QEvt const tickEvt = { TIME_TICK_SIG, 0, 0 };

    QF_ISR_ENTRY();                                /* QF-specific ISR entry */

    QF_TICK(&l_tmr);          /* call QF_tick() outside of critical section */
    QF_PUBLISH(&tickEvt, &l_tmr);                 /* publish the tick event */

#ifdef Q_SPY
    l_tickTime += 0x10000;
#endif

    QF_ISR_EXIT();                                  /* QF-specific ISR exit */
}
Exemplo n.º 15
0
/*..........................................................................*/
void QF_run(void) {
    l_running = (uint8_t)1;
    QF_onStartup();                                     /* startup callback */
            /* raise the priority of this (main) thread to tick more timely */
    SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);

    QS_OBJ_DICTIONARY(&l_ticker);       /* the QS dictionary for the ticker */

    while (l_running) {
        QF_TICK(&l_ticker);                          /* process a time tick */
        Sleep(l_tickMsec);                    /* wait for the tick interval */
    }
    QF_onCleanup();                                     /* cleanup callback */
    QS_EXIT();                               /* cleanup the QSPY connection */
    DeleteCriticalSection(&QF_win32CritSect_);
}
Exemplo n.º 16
0
__interrupt void timerA_ISR(void) {
#ifdef NDEBUG
    __low_power_mode_off_on_exit();
#endif

    QK_ISR_ENTRY();                            /* inform QK about ISR entry */

#ifdef Q_SPY
    TACTL &= ~TAIFG;                    /* clear the interrupt pending flag */
    QS_tickTime_ +=
       (((BSP_SMCLK / 8) + BSP_TICKS_PER_SEC/2) / BSP_TICKS_PER_SEC) + 1;
#endif

    QF_TICK(&l_timerA_ISR);

    QK_ISR_EXIT();                              /* inform QK about ISR exit */
}
Exemplo n.º 17
0
/*..........................................................................*/
void QF_onClockTick(void) {
    QF_TICK(&l_clock_tick); /* perform the QF clock tick processing */
}