⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ircontrol.h

📁 pci 底层驱动
💻 H
字号:
/*+++ *******************************************************************\
*
*   Copyright and Disclaimer:
*
*       ---------------------------------------------------------------
*       This software is provided "as is" without warranty of any kind,
*       either expressed or implied, including but not limited to the
*       implied warranties of merchantability and/or fitness for a
*       particular purpose.
*
*       Copyright (c) 1999-2000 Conexant Systems, Inc.
*       All Rights Reserved.
*       ---------------------------------------------------------------
*
*   Module Revision Id:
*
*
*   Abstract:
*
*       This file contains the interface for the IR receiver access methods.
*
*   Revision History:
*
*
\******************************************************************* ---*/

#ifndef __IR_CONTROL_H
#define __IR_CONTROL_H

#include "registers.h"
#include "rc5decode.h"
#include "necDecode.h"
#include "hid.h"

//AUTO_REPEAT_COUNT is the number of messages thrown away after the initial keypress
// before auto-repeat starts.  This is so that the user has a chance to get a single
// message for a key press before it auto-repeats.
#define AUTO_REPEAT_COUNT 5

typedef enum{
  IR_STANDARD_RC5 = 0,
  IR_STANDARD_NEC = 1
}IR_STANDARD;

/////////////////////////////////////////////////////////////////////////////////////////
//Class IR_Control handles processing IR interrupts on the 880.  The 880 samples the IR
// input at regular intervals, and fills a register with 0's or 1's depending on the
// presense or absense of an IR signal.
//
// This class handles the interrupts, and then passes the signals to the IR decoder class. 
// (RC5Decode).  If a command was found, it converts it to an HID report using the IR 
// command class.  (RC5Command) and submits the report to the HID class
//

class IR_Control
{
public:
    // constructor and destructor
    IR_Control(
        RegisterIo* p_registers,
        HidProcessing* p_hid, 
        IR_STANDARD ir_standard,
        DWORD ir_command_table);
    ~IR_Control();

    VOID initialize();
    VOID uninitialize();

	//interrupt handling
    BOOLEAN interruptHandler(); 
	VOID enableInterrupt();
	VOID disableInterrupt();
    VOID clearInterrupt();
    BOOLEAN isIrInterrupt();

    VOID dpcRoutine(ULONG sample);

    static VOID static_dpcRoutine(
        PKDPC        dpc,
        IR_Control*  p_this,     
        ULONG        sample,     //IR sample
        PVOID        p_context2);  

protected:

private:
    RegisterIo*     _p_registers;
    HidProcessing*  _p_hid;
    KDPC            _dpc;

    IR_Decode*      _p_decoder;

    BOOLEAN         _send_key_up;
    BOOLEAN         _send_consumer_key_up;
    USHORT          _auto_repeat_count;
};

/////////////////////////////////////////////////////////////////////////////////////////
//IR_Control::enableInterrupt
//
// Enable IR interrupts
//
inline	VOID IR_Control::enableInterrupt()
{
    // Enable GP shift register interrupt
    DWORD int_mask = _p_registers->readDword(PCI_INTMSK);
    int_mask |= BIT(18);
    _p_registers->writeDword(PCI_INTMSK, int_mask);
}

/////////////////////////////////////////////////////////////////////////////////////////
//IR_Control::disableInterrupt
//
// Disable IR interrupts
//
inline	VOID IR_Control::disableInterrupt()
{
    // Disable GP shift register interrupt
    DWORD int_mask = _p_registers->readDword(PCI_INTMSK);
    int_mask &= ~BIT(18);
    _p_registers->writeDword(PCI_INTMSK, int_mask);
}

/////////////////////////////////////////////////////////////////////////////////////////
//IR_Control::clearInterrupt
//
// Clear an IR interrupt
//
inline	VOID IR_Control::clearInterrupt()
{
    _p_registers->writeDword(PCI_INTSTAT, BIT(18));
}

/////////////////////////////////////////////////////////////////////////////////////////
//IR_Control::isIrInterrupt
//
// Checks to see if the interrupt that occurred was an IR interrupt
//
inline	BOOLEAN IR_Control::isIrInterrupt()
{
    DWORD int_status = _p_registers->readDword(PCI_INTSTAT);
    DWORD int_mask = _p_registers->readDword(PCI_INTMSK);
    return ((int_status & BIT(18)) && (int_mask & BIT(18)));
}

/////////////////////////////////////////////////////////////////////////////////////////
//IR_Control::initialize
//
// Set up registers for receiving IR interrupts.  This is called from the constructor, 
// and should be called again when the device powers up.
//
inline VOID IR_Control::initialize()
{
    clearInterrupt();

	// Setup 4 KHz sampling for RC5 decode
    _p_registers->writeDword(DDS_IO, 0xA80A80);
    
    //Increment DDS on PCLK/64, shift right, and enable DDS
    _p_registers->writeDword(DDSCFG_IO, BIT(0) |BIT(2));    

	
    enableInterrupt();
}

inline VOID IR_Control::uninitialize()
{
    disableInterrupt();
    clearInterrupt();

    //Make sure the DPC isn't queued
    KeRemoveQueueDpc(&_dpc);

	//Disable DDS
    _p_registers->writeDword(DDSCFG_IO, 0);
}


#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -