Beispiel #1
0
/* ISRs --------------------------------------------------------------------*/
__ramfunc
static void ISR_tick(void) {
    /* state of the button debouncing, see below */
    static struct ButtonsDebouncing {
        uint32_t depressed;
        uint32_t previous;
    } buttons = { ~0U, ~0U };
    uint32_t current;
    uint32_t volatile tmp;

    /* clear the interrupt source */
    tmp = AT91C_BASE_PITC->PITC_PIVR;

    QF_tickXISR(0U); /* process time events for rate 0 */

    /* Perform the debouncing of buttons. The algorithm for debouncing
    * adapted from the book "Embedded Systems Dictionary" by Jack Ganssle
    * and Michael Barr, page 71.
    */
    current = ~AT91C_BASE_PIOA->PIO_PDSR;/* read PIOA with state of Buttons */
    tmp = buttons.depressed; /* save the debounced depressed buttons */
    buttons.depressed |= (buttons.previous & current); /* set depressed */
    buttons.depressed &= (buttons.previous | current); /* clear released */
    buttons.previous   = current; /* update the history */
    tmp ^= buttons.depressed;     /* changed debounced depressed */
    if ((tmp & l_btn[0]) != 0U) {  /* debounced BTN_P1 state changed? */
        if ((buttons.depressed & l_btn[0]) != 0U) { /* is BTN_P1 depressed? */
            QACTIVE_POST_ISR(&AO_Table, PAUSE_SIG, 0U);
        }
        else {            /* the button is released */
            QACTIVE_POST_ISR(&AO_Table, SERVE_SIG, 0U);
        }
    }
}
Beispiel #2
0
/*..........................................................................*/
void QF_onClockTickISR(void) {
    QF_tickXISR(0U);                /* perform the QF clock tick processing */

    if (_kbhit()) {                                     /* any key pressed? */
        switch (_getch()) {
            case '\33':                                     /* ESC pressed? */
                QACTIVE_POST_ISR((QActive *)&AO_Pelican, TERMINATE_SIG, 0U);
                break;
            case 'p':
                printf("-----> PEDS_WAITING\n");
                QACTIVE_POST_ISR((QActive *)&AO_Pelican, PEDS_WAITING_SIG, 0U);
                break;
            case 'f':
                printf("-----> OFF\n");
                QACTIVE_POST_ISR((QActive *)&AO_Pelican, OFF_SIG, 0U);
                break;
            case 'o':
                printf("-----> ON\n");
                QACTIVE_POST_ISR((QActive *)&AO_Pelican, ON_SIG, 0U);
                break;
            default:
                break;
        }
    }
}
Beispiel #3
0
__interrupt void timer2_ISR(void) {
    /* state of the button debouncing, see below */
    static struct ButtonsDebouncing {
        uint8_t depressed;
        uint8_t previous;
    } buttons = { 0xFFU, 0xFFU };
    uint8_t current;
    uint8_t tmp;

    QF_tickXISR(0U); /* process time events for rate 0 */

    /* Perform the debouncing of buttons. The algorithm for debouncing
    * adapted from the book "Embedded Systems Dictionary" by Jack Ganssle
    * and Michael Barr, page 71.
    */
    current = PIND; /* read PORTD with the state of BTN_EXT */
    tmp = buttons.depressed; /* save the debounced depressed buttons */
    buttons.depressed |= (buttons.previous & current); /* set depressed */
    buttons.depressed &= (buttons.previous | current); /* clear released */
    buttons.previous   = current; /* update the history */
    tmp ^= buttons.depressed;     /* changed debounced depressed */
    if ((tmp & BTN_EXT) != 0U) {  /* debounced BTN_EXT state changed? */
        if ((buttons.depressed & BTN_EXT) != 0U) { /* is BTN_EXT depressed? */
            QACTIVE_POST_ISR((QActive *)&AO_Table, PAUSE_SIG, 0U);
        }
        else {            /* the button is released */
            QACTIVE_POST_ISR((QActive *)&AO_Table, SERVE_SIG, 0U);
        }
    }
}
Beispiel #4
0
/*..........................................................................*/
void QF_onClockTickISR(void) {
    QF_tickXISR(0U);           /* perform the QF-nano clock tick processing */

    if (_kbhit()) {                                     /* any key pressed? */
        int ch = _getch();
        if (ch == 0x1B) {                     /* see if the ESC key pressed */
            QACTIVE_POST_ISR((QActive *)&AO_Table, TERMINATE_SIG, 0U);
        }
        else if (ch == 'p') {
            QACTIVE_POST_ISR((QActive *)&AO_Table, PAUSE_SIG, 0U);
        }
    }
}
Beispiel #5
0
/*..........................................................................*/
void QF_onClockTickISR(void) {
    struct timeval timeout = { 0 };                 /* timeout for select() */
    fd_set con;                          /* FD set representing the console */

    QF_tickXISR(0U);                /* perform the QF clock tick processing */

    FD_ZERO(&con);
    FD_SET(0, &con);
    /* check if a console input is available, returns immediately */
    if (0 != select(1, &con, 0, 0, &timeout)) {      /* any descriptor set? */
        char ch;
        read(0, &ch, 1);
        if (ch == '\33') {                                  /* ESC pressed? */
            QACTIVE_POST_ISR((QActive *)&AO_Table, TERMINATE_SIG, 0U);
        }
        else if (ch == 'p') {
            QACTIVE_POST_ISR((QActive *)&AO_Table, PAUSE_SIG, 0U);
        }
    }
}
Beispiel #6
0
/*..........................................................................*/
void BSP_onKeyboardInputISR(uint8_t key) {
    switch (key) {
        case 'o': {                                 /* 'o': Alarm on event? */
            QACTIVE_POST_ISR((QActive *)&AO_AlarmClock, ALARM_ON_SIG, 0);
            break;
        }
        case 'f': {                                /* 'f': Alarm off event? */
            QACTIVE_POST_ISR((QActive *)&AO_AlarmClock, ALARM_OFF_SIG, 0);
            break;
        }
        case '1':                                                    /* '1' */
        case '2':                                                    /* '2' */
        case '3':                                                    /* '3' */
        case '4':                                                    /* '4' */
        case '5':                                                    /* '5' */
        case '6':                                                    /* '6' */
        case '7':                                                    /* '7' */
        case '8':                                                    /* '8' */
        case '9': {                                                  /* '9' */
            QACTIVE_POST_ISR((QActive *)&AO_AlarmClock, ALARM_SET_SIG, key-1);
            break;
        }
        case '0': {                                                  /* '0' */
            QACTIVE_POST_ISR((QActive *)&AO_AlarmClock, ALARM_SET_SIG, 0);
            break;
        }
        case 'a': {                                /* 'a': Clock 12H event? */
            QACTIVE_POST_ISR((QActive *)&AO_AlarmClock, CLOCK_12H_SIG, 0);
            break;
        }
        case 'b': {                                /* 'b': Clock 24H event? */
            QACTIVE_POST_ISR((QActive *)&AO_AlarmClock, CLOCK_24H_SIG, 0);
            break;
        }
        case '\33': {                                       /* ESC pressed? */
            QACTIVE_POST_ISR((QActive *)&AO_AlarmClock, TERMINATE_SIG, 0);
            break;
        }
    }
}