📄 7300cwav.c
字号:
#include "windows.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <process.h>
#include "resource.h"
#include "Dask.h"
#define IDM_EXIT 110
#define IDC_SCROLL 207
#define IDC_START 208
#define IDC_STOP 209
#define IDC_EDIT 211
#define IDC_EDIT1 214
#define IDC_SHOW 213
#define IDC_DA 400
#define PI 3.14159
#define MAX_SIZE 1024000 //in words
int PASCAL WinMain(HANDLE, HANDLE, LPSTR, int);
long PASCAL MainWndProc(HWND, UINT, WPARAM, LPARAM);
BOOL PASCAL ShowDMA(HWND, UINT, WPARAM, LPARAM);
HANDLE hInst;
HWND hListBox;
HWND hEdit,hEdit1, hStart, hStop;
HBRUSH hBlackBrush;
HPEN hRedPen, hBlackPen;
HWND hMainWnd;
U32 sample_rate=10000;
U16 in_buf[MAX_SIZE], in_buf2[MAX_SIZE], in_buf3[MAX_SIZE], in_buf4[MAX_SIZE];
int oldinput=-1,adinput;
U32 data_size=100000;
U32 mem_size;
U16 db_times = 0;
U16 viewidx;
I16 card=-1, card_number = 0;
BOOLEAN bStopped;
U32 count;
U16 out_buf[MAX_SIZE];
BOOLEAN bOutStopped;
ULONG out_count;
BOOLEAN clear_op;
POINT input_pos[16]= {{470, 280}, {440, 280},
{410, 280}, {380, 280},
{350, 280}, {320, 280},
{ 290, 280}, {260, 280},
{230, 280}, {200, 280},
{170, 280}, {140, 280},
{110, 280}, {80, 280},
{ 50, 280}, { 20, 280},
};
POINT output_pos[16] ={
{470, 340}, {440, 340},
{410, 340}, {380, 340},
{350, 340}, {320, 340},
{ 290, 340}, {260, 340},
{230, 340}, {200, 340},
{170, 340}, {140, 340},
{110, 340}, {80, 340},
{ 50, 340}, { 20, 340},
};
POINT io_pos[16] ={
{395, 40}, {370, 40},
{345, 40}, {320, 40},
{295, 40}, {270, 40},
{ 245, 40}, {220, 40},
{195, 40}, {170, 40},
{145, 40}, {120, 40},
{95, 40}, {70, 40},
{ 45, 40}, { 20, 40},
};
BOOL InitApplication(HANDLE);
BOOL InitInstance(HANDLE, int);
void DI_DBCallBack();
void DI_CallBack();
int PASCAL WinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow)
HANDLE hInstance, hPrevInstance;
LPSTR lpCmdLine;
int nCmdShow;
{
MSG msg;
if (!hPrevInstance)
if (!InitApplication(hInstance)) return(FALSE);
if (!InitInstance(hInstance, nCmdShow)) return(FALSE);
while (GetMessage(&msg, NULL, NULL, NULL)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return(msg.wParam);
}
BOOL InitApplication(hInstance)
HANDLE hInstance;
{
WNDCLASS wc;
/* Main Window Class */
wc.style = NULL;
wc.lpfnWndProc = (WNDPROC)MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(hInstance, "MyIcon");
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = GetStockObject(LTGRAY_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "GenericWClass";
if (!RegisterClass(&wc)) return(FALSE);
}
BOOL InitInstance(hInstance, nCmdShow)
HANDLE hInstance;
int nCmdShow;
{
HWND hWnd;
HMENU hSampleMenu;
hInst = hInstance;
hSampleMenu = LoadMenu(hInstance, "U7120Menu");
hWnd = CreateWindow("GenericWClass",
(LPCSTR)"PCI-7300 Multiple Buffered DMA",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
520,
400,
NULL,
hSampleMenu,
hInstance,
NULL);
if (!hWnd) return(FALSE);
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return(TRUE);
}
BOOL PASCAL setup(HWND hWnd, unsigned message, WPARAM wParam, LPARAM lParam)
{
int i;
char n[16];
char s[50];
switch (message) {
case WM_INITDIALOG:
for (i=0;i<16;i++) {
wsprintf(n, "%d", i);
_strupr(n);
SendMessage(GetDlgItem(hWnd,IDC_COMBO1), CB_ADDSTRING, NULL, (LONG)(LPSTR) n);
}
SendMessage(GetDlgItem(hWnd,IDC_COMBO1) , CB_SETCURSEL, 0, 0L);
break;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDC_COMBO1:
if (HIWORD(wParam) == CBN_CLOSEUP) {
i = (int)SendMessage(GetDlgItem(hWnd,IDC_COMBO1), CB_GETCURSEL, 0, 0L);
SendMessage(GetDlgItem(hWnd,IDC_COMBO1), CB_GETLBTEXT, i, (LPARAM)((LPCSTR)n));
card_number = i;
}
return(TRUE);
case IDOK:
if ((card=Register_Card(PCI_7300A_RevB, card_number)) < 0) {
wsprintf(s, "Register_Card Error = %d\n", card);
MessageBox(hWnd, s, "Error", MB_OK);
}
EndDialog(hWnd, TRUE);
InvalidateRect(hWnd, NULL, FALSE);
return (TRUE);
case IDCANCEL:
EndDialog(hWnd, TRUE);
return (TRUE);
}
break;
}
return (FALSE);
}
long PASCAL MainWndProc(hWnd, message, wParam, lParam)
HWND hWnd;
UINT message;
WPARAM wParam;
LPARAM lParam;
{
HDC hDC;
PAINTSTRUCT ps;
int i;
char n[6];
SHORT err;
char s[50];
U16 BufferId;
switch(message) {
case WM_CREATE:
DialogBox(hInst,IDD_DIALOG2, hWnd, setup);
if(card<0) {
SendMessage(hWnd, WM_CLOSE, 0, 0L);
break;
}
err=DI_7300B_Config(card, 16, TRIG_CLK_10MHZ, P7300_WAIT_NO, P7300_TERM_ON, 0, 0, 0);
if (err !=0) {
wsprintf(s, "DI_7300B_Config Error = %d, card=%d\n", err, card);
MessageBox(hWnd, s, "Error", MB_OK);
SendMessage(hWnd, WM_CLOSE, 0, 0L);
break;
}
err=DO_7300B_Config (card, 16, TRIG_INT_PACER, P7300_WAIT_NO, P7300_TERM_ON, 0, 0x00040004);
if (err !=0) {
wsprintf(s, "DO_7300B_Config Error = %d, card=%d\n", err, card);
MessageBox(hWnd, s, "Error", MB_OK);
SendMessage(hWnd, WM_CLOSE, 0, 0L);
break;
}
for (i=0; i<MAX_SIZE; i++)
out_buf[i] = (U16)(sin((double)i/5000*PI)*0x7fff)+0x8000;
for (i=0; i<MAX_SIZE; i++) {
in_buf[i] = (U16)(0);
in_buf2[i] = (U16)(0);
in_buf3[i] = (U16)(0);
in_buf4[i] = (U16)(0);
}
hEdit=CreateWindow("EDIT", NULL,
WS_CHILD | WS_VISIBLE | ES_LEFT,
output_pos[13].x-30, input_pos[15].y+20,40, 20, hWnd, IDC_EDIT, hInst, NULL);
hEdit1=CreateWindow("EDIT", NULL,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -