📄 mboxtest.c
字号:
/* mboxTest.c - Sample code to use Univers Mailbox functionality. *//* Copyright 1999-2002 Dy 4 Systems, Inc. *//*Modification History--------------------01a, 15mar00, elp created*/ /*DESCRIPTIONThis file will verify the functionality of the Universe Mailbox features. The following functions will be tested:sysMailboxAddrGet()sysUnivMailboxConnect()sysMailboxEnable()sysMailboxDisable()INCLUDE files: universe.h universe2.h*//* includes */#include <vxWorks.h>#include <stdio.h>#include <ioLib.h>#include <taskLib.h>#include "config.h"#include "logLib.h"#include "iosLib.h"#include "intLib.h"#include "h/drv/vme/universe_dy4.h"#include "h/drv/vme/universe2_dy4.h"#include "config.h" /* also includes dy4181.h and sysFpgaInt.h *//* locals */LOCAL BOOL gotInt = FALSE;/* external declarations */IMPORT UINT sysMailboxAddrGet (int mailboxId);IMPORT STATUS sysUnivMailboxConnect (int mailboxId, FUNCPTR routine, int arg);IMPORT STATUS sysMailboxEnable (char *mailboxId);IMPORT STATUS sysMailboxDisable (char *mailboxId);/* forward declarations */void mboxIsr (int mboxId);/**************************************************************************** mboxTest - Universe Mailbox Test Program** This routine takes a mailbox ID as a parameter and tests that Mailbox.** RETURNS: N/A* */void mboxTest ( int mboxId ) { UINT32 * mboxAddr; int i = 0; printf ("Testing Universe Mailbox ID%d\n\n", mboxId); mboxAddr = (UINT32 *) sysMailboxAddrGet (mboxId); printf ("Mailbox Address for Mailbox ID%d is %x\n\n", mboxId, (int) mboxAddr); sysUnivMailboxConnect (mboxId, (FUNCPTR) mboxIsr, SYS_MAILBOX_DATA); sysMailboxEnable ((char *) mboxId); printf ("Mailbox Interrupt Enabled. Write Mailbox from 2nd Card Now.\n\n"); /* Wait for the interrupt to happen. Time out after a long time */ while (!gotInt && (i < 100)) { i++; taskDelay (10); } if (!gotInt) { printf ("Never recieved the interrupt. Test FAILED.\n\n"); } else { printf ("Test PASSED.\n\n"); gotInt = FALSE; sysMailboxDisable((char *) mboxId); } } /******************************************************************* mboxIsr - Universe Mailbox Interrupt Service Routine** This routine handles the Mailbox interrupt that it has been connected to.* It finds out the mailbox address based on the passed in ID then prints out* the data in the mailbox with a logMsg. It then sets a global flag saying* it got the interrupt.** RETURNS: N/A*/void mboxIsr ( int mboxData ) { logMsg ("Got Mailbox Interrupt. Data is %x\n\n", mboxData, 0, 0, 0, 0, 0); gotInt = TRUE; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -