// Copyright 2005 Doi Shigeki // list403.cpp LEDの点滅,mmtでトリガ // 〜PCIボードを使った外部制御の基礎 // fbippi.lib、winmm.libをリンクすること // #include #include #include #include #include"FbiPpi.h" void CALLBACK timerProc( UINT, UINT, DWORD, DWORD, DWORD); HANDLE h; BYTE m; main() { int r; int i; WORD timerid; printf("PCIのテスト3\n"); h = PpiOpen( "FBIPPI1", // デバイス名 0 ); // オープンフラグ if( h == INVALID_HANDLE_VALUE ){ printf("PCIデバイスがオープンできません\n"); return 0; } r = PpiControl( h, // デバイスハンドル FBIPPI_8255_CONTROLLER1 , // コントローラの指定 0x90 ); // 制御データ,モード0,PAのみ入力 printf("PPI制御結果 = %d( %d:ok) \n", r, FBIPPI_ERROR_SUCCESS ); m=0; // タイマー割り込み関数の登録 timerid = timeSetEvent(5, // 間隔[ms] 0, // 分解能:最高 timerProc, // タイマ関数 NULL, // ユーザーパラメータ TIME_PERIODIC | TIME_CALLBACK_FUNCTION // 動作フラグ ); if( !timerid ){ printf("タイマー登録に失敗"); return 0; } printf("1分後終了します\n"); Sleep( 60 * 1000); // タイマー割り込み関数の登録抹消 timeKillEvent( timerid ); CloseHandle( h ); } // タイマー割り込みの処理 void CALLBACK timerProc(UINT , UINT , DWORD , DWORD , DWORD ) { PpiOutputPort( h, // デバイスハンドル FBIPPI_8255_CONTROLLER1 , // コントローラ指定 FBIPPI_PORT_B, // ポート指定:B m ); // 出力データ m++; }