📄 main.c
字号:
/****************************************************************************** Product: QDPP example* Last Updated for Version: 3.1.06* Date of the Last Update: May 06, 2006** Q u a n t u m L e a P s* ---------------------------* innovating embedded systems** Copyright (c) 2002-2006 Quantum Leaps, LLC. All rights reserved.** Internet: www.quantum-leaps.com Licensing: sales@quantum-leaps.com** This Software is protected by the United States copyright laws and* international treaties. Distribution of products containing this Software* or based upon this Software (Derivative Works) requires a valid Quantum* Leaps Distribution License. Any other distribution, in source or binary* format is illegal.*****************************************************************************/#include "qf_port.h"#include "qdpp.h"#include "qs_port.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 void setupScreen(char const *comName);/*..........................................................................*/int main(int argc, char *argv[]) { uint8_t n; char const *comName = "COM1"; if (argc > 1) { /* COM name specified? */ comName = argv[1]; } if (!QS_INIT(comName)) { /* initialize QSpy */ printf("Unable to open QSpy output\n"); return -1; } /* filters... */ QS_FILTER_ON(QS_ALL_RECORDS); /* QS_FILTER_OFF(QS_QF_INT_LOCK); QS_FILTER_OFF(QS_QF_INT_UNLOCK); QS_FILTER_OFF(QS_QF_ISR_ENTRY); QS_FILTER_OFF(QS_QF_ISR_EXIT); QS_FILTER_OFF(QS_QF_TICK); QS_FILTER_OFF(QS_QK_SCHEDULE); */ /* object dictionaries... */ QS_OBJ_DICTIONARY(l_regPoolSto); QS_OBJ_DICTIONARY(l_kbdmgrQueueSto); QS_OBJ_DICTIONARY(l_tableQueueSto); QS_OBJ_DICTIONARY(l_philQueueSto[0]); QS_OBJ_DICTIONARY(l_philQueueSto[1]); QS_OBJ_DICTIONARY(l_philQueueSto[2]); QS_OBJ_DICTIONARY(l_philQueueSto[3]); QS_OBJ_DICTIONARY(l_philQueueSto[4]); /* function dictionaries... */ QS_FUN_DICTIONARY(&QHsm_top); /* globally published signal dictionaries... */ QS_SIG_DICTIONARY(HUNGRY_SIG, 0); QS_SIG_DICTIONARY(DONE_SIG, 0); QS_SIG_DICTIONARY(EAT_SIG, 0); QS_SIG_DICTIONARY(TERMINATE_SIG, 0); QS_SIG_DICTIONARY(KBD_SIG, 0); setupScreen(comName); /* 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;}/*..........................................................................*/static void setupScreen(char const *comName) { 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(70, 9, VIDEO_FGND_WHITE, "QS->"); Video_printStrAt(74, 9, VIDEO_FGND_YELLOW, comName); 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-2006 Quantum Leaps, LLC " "* www.quantum-leaps.com *"); Video_printStrAt(28, 24, VIDEO_FGND_LIGHT_RED | VIDEO_BGND_BLINK, "<< Press Esc to quit >>");}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -