FPGA Device Driver Design Guide on Windows 7 Embedded Yunrui Zhang Guangzhou ZHIYUAN Electronics Co.,LTD
Contents 1 Driver Installation 2 Driver Library 3 Driver Design Guide
1. Driver Installation 1 Open device manager. 2 Select PCI Device.
1. Driver Installation 3 Right click on PCI Device ; Select Update Driver Software.
1. Driver Installation 4 Select "Browse my computer for driver software.
1. Driver Installation 5 Click Browse... to select the driver path. Then click Next.
1. Driver Installation 6 select Install this driver software anyway.
1. Driver Installation 7 After installation is complete: Click Close to return.
1. Driver Installation Driver for PCI Device is successfully installed : a). The ArCore Chipset System Driver will appear under the System devices ; b). Several devices are enumerated by ArCore Chipset System Driver.
1. Driver Installation 8 Install drivers for the other devices. The steps to install drivers for these devices are similar to those for PCI Device (See Step 2 to Step 7).
1. Driver Installation After installation is complete: a). A new type of device class is added: "ArCore Chipset Device.
2. Driver Library 1 ADC Device Object 2 DAC Device Object 3 GPIO Device Object 4 Video Capture And Net
2.1 ADC Device Object The method to operate ADC devices: AiCreate AiClose Initialize GetADCInfo GetDeviceName Start Stop RegisterADCallback
2.1 ADC Device Object Create an ADC device object with device index : DWORD stdcall AiCreate( IAiObject** ppiaiobj, int Index );
2.1 ADC Device Object Parameters of AiCreate: Parameters ppiaiobj Index Meaning Pointer to a Pointer to the IAiObject The index of ADC device Return Value: Return zreo if there is no error occurred, otherwise return non-zero value.
2.1 ADC Device Object Prototype of IAiObject: struct IAiObject { virtual DWORD stdcall Initialize( IN void *pcontext) = 0; virtual DWORD stdcall RegisterADCallback( IN AD_CONVERT_CALLBACK padcallback, IN void *padcontext) = 0; virtual DWORD stdcall GetADCInfo( IN OUT int *ByteWidth, IN OUT int *BitWidth) = 0; virtual DWORD stdcall GetDeviceName( IN OUT void* lpszname, IN OUT DWORD* pdwreqiredsize) = 0; virtual DWORD stdcall Start() = 0; virtual DWORD stdcall Stop() = 0; };
2.1 ADC Device Object Close a specified ADC device object: void stdcall AiClose( IAiObject* piaiobj );
2.1 ADC Device Object Parameters of AiClose: Parameters ppiaiobj Meaning Pointer to the IAiObject Return Value: None value to return.
2.1 ADC Device Object Initialize device function: DWORD stdcall Initialize( void* pcontext, );
2.1 ADC Device Object Parameters of Initialize: Parameters pcontext Meaning Reserved,must be NULL Return Value: Return zreo if there is no error occurred, otherwise return non-zero value.
2.1 ADC Device Object Read ADC Device information function: DWORD stdcall GetADCInfo( int* ByteWidth, int* BitWidth );
2.1 ADC Device Object Parameters of GetADCInfo: Parameters ByteWidth BitWidth Meaning Pointer to the number of the bytes for the data returned by the ADC Pointer to the number of bits of the ADC device Return Value: Return zreo if there is no error occurred, otherwise return non-zero value.
2.1 ADC Device Object Read ADC device name function: DWORD stdcall GetDeviceName( void* lpszname, DWORD* pdwreqiredsize );
2.1 ADC Device Object Parameters of GetDeviceName: Parameter lpszname pdwreqiredsize Meaning Pointer to the device name Pointer to the number of bytes required for the device name Return Value: Return zreo if there is no error occurred, otherwise return non-zero value.
2.1 ADC Device Object Start A/D Conversion function: DWORD stdcall Start();
2.1 ADC Device Object Parameters of Start: None Parameters to input. Return Value: Return zreo if there is no error occurred, otherwise return non-zero value.
2.1 ADC Device Object Stop A/D conversion function: DWORD stdcall Stop();
2.1 ADC Device Object Parameters of Stop: None Parameters to input. Return Value: Return zreo if there is no error occurred, otherwise return non-zero value.
2.1 ADC Device Object Register A/D data convert handler callback routine : DWORD stdcall RegisterADCallback( AD_CONVERT_CALLBACK padcallback, void* padcontext );
2.1 ADC Device Object Parameters of RegisterADCallback : Parameter padcallback padcontext Meaning Specifies the entry point for the usersupplied A/D data convert handler callback routine Pointer to a user-determined context to pass to the A/D data convert handler callback routine Return Value: Return zreo if there is no error occurred, otherwise return non-zero value.
2.1 ADC Device Object Prototype of A/D data convert handler routine : void ( stdcall *AD_CONVERT_CALLBACK)( ); DWORD dwrawdata, void* Context
2.1 ADC Device Object Parameters of AD_CONVERT_CALLBACK: Parameter dwrawdata padcontext Meaning The raw data get from the AD converter Pointer to a user-determined context Return Value: None value to return.
2.2 DAC Device Object Method to operate DAC device: AoCreate AoClose Initialize SendAoData
2.2 DAC Device Object Create a DAC device object with device index : DWORD stdcall AoCreate( IAoObject** ppiaoobj, int Index );
2.2 DAC Device Object Parameters of AoCreate: Parameters ppiaoobj Index Meaning Pointer to a Pointer to the IAoObject The index of DAC device Return Value: Return zreo if there is no error occurred, otherwise return non-zero value.
2.2 DAC Device Object Prototype of IAoObject : struct IAoObject { virtual DWORD stdcall Initialize( IN void *pcontext) = 0; }; virtual DWORD stdcall SendAoData( IN USHORT *ptxbuffer, IN unsigned long dwbuffersize) = 0;
2.2 DAC Device Object Close a specified DAC device object: void stdcall AoClose( IAoObject* piaoobj );
2.2 DAC Device Object Parameters of AoClose: Parameters ppiaoobj Meaning Pointer to the IAoObject Return Value: None value to return.
2.2 DAC Device Object Initialize device function: DWORD stdcall Initialize( void* pcontext, );
2.2 DAC Device Object Parameters of Initialize: Parameters pcontext Meaning Reserved,must be NULL Return Value: Return zreo if there is no error occurred, otherwise return non-zero value.
2.2 DAC Device Object Write data to DAC function: DWORD stdcall SendAoData( USHORT * ptxbuffer, unsigned long dwbuffersize );
2.2 DAC Device Object Parameters of SendAoData: Parameter ptxbuffer dwbuffersize Meaning Pointer to the DAC write buffer The size of the DAC write buffer Return Value: Return zreo if there is no error occurred, otherwise return non-zero value.
2.3 GPIO Device Object Method to operate GPIO interfaces: GpioCreate GpioClose Initialize RegisterEventProc SetLEDState GetLEDState
2.3 GPIO Device Object Create a GPIO device object with device index : DWORD stdcall GpioCreate( IGpioObject** ppigpioobj, int Index );
2.3 GPIO Device Object Parameters of GpioCreate : Parameters ppigpioobj Index Return Value: Meaning Pointer to a Pointer to the IGpioObject The index of GPIO device Return zreo if there is no error occurred, otherwise return non-zero value.
2.3 GPIO Device Object Prototype of IGpioObject : struct IGpioObject { virtual DWORD stdcall Initialize( void *pcontext) = 0; virtual DWORD stdcall RegisterEventProc( GPIO_EVENT_PROC_ROUTINE peventprocroutine, void *peventproccontext) = 0; virtual DWORD stdcall SetLEDState( DWORD State) = 0; virtual DWORD stdcall GetLEDState( DWORD* psate) = 0; };
2.3 GPIO Device Object Close a specified GPIO device object: void stdcall GpioClose( IGpioObject* pigpioobj );
2.3 GPIO Device Object Parameters of GpioClose : Parameters pigpioobj Meaning Pointer to the IGpioObject Return Value: None value to return.
2.3 GPIO Device Object Initialize device function: DWORD stdcall Initialize( void* pcontext, );
2.3 GPIO Device Object Parameters of Initialize: Parameters pcontext Meaning Reserved,must be NULL Return Value: Return zreo if there is no error occurred, otherwise return non-zero value.
2.3 GPIO Device Object Register GPIO event handler callback routine : DWORD stdcall RegisterEventProc( GPIO_EVENT_PROC_ROUTINE peventprocroutine, void* peventproccontext );
2.3 GPIO Device Object Parameters of RegisterEventProc: Parameter peventprocroutine peventproccontext Meaning Specifies the entry point for the usersupplied GPIO event handler callback routine Pointer to a user-determined context to pass to the GPIO event handler callback routine Return Value: Return zreo if there is no error occurred, otherwise return non-zero value.
2.3 GPIO Device Object Prototype of GPIO event handler callback routine : void ( stdcall* GPIO_EVENT_PROC_ROUTINE)( int Event, int wparam, int lparam, void* Context );
2.3 GPIO Device Object Parameters of GPIO_EVENT_PROC_ROUTINE: Parameter Event wparam lparam Context Meaning Event message type Status of the switch or buttons Switch message : reserved Button message : the index of the button, if more than one button s state is changed or there are one or more buttons are held, lparam will be negative one Pointer to a user-determined context Return Value: None value to return.
2.3 GPIO Device Object The enumeration values of Event: Event type GPIO_SWITCH_CHANGED GPIO_BUTTON_DOWN GPIO_BUTTON_UP Meaning Switch statue is changed Button down Button up
2.3 GPIO Device Object Set LED state: DWORD stdcall SetLEDState( DWORD State );
2.3 GPIO Device Object Parameters of SetLEDState: Parameters State Meaning The lower 8 bits of psate are corresponding to the states of 8 LEDs Return Value: Return zreo if there is no error occurred, otherwise return non-zero value.
2.3 GPIO Device Object Get LED state: DWORD stdcall GetLEDState( DWORD* pstate );
2.3 GPIO Device Object Parameters of GetLEDState: Parameters pstate Meaning The lower 8 bits of psate are corresponding to the states of 8 LEDs Return Value: Return zreo if there is no error occurred, otherwise return non-zero value.
2.4 Video Capture And Net Video Capture DirectShow. Refer to platform SDK Documentation. NET Windows Sockets. Refer to platform SDK Documentation.
3. Driver Design Guide Summary Driver Design Guide Hardware Architecture Driver Stack of FPGA Device Supported Drivers And Driver Type Driver Development Tools Implement A Driver
I/O Bank 7 I/O Bank 6 3. Driver Design Guide Hardware Architecture Intel Atom Processor PCIe Altera Arria II EP2AGXE6XX FPGA Intel Atom E6x5C COMe Connector 2 PHY Video Decoder Altera TSE 12-bit ADC 400Ksps 8-bit ADC 10Msps 10-bit DAC 10Msps Analog Video Input 8 Leds 4 Switches 4 Buttons
3. Driver Design Guide Driver Stack of FPGA Device ADC (aradc.sys) DAC (ardac.sys) GPIO (argpio.sys) VIDEO (arvideo.sys) NET (arndis.sys) Child Device FPGA (arcore.sys) Parent Device PCI Bus (pci.sys)
3. Driver Design Guide ZLG Supported Drivers Bus Driver FPGA bus driver, ArCore.sys ADC One 8bit ADC and 12bit ADC Input DAC One 10bit DAC Output GPIO 8 LED Output, 4 Button Input, 4 Switch Input Video Capture AVStream minidriver Net Driver NDIS miniport driver
3. Driver Design Guide Generic WDM Device Driver Overview Application API (Application Interface) User Kernel API DLL Device Driver DDI (Device Driver Interface) Kernel / HAL Hardware
3. Driver Design Guide Video Capture Driver Overview Ks Microsoft supplied Port Class Stream Class AVStream Vendor supplied audio minidrivers DVD video capture audio or video minidrivers
3. Driver Design Guide Net Device Driver Overview Transport Driver Interface (TDI) Microsoft supplied LAN Protocols Native Media Aware Protocol Vendor supplied NDIS Interface NDIS miniport Net Card
3. Driver Design Guide Driver Development Tools ESDC Hardware Platform WDK Version 7600.16385.0 WinDbg or Other Debug Tools System Symbols (for debugging driver) Visual Studio (optional)
3. Driver Design Guide Implement ADC/DAC Drivers Assume Bus Driver is Working as Design ADC/DAC Running After Power On ADC/DAC No FIFO, No Interrupt Generated Driver Must Polling the ADC/DAC
3. Driver Design Guide Build ADC/DAC Drivers