/*${components::aoGrinder::SM::grinding} ...................................*/
static QState aoGrinder_grinding(aoGrinder * const me) {
    QState status_;
    switch (Q_SIG(me)) {
        /* ${components::aoGrinder::SM::grinding} */
        case Q_ENTRY_SIG: {
            BSP_println("Start grinding.");
            BSP_ledOn();
            QActive_postISR((QActive *)&AO_Scale, SCALE_START_SIG, 0);
            QActive_postISR((QActive *)&AO_Display, DISPLAY_WEIGHT_SIG, 0);
            status_ = Q_HANDLED();
            break;
        }
        /* ${components::aoGrinder::SM::grinding} */
        case Q_EXIT_SIG: {
            BSP_println("Stop grinding.");
            BSP_ledOff();
            status_ = Q_HANDLED();
            break;
        }
        /* ${components::aoGrinder::SM::grinding::THRESHOLD_REACHED} */
        case THRESHOLD_REACHED_SIG: {
            status_ = Q_TRAN(&aoGrinder_settling);
            break;
        }
        default: {
            status_ = Q_SUPER(&QHsm_top);
            break;
        }
    }
    return status_;
}
/*${components::aoGrinder::SM::done} .......................................*/
static QState aoGrinder_done(aoGrinder * const me) {
    QState status_;
    switch (Q_SIG(me)) {
        /* ${components::aoGrinder::SM::done} */
        case Q_ENTRY_SIG: {
            BSP_println("Grinder done.");
            QActive_postISR((QActive *)&AO_Display, DISPLAY_RESULT_SIG, 0);
            status_ = Q_HANDLED();
            break;
        }
        /* ${components::aoGrinder::SM::done} */
        case Q_EXIT_SIG: {
            QActive_postISR((QActive *)&AO_Scale, SCALE_STOP_SIG, 0);
            QActive_postISR((QActive *)&AO_Display, DISPLAY_IDLE_SIG, 0);
            status_ = Q_HANDLED();
            break;
        }
        /* ${components::aoGrinder::SM::done::NEGATIVE_REACHED} */
        case NEGATIVE_REACHED_SIG: {
            status_ = Q_TRAN(&aoGrinder_idle);
            break;
        }
        default: {
            status_ = Q_SUPER(&QHsm_top);
            break;
        }
    }
    return status_;
}
Example #3
0
/*..........................................................................*/
static void interrupt ISR_tmr(void) {
    QK_ISR_ENTRY();                       /* inform QK-nano about ISR entry */

    QF_tickISR();                          /* process all armed time events */

    QActive_postISR((QActive *)&AO_Tunnel,  TIME_TICK_SIG, 0);
    QActive_postISR((QActive *)&AO_Ship,    TIME_TICK_SIG, 0);
    QActive_postISR((QActive *)&AO_Missile, TIME_TICK_SIG, 0);

    QK_ISR_EXIT();                         /* inform QK-nano about ISR exit */
}
/*${components::aoWeight::SM::aboveTreshold} ...............................*/
static QState aoWeight_aboveTreshold(aoWeight * const me) {
    QState status_;
    switch (Q_SIG(me)) {
        /* ${components::aoWeight::SM::aboveTreshold} */
        case Q_ENTRY_SIG: {
            BSP_println("Weight above threshold.");
            status_ = Q_HANDLED();
            break;
        }
        /* ${components::aoWeight::SM::aboveTreshold::REFRESH} */
        case REFRESH_SIG: {
            /* ${components::aoWeight::SM::aboveTreshold::REFRESH::[Weight>TargetDose]} */
            if (Weight > TargetDose) {
                QActive_postISR((QActive *)&AO_Grinder, DOSE_REACHED_SIG, 0);
                status_ = Q_TRAN(&aoWeight_aboveDose);
            }
            /* ${components::aoWeight::SM::aboveTreshold::REFRESH::[<threshold]} */
            else if (Weight < (TargetDose + SCALE_TARGET_THRESHOLD)) {
                status_ = Q_TRAN(&aoWeight_positive);
            }
            else {
                status_ = Q_UNHANDLED();
            }
            break;
        }
        default: {
            status_ = Q_SUPER(&QHsm_top);
            break;
        }
    }
    return status_;
}
/*${components::aoWeight::SM::negative} ....................................*/
static QState aoWeight_negative(aoWeight * const me) {
    QState status_;
    switch (Q_SIG(me)) {
        /* ${components::aoWeight::SM::negative} */
        case Q_ENTRY_SIG: {
            BSP_println("Weight negative.");
            QActive_postISR((QActive *)&AO_Grinder, NEGATIVE_REACHED_SIG, 0);
            status_ = Q_HANDLED();
            break;
        }
        /* ${components::aoWeight::SM::negative::REFRESH} */
        case REFRESH_SIG: {
            /* ${components::aoWeight::SM::negative::REFRESH::[>negative]} */
            if (Weight > SCALE_NEGATIVE_THRESHOLD) {
                status_ = Q_TRAN(&aoWeight_aroundZero);
            }
            else {
                status_ = Q_UNHANDLED();
            }
            break;
        }
        default: {
            status_ = Q_SUPER(&QHsm_top);
            break;
        }
    }
    return status_;
}
/*${components::aoWeight::SM::positive} ....................................*/
static QState aoWeight_positive(aoWeight * const me) {
    QState status_;
    switch (Q_SIG(me)) {
        /* ${components::aoWeight::SM::positive} */
        case Q_ENTRY_SIG: {
            BSP_println("Weight positive.");
            status_ = Q_HANDLED();
            break;
        }
        /* ${components::aoWeight::SM::positive::REFRESH} */
        case REFRESH_SIG: {
            /* ${components::aoWeight::SM::positive::REFRESH::[>threshold]} */
            if (Weight > (TargetDose + SCALE_TARGET_THRESHOLD)) {
                QActive_postISR((QActive *)&AO_Grinder, THRESHOLD_REACHED_SIG, 0);
                status_ = Q_TRAN(&aoWeight_aboveTreshold);
            }
            /* ${components::aoWeight::SM::positive::REFRESH::[<zero]} */
            else if (Weight < SCALE_ZERO_THRESHOLD) {
                status_ = Q_TRAN(&aoWeight_aroundZero);
            }
            else {
                status_ = Q_UNHANDLED();
            }
            break;
        }
        default: {
            status_ = Q_SUPER(&QHsm_top);
            break;
        }
    }
    return status_;
}
Example #7
0
/*..........................................................................*/
void BSP_onKeyboardInputISR(uint8_t key) {
    switch (key) {
        case 129: {                                         /* ESC pressed? */
            QActive_postISR((QActive *)&AO_Sensor, TERMINATE_SIG, 0);
            break;
        }
    }
}
Example #8
0
/*..........................................................................*/
static void interrupt ISR_kbd() {
    static uint8_t ship_pos = GAME_SHIP_Y;
    uint8_t key;
    uint8_t kcr;

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

    key = inp(0x60);              /* key scan code from 8042 kbd controller */
    kcr = inp(0x61);                       /* get keyboard control register */
    outp(0x61, (uint8_t)(kcr | 0x80));       /* toggle acknowledge bit high */
    outp(0x61, kcr);                          /* toggle acknowledge bit low */

    switch (key) {
        case 200:                                               /* Up-arrow */
        case 208: {                                           /* Down-arrow */
            if ((key == (uint8_t)200) && (ship_pos > 0x00)) {
                --ship_pos;
            }
            else if ((key == (uint8_t)208)
                     && (ship_pos < (GAME_SCREEN_HEIGHT - 3))) {
                ++ship_pos;
            }

            QActive_postISR((QActive *)&AO_Ship, PLAYER_SHIP_MOVE_SIG,
                            ((ship_pos << 8) | GAME_SHIP_X));

            Video_printNumAt(24, 24, VIDEO_FGND_YELLOW, ship_pos);
            break;
        }
        case 57: {                                                 /* Space */
            static uint16_t ntrig = 0;

            QActive_postISR((QActive *)&AO_Ship,   PLAYER_TRIGGER_SIG, 0);
            QActive_postISR((QActive *)&AO_Tunnel, PLAYER_TRIGGER_SIG, 0);

            Video_printNumAt(47, 24, VIDEO_FGND_YELLOW, ++ntrig);
            break;
        }                                                            /* Esc */
        case 129: {
            QActive_postISR((QActive *)&AO_Tunnel, PLAYER_QUIT_SIG, 0);
            break;
        }
    }

    QK_ISR_EXIT();                         /* inform QK-nano about ISR exit */
}
Example #9
0
/*..........................................................................*/
static void interrupt kbdISR() {
    uint8_t key = inport(0x60);   /* key scan code from 8042 kbd controller */
    uint8_t kcr = inport(0x61);            /* get keyboard control register */

    outportb(0x61, (uint8_t)(kcr | 0x80));   /* toggle acknowledge bit high */
    outportb(0x61, kcr);                      /* toggle acknowledge bit low */

    if (key == (uint8_t)129) {                          /* ESC key pressed? */
        QActive_postISR((QActive *)&AO_Table, TERMINATE_SIG, 0);
    }
    outportb(0x20, 0x20);                    /* write EOI to the master PIC */
}
Example #10
0
__interrupt void port1_ISR(void) {                           /* for testing */
#ifdef NDEBUG
    __low_power_mode_off_on_exit();
#endif

    P1IFG &= ~BIT3;                               /* clear interrupt source */

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

    QActive_postISR((QActive *)&AO_Ped, TEST_SIG, 0);    /* post test event */

    QK_ISR_EXIT();                       /* inform QK kernel about ISR exit */
}
Example #11
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 */

    QF_tickISR();                          /* process all armed time events */

                                             /* debounce the USER button... */
    btn = GPIOF->DATA_Bits[USR_SW1];                   /* read the User Sw1 */
    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? */
                    QActive_postISR((QActive *)&AO_Pelican,
                                    PEDS_WAITING_SIG, 0U);
                }
                else {                                   /* button released */
                }
            }
            debounce_state = 0U;              /* transition back to state 0 */
            break;
    }

    QK_ISR_EXIT();                  /* inform QK-nano about exiting the ISR */
}
Example #12
0
/*..........................................................................*/
static void interrupt ISR_kbd() {
    uint8_t key;
    uint8_t kcr;

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

    key = inp(0x60);              /* key scan code from 8042 kbd controller */
    kcr = inp(0x61);                       /* get keyboard control register */
    outp(0x61, (uint8_t)(kcr | 0x80));       /* toggle acknowledge bit high */
    outp(0x61, kcr);                          /* toggle acknowledge bit low */

    if (key == 129) {                                       /* ESC pressed? */
        QActive_postISR((QActive *)&AO_Ped, TERMINATE_SIG, 0);
    }

    QK_ISR_EXIT();                         /* inform QK-nano about ISR exit */
}
Example #13
0
/*..........................................................................*/
static void interrupt kbdISR() {
    uint8_t key = inport(0x60);   /* key scan code from 8042 kbd controller */
    uint8_t kcr = inport(0x61);            /* get keyboard control register */

    dispPreemptions(KBD_ISR_PRIO);              /* for testing only, NOTE01 */
    QK_ISR_ENTRY();                /* inform QK-nano about entering the ISR */

    outportb(0x61, (uint8_t)(kcr | 0x80));   /* toggle acknowledge bit high */
    outportb(0x61, kcr);                      /* toggle acknowledge bit low */

    if (key == (uint8_t)129) {                          /* ESC key pressed? */
        QActive_postISR((QActive *)&AO_Table, TERMINATE_SIG, 0);
    }
    Video_printNumAt(60, 12 + 0, VIDEO_FGND_YELLOW, key);/* display the key */

    BSP_busyDelay();                                 /* for testing, NOTE02 */

    QK_ISR_EXIT();                  /* inform QK-nano about exiting the ISR */
}
/*${components::aoGrinder::SM::calibration} ................................*/
static QState aoGrinder_calibration(aoGrinder * const me) {
    QState status_;
    switch (Q_SIG(me)) {
        /* ${components::aoGrinder::SM::calibration} */
        case Q_ENTRY_SIG: {
            QActive_postISR((QActive *)&AO_Scale, SCALE_TARE_SIG, 0);
            status_ = Q_HANDLED();
            break;
        }
        /* ${components::aoGrinder::SM::calibration::SCALE_TARE_DONE} */
        case SCALE_TARE_DONE_SIG: {
            status_ = Q_TRAN(&aoGrinder_grinding);
            break;
        }
        default: {
            status_ = Q_SUPER(&QHsm_top);
            break;
        }
    }
    return status_;
}
/*${components::aoGrinder::SM::idle} .......................................*/
static QState aoGrinder_idle(aoGrinder * const me) {
    QState status_;
    switch (Q_SIG(me)) {
        /* ${components::aoGrinder::SM::idle} */
        case Q_ENTRY_SIG: {
            BSP_println("Grinder enter idle.");
            QActive_postISR((QActive *)&AO_Display, DISPLAY_IDLE_SIG, 0);
            status_ = Q_HANDLED();
            break;
        }
        /* ${components::aoGrinder::SM::idle::BUTTON_DOWN} */
        case BUTTON_DOWN_SIG: {
            status_ = Q_TRAN(&aoGrinder_calibration);
            break;
        }
        default: {
            status_ = Q_SUPER(&QHsm_top);
            break;
        }
    }
    return status_;
}
Example #16
0
/*..........................................................................*/
void GPIOPortA_IRQHandler(void) {
    QK_ISR_ENTRY();                /* inform QK-nano about entering the ISR */
    QActive_postISR((QActive *)&AO_Pelican, PEDS_WAITING_SIG, 0);/* testing */
    QK_ISR_EXIT();                  /* inform QK-nano about exiting the ISR */
}