コード例 #1
0
/*..........................................................................*/
void BSP_init(void) {
    Video_clearScreen(VIDEO_BGND_LIGHT_GRAY);
    Video_clearRect( 0,  0, 80,   1, VIDEO_BGND_RED | VIDEO_BLINK);
    Video_clearRect( 0,  8, 80,  24, VIDEO_BGND_BLACK | VIDEO_FGND_WHITE);
    Video_clearRect( 0,  7, 80,   8, VIDEO_BGND_BLUE);
    Video_clearRect( 0, 24, 80,  25, VIDEO_BGND_BLUE);

    Video_clearRect(24, 24, 28,  25, VIDEO_BGND_RED | VIDEO_BLINK);
    Video_clearRect(24, 24, 28,  25, VIDEO_BGND_RED | VIDEO_BLINK);

    Video_printStrAt(30,  0, VIDEO_FGND_WHITE, "FLY 'n' SHOOT");
    Video_printStrAt(15,  2, VIDEO_FGND_BLACK,
                     "Press UP-arrow   to move the space ship up");
    Video_printStrAt(15,  3, VIDEO_FGND_BLACK,
                     "Press DOWN-arrow to move the space ship down");
    Video_printStrAt(15,  4, VIDEO_FGND_BLACK,
                     "Press SPACE      to fire the missile");
    Video_printStrAt(15,  5, VIDEO_FGND_BLACK,
                     "Press ESC        to quit the game");
    Video_printStrAt( 8, 24, VIDEO_FGND_WHITE, "Ship Position:");
    Video_printStrAt(37, 24, VIDEO_FGND_WHITE, "Triggers:");
    Video_printStrAt(61, 24, VIDEO_FGND_WHITE, "Score:");

    Video_clearRect(24, 24, 28,  25, VIDEO_BGND_RED);
    Video_clearRect(47, 24, 51,  25, VIDEO_BGND_RED);
    Video_clearRect(68, 24, 72,  25, VIDEO_BGND_RED);
    Video_printNumAt(24, 24, VIDEO_FGND_YELLOW, 0);
    Video_printNumAt(47, 24, VIDEO_FGND_YELLOW, 0);
    Video_printNumAt(68, 24, VIDEO_FGND_YELLOW, 0);
}
コード例 #2
0
ファイル: bsp.c プロジェクト: westlicht/camcontrol
/*..........................................................................*/
void BSP_init(int argc, char *argv[]) {
    uint8_t n;

    if (argc > 1) {
        l_delay = atol(argv[1]);    /* set the delay counter for busy delay */
    }
    Video_clearScreen(VIDEO_BGND_BLACK);
    Video_clearRect( 0,  0, 80,  7, VIDEO_BGND_LIGHT_GRAY);
    Video_clearRect( 0, 11, 80, 12, VIDEO_BGND_LIGHT_GRAY);
    Video_clearRect( 0, 12, 41, 23, VIDEO_BGND_BLUE);
    Video_clearRect(41, 12, 80, 23, VIDEO_BGND_RED);
    Video_clearRect( 0, 23, 80, 24, VIDEO_BGND_LIGHT_GRAY);

    n = VIDEO_FGND_BLUE;
    Video_printStrAt(10, 0, n, "  __");
    Video_printStrAt(10, 1, n, " /  |      _   _ -|-     _ _");
    Video_printStrAt(10, 2, n, " \\__| | |  _\\ | \\ | | | | \\ \\");
    Video_printStrAt(10, 3, n, "    | \\_/ |_| | | | \\_| | | |");
    Video_printStrAt(10, 4, n, "    |");
    n = VIDEO_FGND_RED;
    Video_printStrAt(43, 0, n, "    _       __ ");
    Video_printStrAt(43, 1, n, "|  /_\\     |  \\  TM");
    Video_printStrAt(43, 2, n, "|  \\_   _  |__/ _");
    Video_printStrAt(43, 3, n, "|       _\\ |   |_");
    Video_printStrAt(43, 4, n, "|___   |_| |    _|");
    Video_printStrAt(10, 5, VIDEO_FGND_BLUE,
                     "_____________________________________________________");
    Video_printStrAt(10, 6, VIDEO_FGND_RED,
                     "i n n o v a t i n g   e m b e d d e d   s y s t e m s");
    Video_printStrAt(18,  7, VIDEO_FGND_WHITE,
                     "Dining Philosophers Problem (DPP)");
    Video_printStrAt(18,  8, VIDEO_FGND_WHITE, "QP-nano (QK) ");
    Video_printStrAt(32,  8, VIDEO_FGND_YELLOW, QP_getVersion());
    Video_printStrAt(41, 10, VIDEO_FGND_WHITE, "Delay Counter");
    Video_printNumAt(54, 10, VIDEO_FGND_YELLOW, l_delay);

    Video_printStrAt( 1, 11, VIDEO_FGND_BLUE,
                     "Active Object   State     Preemptions");

    Video_printStrAt(42, 11, VIDEO_FGND_RED,
                     "ISR      Calls    Data    Preemptions");
    for (n = 0; n < N_PHILO; ++n) {
        Video_printStrAt( 1, 12 + n, VIDEO_FGND_WHITE, "Philosopher");
        Video_printNumAt(12, 12 + n, VIDEO_FGND_WHITE, n);
    }
    Video_printStrAt( 1, 12 + N_PHILO, VIDEO_FGND_WHITE,  "Table");
    Video_printStrAt(17, 12 + N_PHILO, VIDEO_FGND_YELLOW, "serving");
    Video_printStrAt( 1, 12 + N_PHILO + 1, VIDEO_FGND_WHITE,  "KbdMgr");
    Video_printStrAt(17, 12 + N_PHILO + 1, VIDEO_FGND_YELLOW, "active");
    Video_printStrAt( 1, 12 + N_PHILO + 3, VIDEO_FGND_WHITE,  "Locked Sched");

    Video_printStrAt(42, 12 + 0, VIDEO_FGND_WHITE,  "kbdISR");
    Video_printStrAt(42, 12 + 1, VIDEO_FGND_WHITE,  "tmrISR");

    Video_printStrAt(10, 23, VIDEO_FGND_BLUE,
         "* Copyright (c) Quantum Leaps, LLC * www.quantum-leaps.com *");
    Video_printStrAt(28, 24, VIDEO_FGND_LIGHT_RED,
         "<< Press Esc to quit >>");
}
コード例 #3
0
ファイル: bsp.c プロジェクト: christation/STM32491_CPLR
/*..........................................................................*/
static void interrupt ISR_kbd() {
    static uint8_t ship_pos = GAME_SHIP_Y;
    uint8_t key;
    uint8_t kcr;

    QF_ISR_ENTRY();                                /* QF-specific 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 */
            ObjectPosEvt *ope = Q_NEW(ObjectPosEvt, PLAYER_SHIP_MOVE_SIG);
            if ((key == (uint8_t)200) && (ship_pos > 0x00)) {
                --ship_pos;
            }
            else if ((key == (uint8_t)208)
                     && (ship_pos < (GAME_SCREEN_HEIGHT - 3))) {
                ++ship_pos;
            }
            ope->x = (uint8_t)GAME_SHIP_X;           /* x-position is fixed */
            ope->y = (uint8_t)ship_pos;
            QACTIVE_POST(AO_Ship, (QEvt *)ope, &l_kbd);    /* to the ship */

            Video_printNumAt(24, 24, VIDEO_FGND_YELLOW, ship_pos);
            break;
        }
        case 57: {                                                 /* Space */
            static uint16_t ntrig = 0;
            static QEvt const fireEvt = { PLAYER_TRIGGER_SIG, 0, 0 };
            QF_PUBLISH(&fireEvt, &l_kbd);

            Video_printNumAt(47, 24, VIDEO_FGND_YELLOW, ++ntrig);
            break;
        }                                                            /* Esc */
        case 129: {
            static QEvt const quitEvt = { PLAYER_QUIT_SIG, 0, 0 };
            QF_PUBLISH(&quitEvt, &l_kbd);
            break;
        }
    }

    QF_ISR_EXIT();                                  /* QF-specific ISR exit */
}
コード例 #4
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 */
}
コード例 #5
0
/*..........................................................................*/
static void interrupt ISR_tmr() {                             /* see NOTE01 */
    QK_ISR_ENTRY();                       /* inform QK-nano about ISR entry */

    QF_tickISR();                       /* process all time events (timers) */
    Video_printNumAt(20, 17, VIDEO_FGND_YELLOW, ++l_tickCtr);

    QK_ISR_EXIT();                         /* inform QK-nano about ISR exit */
}
コード例 #6
0
/*--------------------------------------------------------------------------*/
void Q_onAssert(char const Q_ROM * const file, int line) {
    Video_clearRect(0, 24, 80, 25, VIDEO_BGND_RED);
    Video_printStrAt(0, 24, VIDEO_FGND_WHITE, "ASSERTION FAILED in file:");
    Video_printStrAt(26, 24, VIDEO_FGND_YELLOW, file);
    Video_printStrAt(57, 24, VIDEO_FGND_WHITE, "line:");
    Video_printNumAt(62, 24, VIDEO_FGND_YELLOW, line);

    QF_stop();                                       /* stop QF and cleanup */
}
コード例 #7
0
ファイル: bsp.c プロジェクト: christation/STM32491_CPLR
/*..........................................................................*/
void BSP_init(int argc, char *argv[]) {
    char const *com = "COM1";

    if (argc > 1) {
        com = argv[1];
    }
    if (!QS_INIT(com)) {                                   /* initialize QS */
        Q_ERROR();
    }

    QS_OBJ_DICTIONARY(&l_tmr);
    QS_OBJ_DICTIONARY(&l_kbd);

    Video_clearScreen(VIDEO_BGND_LIGHT_GRAY);
    Video_clearRect( 0,  0, 80,   1, VIDEO_BGND_RED | VIDEO_BLINK);
    Video_clearRect( 0,  8, 80,  24, VIDEO_BGND_BLACK | VIDEO_FGND_WHITE);
    Video_clearRect( 0,  7, 80,   8, VIDEO_BGND_BLUE);
    Video_clearRect( 0, 24, 80,  25, VIDEO_BGND_BLUE);

    Video_clearRect(24, 24, 28,  25, VIDEO_BGND_RED | VIDEO_BLINK);
    Video_clearRect(24, 24, 28,  25, VIDEO_BGND_RED | VIDEO_BLINK);

    Video_printStrAt(35,  0, VIDEO_FGND_WHITE, "FLY 'n' SHOOT");
    Video_printStrAt(15,  2, VIDEO_FGND_BLACK,
                     "Press UP-arrow   to move the space ship up");
    Video_printStrAt(15,  3, VIDEO_FGND_BLACK,
                     "Press DOWN-arrow to move the space ship down");
    Video_printStrAt(15,  4, VIDEO_FGND_BLACK,
                     "Press SPACE      to fire the missile");
    Video_printStrAt(15,  5, VIDEO_FGND_BLACK,
                     "Press ESC        to quit the game");
    Video_printStrAt( 8, 24, VIDEO_FGND_WHITE, "Ship Position:");
    Video_printStrAt(37, 24, VIDEO_FGND_WHITE, "Triggers:");
    Video_printStrAt(61, 24, VIDEO_FGND_WHITE, "Score:");

    Video_clearRect(24, 24, 28,  25, VIDEO_BGND_RED);
    Video_clearRect(47, 24, 51,  25, VIDEO_BGND_RED);
    Video_clearRect(68, 24, 72,  25, VIDEO_BGND_RED);
    Video_printNumAt(24, 24, VIDEO_FGND_YELLOW, 0);
    Video_printNumAt(47, 24, VIDEO_FGND_YELLOW, 0);
    Video_printNumAt(68, 24, VIDEO_FGND_YELLOW, 0);

    (void)com;                  /* avoid compiler warning if QS is not used */
}
コード例 #8
0
ファイル: bsp.c プロジェクト: westlicht/camcontrol
/*..........................................................................*/
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 */
}
コード例 #9
0
ファイル: bsp.c プロジェクト: christation/STM32491_CPLR
/*..........................................................................*/
void ucosTask(void *pdata) {
    (void)pdata; /* avoid the compiler warning about unused parameter */

    QF_onStartup(); /* start interrupts including the clock tick, NOTE01 */

    for (;;) {

        OSTimeDly(OS_TICKS_PER_SEC/10); /* sleep for 1/10 s */

        if (kbhit()) { /* poll for a new keypress */
            uint8_t key = (uint8_t)getch();
            if (key == 0x1B) { /* is this the ESC key? */
                QF_PUBLISH(Q_NEW(QEvt, TERMINATE_SIG), &l_kbdTask);
            }
            else {  /* other key pressed */
                Video_printNumAt(30, 13 + N_PHILO, VIDEO_FGND_YELLOW, key);
            }
        }
    }
}
コード例 #10
0
ファイル: bsp.c プロジェクト: westlicht/camcontrol
/*..........................................................................*/
void dispPreemptions(uint8_t pisr) {             /* for testing, see NOTE01 */
    if (pisr == TMR_ISR_PRIO) {
        static uint32_t tmrIsrCtr;               /* timer interrupt counter */
        Video_printNumAt(51, 12 + 1, VIDEO_FGND_YELLOW, ++tmrIsrCtr);
    }
    else if (pisr == KBD_ISR_PRIO) {
        static uint32_t kbdIsrCtr;                 /* kbd interrupt counter */
        Video_printNumAt(51, 12 + 0, VIDEO_FGND_YELLOW, ++kbdIsrCtr);
    }
    else {
        Q_ERROR();                         /* unexpected interrupt priority */
    }

#ifdef QF_ISR_NEST
    if (QK_intNest_ == (uint8_t)0) {          /* is this a task preemption? */
        if (QK_currPrio_ > (uint8_t)0) {
            static uint32_t preCtr[QF_MAX_ACTIVE + 1];
            Video_printNumAt(30, 12 + QK_currPrio_ - 1, VIDEO_FGND_YELLOW,
                             ++preCtr[QK_currPrio_]);
        }
    }
    else if (QK_intNest_ == (uint8_t)1) {      /* this is an ISR preemption */
        if (pisr == TMR_ISR_PRIO) {          /* TMR_ISR preempting KBD_ISR? */
            static uint32_t kbdPreCtr;        /* kbd ISR preemption counter */
            Video_printNumAt(71, 12 + 0, VIDEO_FGND_YELLOW, ++kbdPreCtr);
        }
        else {
            static uint32_t tmrPreCtr;        /* tmr ISR preemption counter */
            Video_printNumAt(71, 12 + 1, VIDEO_FGND_YELLOW, ++tmrPreCtr);
        }
    }
    else {
        Q_ERROR();         /* impossible ISR nesting level with just 2 ISRs */
    }
#else
    if (QK_currPrio_ > (uint8_t)0) {
        static uint32_t preCtr[QF_MAX_ACTIVE + 1];
        Video_printNumAt(30, 12 + QK_currPrio_ - 1, VIDEO_FGND_YELLOW,
                         ++preCtr[QK_currPrio_]);
    }
#endif
}
コード例 #11
0
/*..........................................................................*/
void BSP_updateScore(uint16_t score) {
    if (score == 0) {
        Video_clearRect(68, 24, 72,  25, VIDEO_BGND_RED);
    }
    Video_printNumAt(68, 24, VIDEO_FGND_YELLOW, score);
}
コード例 #12
0
ファイル: bsp.c プロジェクト: christation/STM32491_CPLR
/*..........................................................................*/
void BSP_init(int argc, char *argv[]) {
    char const *com = "COM1";
    uint8_t n;

    if (argc > 1) {
        l_delay = atol(argv[1]); /* set the delay counter for busy delay */
    }
    if (argc > 2) {
        com = argv[2];
        (void)com; /* avoid compiler warning if Q_SPY not defined */
    }
    if (!QS_INIT(com)) { /* initialize QS */
        Q_ERROR();
    }

    QS_OBJ_DICTIONARY(&l_tickHook);
    QS_OBJ_DICTIONARY(&l_kbdTask);

    Video_clearScreen(VIDEO_BGND_BLACK);
    Video_clearRect( 0,  0, 80,  7, VIDEO_BGND_LIGHT_GRAY);
    Video_clearRect( 0, 11, 80, 12, VIDEO_BGND_LIGHT_GRAY);
    Video_clearRect( 0, 12, 41, 23, VIDEO_BGND_BLUE);
    Video_clearRect(41, 12, 80, 23, VIDEO_BGND_RED);
    Video_clearRect( 0, 23, 80, 24, VIDEO_BGND_LIGHT_GRAY);

    n = VIDEO_FGND_BLUE;
    Video_printStrAt(10, 0, n, "  __");
    Video_printStrAt(10, 1, n, " /  |      _   _ -|-     _ _");
    Video_printStrAt(10, 2, n, " \\__| | |  _\\ | \\ | | | | \\ \\");
    Video_printStrAt(10, 3, n, "    | \\_/ |_| | | | \\_| | | |");
    Video_printStrAt(10, 4, n, "    |");
    n = VIDEO_FGND_RED;
    Video_printStrAt(43, 0, n, "    _       __ ");
    Video_printStrAt(43, 1, n, "|  /_\\     |  \\  TM");
    Video_printStrAt(43, 2, n, "|  \\_   _  |__/ _");
    Video_printStrAt(43, 3, n, "|       _\\ |   |_");
    Video_printStrAt(43, 4, n, "|___   |_| |    _|");
    Video_printStrAt(10, 5, VIDEO_FGND_BLUE,
                     "_____________________________________________________");
    Video_printStrAt(10, 6, VIDEO_FGND_RED,
                     "i n n o v a t i n g   e m b e d d e d   s y s t e m s");
    Video_printStrAt(18,  7, VIDEO_FGND_WHITE,
                     "Dining Philosophers Example");
    Video_printStrAt(18,  8, VIDEO_FGND_WHITE, "QEP/C");
    Video_printStrAt(28,  8, VIDEO_FGND_YELLOW, QEP_getVersion());
    Video_printStrAt(18,  9, VIDEO_FGND_WHITE, "QF/C");
    Video_printStrAt(28,  9, VIDEO_FGND_YELLOW, QF_getVersion());
    Video_printStrAt(18, 10, VIDEO_FGND_WHITE, "uC/OS-II");

    /* uC/OS-II version is returned as an integer value multiplied by 100 */
    Video_printNumAt(29, 10, VIDEO_FGND_YELLOW, OSVersion()%100);
    Video_printStrAt(28, 10, VIDEO_FGND_YELLOW, "2.");

    Video_printStrAt( 1, 11, VIDEO_FGND_BLUE,
                     "Active Object   State        Data");

    for (n = 0; n < N_PHILO; ++n) {
        Video_printStrAt( 1, 12 + n, VIDEO_FGND_WHITE, "Philosopher");
        Video_printNumAt(12, 12 + n, VIDEO_FGND_WHITE, n + 1);
    }
    Video_printStrAt( 1, 12 + N_PHILO, VIDEO_FGND_WHITE,  "Table");
    Video_printStrAt(17, 12 + N_PHILO, VIDEO_FGND_YELLOW, "serving");
    Video_printStrAt( 1, 12 + N_PHILO + 1, VIDEO_FGND_WHITE,  "ucosTask");
    Video_printStrAt(17, 12 + N_PHILO + 1, VIDEO_FGND_YELLOW, "active");

    Video_printStrAt(4, 23, VIDEO_FGND_BLUE,
         "* Copyright (c) Quantum Leaps, LLC * www.state-machine.com *");
    Video_printStrAt(28, 24, VIDEO_FGND_LIGHT_RED,
         "<< Press Esc to quit >>");
}