?? main.c
字號:
/****************************************************************************** Product: QDPP example* Version: Compatible with QF/C 3.1.yy* Updated: Dec 18, 2005** Copyright (C) 2002-2005 Quantum Leaps, LLC. All rights reserved.** This example is part of the Quantum Leaps QP/C software, and may be* distributed and modified under the terms of the GNU General Public License* version 2 (GPL) as published by the Free Software Foundation and appearing* in the file GPL.TXT included in the packaging of this file. Please note* that GPL Section 2[b] requires that all works based on this software must* also be made publicly available under the terms of the GPL ("Copyleft").** Alternatively, this software may be distributed and modified in conjunction* with a valid QP/C Quantum Leaps commercial license. Quantum Leaps* commercial licenses are designed for users who want to retain proprietary* status of their code. The users who license this software under one of* Quantum Leaps commercial licenses do not use this software under the GPL* and therefore are not subject to any of its terms.** Contact information:* Quantum Leaps Web site: http://www.quantum-leaps.com* Quantum Leaps licensing: http://www.quantum-leaps.com/licensing* Quantum Leaps products: http://www.quantum-leaps.com/products* e-mail: sales@quantum-leaps.com*****************************************************************************/#include "qf_port.h"#include "qdpp.h"#include "video.h"#include <stdlib.h> /* for atol() *//* local objects -----------------------------------------------------------*/static QEvent const *l_kbdmgrQueueSto[2];static QEvent const *l_tableQueueSto[N];static QEvent const *l_philQueueSto[N][10];static void *l_regPoolSto[100/sizeof(void*)];/*100 bytes for the event pool */static QSubscrList l_subscrSto[MAX_PUB_SIG];static uint32_t l_delayCtr = 0UL;static void setupScreen(void);/*..........................................................................*/int main(int argc, char *argv[]) { uint8_t n; if (argc > 1) { /* delay specified? */ l_delayCtr = atol(argv[1]); } setupScreen(); /* setup the screen */ QF_init(); /* initialize the framework and the underlying RT kernel */ QF_psInit(l_subscrSto, Q_DIM(l_subscrSto)); /* init publish-subscribe */ /* initialize event pools... */ QF_poolInit(l_regPoolSto, sizeof(l_regPoolSto), sizeof(l_regPoolSto[0])); /* start active objects... */ for (n = 0; n < N; ++n) { philosopherStart(n, (uint8_t)(n*10 + 1), l_philQueueSto[n], Q_DIM(l_philQueueSto[n]), (void *)0, 0); } tableStart((uint8_t)(N*10 + 1), l_tableQueueSto, Q_DIM(l_tableQueueSto), (void *)0, 0); kbdMgrStart((uint8_t)((N + 1)*10 + 1), l_kbdmgrQueueSto, Q_DIM(l_kbdmgrQueueSto), (void *)0, 0); QF_run(); /* run the QF application */ return 0;}/*..........................................................................*/void busyDelay(void) { volatile uint32_t i = l_delayCtr; while (i-- > 0) { }}/*..........................................................................*/static void setupScreen(void) { uint8_t n; 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, "Quantum 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, "QK/C"); Video_printStrAt(28, 10, VIDEO_FGND_YELLOW, QK_getVersion()); Video_printStrAt(36, 10, VIDEO_FGND_WHITE, "Port to 80x86"); Video_printStrAt(52, 10, VIDEO_FGND_YELLOW, QK_getPortVersion()); 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; ++n) { Video_printStrAt( 1, 12 + n, VIDEO_FGND_WHITE, "Philosopher"); Video_printNumAt(12, 12 + n, VIDEO_FGND_WHITE, n); } Video_printStrAt( 1, 12 + N, VIDEO_FGND_WHITE, "Table"); Video_printStrAt(17, 12 + N, VIDEO_FGND_YELLOW, "serving"); Video_printStrAt( 1, 12 + N + 1, VIDEO_FGND_WHITE, "KbdMgr"); Video_printStrAt(17, 12 + N + 1, VIDEO_FGND_YELLOW, "active"); Video_printStrAt( 1, 12 + N + 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(4, 23, VIDEO_FGND_BLUE, "* Copyright (c) 2002-2005 Quantum Leaps, LLC " "* www.quantum-leaps.com *"); Video_printStrAt(28, 24, VIDEO_FGND_LIGHT_RED, "<< Press Esc to quit >>");}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -