fpga device driver design guide on windows 7 embedded · 2013-12-17 · fpga device driver design...
TRANSCRIPT
Guangzhou ZHIYUAN Electronics Co.,LTD
FPGA Device Driver
Design Guide on
Windows 7 Embedded
Yunrui Zhang
Contents
Driver Installation 1
2 Driver Library
Driver Design Guide 3
1. Driver Installation
② Select “PCI Device”.
① Open device manager.
1. Driver Installation
③ Right click on “PCI
Device“;
Select “Update Driver
Software…”.
1. Driver Installation
④ Select "Browse
my computer for
driver software”.
1. Driver Installation
⑤ Click “Browse...” to
select the driver path.
Then click “Next”.
1. Driver Installation
⑥ select “Install
this driver software
anyway”.
1. Driver Installation
⑦ 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
The steps to install drivers for
these devices are similar to
those for “PCI Device” (See
Step ② to Step ⑦).
⑧ Install drivers for the
“other devices”.
1. Driver Installation
After installation is
complete:
a). A new type of device
class is added: "ArCore
Chipset Device“.
2. Driver Library
ADC Device Object 1
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 Meaning
ppIAiObj Pointer to a Pointer to the IAiObject
Index The index of ADC device
Parameters of AiCreate:
Return Value:
Return zreo if there is no error occurred, otherwise return non-zero value.
2.1 ADC Device Object
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;
};
Prototype of
IAiObject:
2.1 ADC Device Object
• Close a specified ADC device object:
void __stdcall
AiClose(
IAiObject* pIAiObj
);
2.1 ADC Device Object
Parameters Meaning
ppIAiObj Pointer to the IAiObject
Parameters of AiClose:
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 Meaning
pContext Reserved ,must be NULL
Parameters of Initialize:
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 Meaning
ByteWidth Pointer to the number of the bytes for
the data returned by the ADC
BitWidth Pointer to the number of bits of the
ADC device
Parameters of GetADCInfo:
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
Parameter Meaning
lpszName Pointer to the device name
pdwReqiredSize Pointer to the number of bytes
required for the device name
Parameters of GetDeviceName:
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:
Return Value:
Return zreo if there is no error occurred, otherwise return non-zero value.
None Parameters to input.
2.1 ADC Device Object
• Stop A/D conversion function:
DWORD __stdcall Stop();
2.1 ADC Device Object
Parameters of Stop:
Return Value:
Return zreo if there is no error occurred, otherwise return non-zero value.
None Parameters to input.
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
Parameter Meaning
pADCallback Specifies the entry point for the user-
supplied A/D data convert handler
callback routine
pADContext Pointer to a user-determined context
to pass to the A/D data convert
handler callback routine
Parameters of RegisterADCallback :
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
Parameter Meaning
dwRawData The raw data get from the AD
converter
pADContext Pointer to a user-determined context
Parameters of AD_CONVERT_CALLBACK:
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 Meaning
ppIAoObj Pointer to a Pointer to the IAoObject
Index The index of DAC device
Parameters of AoCreate:
Return Value:
Return zreo if there is no error occurred, otherwise return non-zero value.
2.2 DAC Device Object
struct IAoObject
{
virtual DWORD __stdcall Initialize(
IN void *pContext) = 0;
virtual DWORD __stdcall SendAoData(
IN USHORT *pTxBuffer,
IN unsigned long dwBufferSize) = 0;
};
Prototype of IAoObject :
2.2 DAC Device Object
• Close a specified DAC device object:
void __stdcall
AoClose(
IAoObject* pIAoObj
);
2.2 DAC Device Object
Parameters Meaning
ppIAoObj Pointer to the IAoObject
Parameters of AoClose:
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 Meaning
pContext Reserved ,must be NULL
Parameters of Initialize:
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
Parameter Meaning
pTxBuffer Pointer to the DAC write buffer
dwBufferSize The size of the DAC write buffer
Parameters of SendAoData:
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 Meaning
ppIGpioObj Pointer to a Pointer to the
IGpioObject
Index The index of GPIO device
Parameters of GpioCreate :
Return Value:
Return zreo if there is no error occurred, otherwise return non-zero value.
2.3 GPIO Device Object
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;
};
Prototype of IGpioObject :
2.3 GPIO Device Object
• Close a specified GPIO device object:
void __stdcall
GpioClose(
IGpioObject* pIGpioObj
);
2.3 GPIO Device Object
Parameters Meaning
pIGpioObj Pointer to the IGpioObject
Parameters of GpioClose :
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 Meaning
pContext Reserved ,must be NULL
Parameters of Initialize:
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
Parameter Meaning
pEventProcRoutine Specifies the entry point for the user-
supplied GPIO event handler callback
routine
pEventProcContext Pointer to a user-determined context
to pass to the GPIO event handler
callback routine
Parameters of RegisterEventProc:
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
Parameter Meaning
Event Event message type
wParam Status of the switch or buttons
lParam 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
Context Pointer to a user-determined context
Parameters of GPIO_EVENT_PROC_ROUTINE:
Return Value:
None value to return.
2.3 GPIO Device Object
Event type Meaning
GPIO_SWITCH_CHANGED Switch statue is changed
GPIO_BUTTON_DOWN Button down
GPIO_BUTTON_UP Button up
The enumeration values of Event:
2.3 GPIO Device Object
• Set LED state:
DWORD __stdcall
SetLEDState(
DWORD State
);
2.3 GPIO Device Object
Parameters Meaning
State The lower 8 bits of pSate are
corresponding to the states of 8 LEDs
Parameters of SetLEDState:
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 Meaning
pState The lower 8 bits of pSate are
corresponding to the states of 8 LEDs
Parameters of GetLEDState:
Return Value:
Return zreo if there is no error occurred, otherwise return non-zero value.
2.4 Video Capture And Net
Video Capture
NET
DirectShow. Refer to platform SDK Documentation.
Windows Sockets. Refer to platform SDK Documentation.
3. Driver Design Guide
Hardware Architecture
Driver Stack of FPGA Device
Supported Drivers And Driver Type
Driver Development Tools
Implement A Driver
Summary Driver Design Guide
3. Driver Design Guide
Intel® Atom™
Processor
Intel® Atom™ E6x5C
Altera® Arria® IIEP2AGXE6XX FPGA
PCIe
COMe Connector 2
I/O
Ban
k 7
I/O
Ban
k 6
4Buttons
4Switches
8Leds
VideoDecoder
AnalogVideoInput
10-bit DAC
10Msps
8-bitADC
10Msps
12-bit ADC
400Ksps
PHY
Altera TSE
Hardware Architecture
3. Driver Design Guide
Driver Stack of FPGA Device
PCI Bus
(pci.sys)
FPGA
(arcore.sys)
ADC
(aradc.sys)
DAC
(ardac.sys)
GPIO
(argpio.sys)
VIDEO
(arvideo.sys)
NET
(arndis.sys)
Parent Device
Child Device
3. Driver Design Guide
ZLG Supported Drivers
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
Bus Driver — FPGA bus driver, ArCore.sys
3. Driver Design Guide
Hardware
Kernel / HAL
Device Driver
API DLL
Application
User
Kernel
Generic WDM Device Driver Overview
DDI (Device Driver Interface)
API (Application Interface)
3. Driver Design Guide
Video Capture Driver Overview
Port Class Stream Class AVStream
Ks
audio
minidrivers
DVD video
capture
audio or video
minidrivers
Microsoft
supplied
Vendor
supplied
3. Driver Design Guide
NDIS miniport
Net Card
NDIS Interface
Transport Driver
Interface (TDI)
LAN Protocols Native Media
Aware Protocol
Vendor
supplied
Net Device Driver Overview
Microsoft
supplied
3. Driver Design Guide
Driver Development Tools
WDK Version 7600.16385.0
WinDbg or Other Debug Tools
Visual Studio (optional)
ESDC Hardware Platform
System Symbols (for debugging driver)
3. Driver Design Guide
Implement ADC/DAC Drivers
ADC/DAC Running After Power On
ADC/DAC No FIFO, No Interrupt Generated
Driver Must Polling the ADC/DAC
Assume Bus Driver is Working as Design
3. Driver Design Guide
Build ADC/DAC Drivers