xilinx sdk c语言 教程,Xilinx SDK API函数的使用方法 未完待续

本文主要参考Xlinx的Device Driver Programmer Guide

Device Driver特点

提供最大的兼容性

使用标准的C语言编写

设备驱动层和操作系统层、处理器分离

支持FPGA重配置

支持动态重配置

不复制代码可以例化多个设备

支持简单和复杂的使用方法

可根据需求去调整面积与速度的优化

方便使用和维护

不同的设备驱动API都有着相似的风格

Device Driver结构

0818b9ca8b590ca3270a3433284dd417.png

带有API函数的是Layer1和Layer2,Direct Hardware Interface只有一些宏定义的常量

Layer 2 (RTOS Adapter)

Adapters 典型特点.

Communicates directly to the RTOS as well as the Layer 1 interface of the device driver.

References functions and identifiers specific to the RTOS. This layer is therefore not portable across operating systems.

Can use memory management

Can use RTOS services such as threading, inter-task communication, etc.

Can be simple or complex depending on the RTOS interface and requirements for the device driver

Layer 1 (Device Driver)

Device Driver典型特点

Consistent API that gives the user an “out-of-the-box” solution. The abstract API helps isolate the user from hardware changes.

No RTOS or processor dependencies, making the device driver highly portable

Run-time error checking such as assertion of input arguments, and provides the ability to compile away asserts.

Comprehensive support of device features

Supports device configuration parameters to handle FPGA-based parameterization of hardware devices.

Supports multiple instances of a device while managing unique characteristics on a per instance basis.

Polled and interrupt driven I/O

Non-blocking function calls to aid complex applications

May have a large memory footprint

Typically provides buffer interfaces for data transfers as opposed to byte interfaces. This makes the API easier to use for complex applications.

Does not communicate directly to Layer 2 adapters or application software. Utilizes asynchronous callbacks for upward communication.

Direct Hardware Interface

典型特点

Constants that define the device register offsets and bit fields, and simple macros that give the user access to the hardware registers

Small memory footprint

Little to no error checking is performed

Minimal abstraction such that the API typically matches the device registers. The API is therefore less isolated from hardware device changes.

No support of device configuration parameters

Supports multiple instances of a device with base address input to the API

No, or minimal, state is maintained

Polled I/O only

Blocking functions for simple use cases

Typically provides byte interfaces

命名规则

外部标识符(External Identifiers)

External Name Pattern:

X[driver_name]_VariableName;

X[driver_name]_FunctionName(ArgumentType Argument)

X[driver_name]_TypeName;

For example, a driver named XUartLite (for the UART Lite device driver) would have constants that begin with XUL_, and a driver named XEmac (for the Ethernet 10/100 device driver) would have constants that begin with XEM_.

文件命名规则(File Naming Conventions)

Driver Source File Names

每一个文件都有一个小写的 “x”

Implementation Source Files (*.c)

Source File Naming Pattern:

x[driver_name].c main source file

x[driver_name]_functionality.c secondary source file

Header Source Files (*.h)

The high-level, abstract interface (Layer 1) for a driver is contained in a header file with the file name format x[driver_name].h.

The direct hardware interface is contained in a header file with the file name format x_hw.h (or x[driver_name]_l.h).

The internal interfaces are contained in a header file with the file name format

x[driver_name]_i.h.

Device Driver Layers

Example File Names

The following source file names illustrates an example which is complex enough to utilize multiple C source files.

xuartns550.c Main implementation file

xuartns550_intr.c Secondary implementation file for interrupt handling

xuartns550.h High level external interfaces header file

xuartns550_i.h Internal identifiers header file

xuartns550_l.h Low level external interfaces header file

xuartns550_l.c Low level implementation file

xuartns550_g.c Generated file controlling parameterized

instances and, xuartns550_sio_adapter.c VxWorks Serial I/O (SIO) adapter

上面文件的命名规则

Layer 1 and the direct hardware interface (i.e., high-level and low-level driver interfaces) are bundled together in a directory. The direct hardware interface files are named x[driver_name]_hw.h (or _l.h) and sometimes x[driver_name]_hw.c (or _l.c). The “_hw” indicates hardware-specific definitions. Layer 2 RTOS adapter files typically include the word “adapter” in the file name, such as x[driver_name]_adapter.h and x[driver_name]_adapter.c.These are stored in a different directory name (e.g., one specific to the RTOS) than the device driver files.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一些关于Xilinx SDK使用教程和解决方案: 1. 如何打开Xilinx SDK项目: - 打开Xilinx SDK。 - 在“File”菜单中选择“Open Projects from File System”选项。 - 在弹出的对话框中选择“Directory”选项,并浏览到您的项目文件夹。 - 单击“Finish”按钮以打开项目。 2. 如何设置保存代码自动编译: - 在Xilinx SDK中,选择“Project”菜单,然后选择“Properties”选项。 - 在弹出的对话框中,选择“C/C++ Build”选项。 - 在右侧的选项卡中选择“Behavior”选项。 - 在“Build (Incremental Build)”部分,勾选“Build Automatically”选项。 - 单击“Apply”按钮以保存更改。 3. 如何链接库: - 在Xilinx SDK中,选择“Project”菜单,然后选择“Properties”选项。 - 在弹出的对话框中,选择“C/C++ Build”选项。 - 在右侧的选项卡中选择“Settings”选项。 - 在左侧的列表中选择“Tool Settings”下的“Libraries”选项。 - 在右侧的“Libraries”部分,单击“Add”按钮并选择要链接的库文件。 - 单击“Apply”按钮以保存更改。 4. 如何设置编译的.elf文件为release或debug版: - 在Xilinx SDK中,选择“Project”菜单,然后选择“Properties”选项。 - 在弹出的对话框中,选择“C/C++ Build”选项。 - 在右侧的选项卡中选择“Behavior”选项。 - 在“Build (Incremental Build)”部分,选择“Release”或“Debug”选项。 - 单击“Apply”按钮以保存更改。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值