📄 vmedev.c
字号:
/* vmedev.c
This example program opens a VXI interface session and sets
up an interrupt handler. When the specified interrupt occurs,
the procedure defined in the interrupt handler is called. */
#include <stdio.h>
#include <stdlib.h>
#include <sicl.h>
#define ADDR "vxi"
void handler (INST id, long reason, long secval){
printf ("Got the interrupt\n");
}
void main ()
{
unsigned short reg;
char *base_addr;
INST id;
/* install error handler */
ionerror (I_ERROR_EXIT);
/* open an interface communications session */
id = iopen (ADDR);
/* install interrupt handler */
ionintr (id, handler);
isetintr (id, I_INTR_VXI_VME, 1);
/* turn off interrupt notification */
iintroff ();
/* map into user memory space */
base_addr = imap (id, I_MAP_A24, 0x40, 1, NULL);
/* read a register */
reg = iwpeek((unsigned short *)(base_addr + 0x00));
/* print contents */
printf ("The registers contents were as follows: 0x%4X\n", reg);
/* write to a register causing interrupt */
iwpoke ((unsigned short *)(base_addr + 0x00), reg);
/* wait for interrupt */
iwaithdlr (10000);
/* turn on interrupt notification */
iintron ();
/* unmap memory space */
iunmap (id, base_addr, I_MAP_VXIDEV, 0x40, 1);
/* close session */
iclose (id);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -