Documentation-spi-spidev.txt

Chinese translated version of Documentation-spi-spidev.txt

If you have any comment or update to the content, please contact the
original document maintainer directly.  However, if you have a problem
communicating in English you can also ask the Chinese maintainer for
help.  Contact the Chinese maintainer if this translation is outdated
or if there is a problem with the translation.

Chinese maintainer: majg <1519014266@qq.com>
---------------------------------------------------------------------
Documentation-spi-spidev.txtt的中文翻译

如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文
交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻
译存在问题,请联系中文版维护者。

中文版维护者: 马建刚  majg <1519014266@qq.com>
中文版翻译者: 马建刚  majg <1519014266@qq.com>
中文版校译者: 马建刚  majg <1519014266@qq.com>

 

 

以下为正文
---------------------------------------------------------------------
  1 SPI devices have a limited userspace API, supporting basic half-duplex
  2 read() and write() access to SPI slave devices.  Using ioctl() requests,
  3 full duplex transfers and device I/O configuration are also available.
-SPI器件有一个有限的用户空间API,支持基本半双工的read(),write()
的访问SPI从属设备。使用ioctl()请求,全双工的传输和设备I / O配置也可。
  4
  5         #include <fcntl.h>
  6         #include <unistd.h>
  7         #include <sys/ioctl.h>
  8         #include <linux/types.h>
  9         #include <linux/spi/spidev.h>
 10
 11 Some reasons you might want to use this programming interface include:
-你可能想使用这种编程接口的一些原因包括:
 12
 13  * Prototyping in an environment that's not crash-prone; stray pointers
 14    in userspace won't normally bring down any Linux system.
-原型的环境中,不容易崩溃;在用户空间的指针通常不会带来任何Linux系统。
 15
 16  * Developing simple protocols used to talk to microcontrollers acting
 17    as SPI slaves, which you may need to change quite often.
-开发用于微控制器作为SPI附件,你可能需要经常改变说话的简单协议。
 18
 19 Of course there are drivers that can never be written in userspace, because
 20 they need to access kernel interfaces (such as IRQ handlers or other layers
 21 of the driver stack) that are not accessible to userspace.
-当然也有永远不会被写入的驱动程序可以在用户空间,因为他们需要访问
内核接口(如IRQ处理程序或其他驱动程序堆栈层)的不能访问用户空间。
 22
 23
 24 DEVICE CREATION, DRIVER BINDING
 25 ===============================
 26 The simplest way to arrange to use this driver is to just list it in the
 27 spi_board_info for a device as the driver it should use:  the "modalias"
 28 entry is "spidev", matching the name of the driver exposing this API.
 29 Set up the other device characteristics (bits per word, SPI clocking,
 30 chipselect polarity, etc) as usual, so you won't always need to override
 31 them later.
-安排使用此驱动程序最简单的方法是只在spi_board_info列出设备的驱动程序,
应该使用:MODALIAS“条目的”spidev“,,揭露这个API的名称相匹配的驱动程
序。设置其他设备特性(每字位,SPI时钟,片选极性等),像往常一样,所以
你不会总是需要覆盖它们。
 32
 33 (Sysfs also supports userspace driven binding/unbinding of drivers to
 34 devices.  That mechanism might be supported here in the future.)
-(sysfs中还支持绑定/解除绑定的驱动程序的设备的用户空间的驱动机制可能在未来支持)。
 35
 36 When you do that, the sysfs node for the SPI device will include a child
 37 device node with a "dev" attribute that will be understood by udev or mdev.
 38 (Larger systems will have "udev".  Smaller ones may configure "mdev" into
 39 busybox; it's less featureful, but often enough.)  For a SPI device with
 40 chipselect C on bus B, you should see:
-当你这样做,为SPI设备的sysfs节点将包括“dev”属性的一个子设备节点由udev或MDEV将会理解。
(较大的系统将有“udev的”较小的可配置“的mdev”到busybox的,它是较少的其他功能,但往往不够)。
对于一个SPI片选设备与总线B C对,你应该看到:
 41
 42     /dev/spidevB.C ... character special device, major number 153 with
 43         a dynamically chosen minor device number.  This is the node
 44         that userspace programs will open, created by "udev" or "mdev".
-/dev/spidevB.C ... 字符专用设备,主要与动态选择次要设备号的153号。
在这个节点上,用户空间程序就会打开,通过的“udev的”或“的mdev”创建。
 45
 46     /sys/devices/.../spiB.C ... as usual, the SPI device node will
 47         be a child of its SPI master controller.
- /sys/devices/.../spiB.C ...像往常一样,SPI设备节点将其SPI主控制器的孩子节点。
 48
 49     /sys/class/spidev/spidevB.C ... created when the "spidev" driver
 50         binds to that device.  (Directory or symlink, based on whether
 51         or not you enabled the "deprecated sysfs files" Kconfig option.)
- /sys/class/spidev/spidevB.C ...“spidev”驱动程序时创建绑定到该设备。
(目录或符号链接,您是否启用了“过时的sysfs文件”的Kconfig选项的基础上。)
 52
 53 Do not try to manage the /dev character device special file nodes by hand.
 54 That's error prone, and you'd need to pay careful attention to system
 55 security issues; udev/mdev should already be configured securely.
-不要试图手工管理在/ dev字符设备特殊文件节点。这是容易出错,你需要特别
注意系统的安全性问题,应该已经安全地配置使用udev/ MDEV。
 56
 57 If you unbind the "spidev" driver from that device, those two "spidev" nodes
 58 (in sysfs and in /dev) should automatically be removed (respectively by the
 59 kernel and by udev/mdev).  You can unbind by removing the "spidev" driver
 60 module, which will affect all devices using this driver.  You can also unbind
 61 by having kernel code remove the SPI device, probably by removing the driver
 62 for its SPI controller (so its spi_master vanishes).
-如果解除“spidev”来自该设备的驱动程序,这两个的“spidev”节点(在sysfs中在/ dev)
应自动删除(分别由内核和由udev/ MDEV)。您可以解除通过删除“spidev”驱动模块,
这将影响所有使用此驱动程序的设备。你可以解除通过内核代码删除SPI设备,可能是
通过其SPI控制器(所以其spi_master消失)删除驱动程序。
 63
 64 Since this is a standard Linux device driver -- even though it just happens
 65 to expose a low level API to userspace -- it can be associated with any number
 66 of devices at a time.  Just provide one spi_board_info record for each such
 67 SPI device, and you'll get a /dev device node for each device.
-由于这是一个标准的Linux设备驱动程序 - 即使它恰好是一个低级别的API暴露给用户空间 -
它可以与任意数量的设备在同一时间。只需提供一个spi_board_info的记录为每个这样的SPI
器件,,你会得到一个/ dev设备节点的每个设备。
 68
 69
 70 BASIC CHARACTER DEVICE API
-基本字符设备API
 71 ==========================
 72 Normal open() and close() operations on /dev/spidevB.D files work as you
 73 would expect.
-通常open() 和close()操作在/ dev/ spidev.D的文件上工作如你所期望。
 74
 75 Standard read() and write() operations are obviously only half-duplex, and
 76 the chipselect is deactivated between those operations.  Full-duplex access,
 77 and composite operation without chipselect de-activation, is available using
 78 the SPI_IOC_MESSAGE(N) request.
-标准read() 和write()操作是明显半双工,这些业务之间的片选无效。全双工的
连接,复合片选操作,而不去激活,是可以使用的SPI_IOC_MESSAGE(N)请求。
 79
 80 Several ioctl() requests let your driver read or override the device's current
 81 settings for data transfer parameters:
-几个ioctl()请求,让你的驱动器读取或覆盖设备的数据传输参数的当前设置:
 82
 83     SPI_IOC_RD_MODE, SPI_IOC_WR_MODE ... pass a pointer to a byte which will
 84         return (RD) or assign (WR) the SPI transfer mode.  Use the constants
 85         SPI_MODE_0..SPI_MODE_3; or if you prefer you can combine SPI_CPOL
 86         (clock polarity, idle high iff this is set) or SPI_CPHA (clock phase,
 87         sample on trailing edge iff this is set) flags.
- SPI_IOC_RD_MODE, SPI_IOC_WR_MODE ... 传递一个指针,它将返回一个字节(RD),
或分配(WR)SPI传输模式。使用的常数SPI_MODE_0 SPI_MODE_3,或者如果你愿意
,你可以结合SPI_CPOL(clock polarity, idle high 当且仅当此设置)或SPI_CPHA(clock phase,
 87sample on trailing edge当且仅当它被设置)标志。
 88
 89     SPI_IOC_RD_LSB_FIRST, SPI_IOC_WR_LSB_FIRST ... pass a pointer to a byte
 90         which will return (RD) or assign (WR) the bit justification used to
 91         transfer SPI words.  Zero indicates MSB-first; other values indicate
 92         the less common LSB-first encoding.  In both cases the specified value
 93         is right-justified in each word, so that unused (TX) or undefined (RX)
 94         bits are in the MSBs.
- SPI_IOC_RD_LSB_FIRST, SPI_IOC_WR_LSB_FIRST ... 传递一个指针,它将返回一个字节(RD),
或分配(WR)用来传输SPI字位的理由。零表示MSB优先,其他值表示的是不太常见的LSB优
先编码。在这两种情况下,指定的值是右对齐的每一个字,使未使用(TX)或未定义(RX)
的MSB位。
 95
 96     SPI_IOC_RD_BITS_PER_WORD, SPI_IOC_WR_BITS_PER_WORD ... pass a pointer to
 97         a byte which will return (RD) or assign (WR) the number of bits in
 98         each SPI transfer word.  The value zero signifies eight bits.
-SPI_IOC_RD_BITS_PER_WORD, SPI_IOC_WR_BITS_PER_WORD ... 传递一个指针,它将返回一个字节(RD),
或在每个SPI传输字的位分配(WR)。零值表示八位。
 99
100     SPI_IOC_RD_MAX_SPEED_HZ, SPI_IOC_WR_MAX_SPEED_HZ ... pass a pointer to a
101         u32 which will return (RD) or assign (WR) the maximum SPI transfer
102         speed, in Hz.  The controller can't necessarily assign that specific
103         clock speed.
- SPI_IOC_RD_MAX_SPEED_HZ, SPI_IOC_WR_MAX_SPEED_HZ ... 传递一个指针,它将返回到U32(RD),
或分配(WR)的最大的SPI传输速度,单位为Hz。该控制器可不一定指派特定的时钟速度。
104
105 NOTES:
106
107     - At this time there is no async I/O support; everything is purely
108       synchronous.
-- 在这个时候,没有任何异步I / O支持;一切纯粹是同步的。
109
110     - There's currently no way to report the actual bit rate used to
111       shift data to/from a given device.
-- 目前有没有办法报告的实际比特率用于转移数据 to/from一个给定的设备。
112
113     - From userspace, you can't currently change the chip select polarity;
114       that could corrupt transfers to other devices sharing the SPI bus.
115       Each SPI device is deselected when it's not in active use, allowing
116       other drivers to talk to other devices.
-- 从用户空间,你可以目前没有改变芯片选择极性可能破坏传输到其他设备共享SPI总线。
每个SPI设备没有被选中时,它不是在积极利用,让其他司机与其他设备。
117
118     - There's a limit on the number of bytes each I/O request can transfer
119       to the SPI device.  It defaults to one page, but that can be changed
120       using a module parameter.
-- 每个I / O请求可以转移到SPI器件的字节的数量是有限制。它默认为一个页面,但可以改变使用的模块参数。
121
122     - Because SPI has no low-level transfer acknowledgement, you usually
123       won't see any I/O errors when talking to a non-existent device.
-- 由于SPI有没有低级的转移确认,你通常不会看到任何I / O错误交谈时,一个不存在的设备。
124
125
126 FULL DUPLEX CHARACTER DEVICE API
-全双工字符设备API
127 ================================
128
129 See the spidev_fdx.c sample program for one example showing the use of the
130 full duplex programming interface.  (Although it doesn't perform a full duplex
131 transfer.)  The model is the same as that used in the kernel spi_sync()
132 request; the individual transfers offer the same capabilities as are
133 available to kernel drivers (except that it's not asynchronous).
-参阅样本程序显示全双工编程接口使用的一个例子spidev_fdx.c。(虽然它不执行全双工传输)
模型是用于内核spi_sync(相同)的要求,个人转让提供相同的功能,内核驱动程序(除了它是不是异步)。
134
135 The example shows one half-duplex RPC-style request and response message.
136 These requests commonly require that the chip not be deselected between
137 the request and response.  Several such requests could be chained into
138 a single kernel request, even allowing the chip to be deselected after
139 each response.  (Other protocol options include changing the word size
140 and bitrate for each transfer segment.)
-这个例子显示了一个半双工的RPC风格的请求和响应消息。这些请求通常要求不被取消的
芯片之间的请求和响应。几个这样的请求可能被链接到一个单一的核心要求,甚至允许芯
片被取消后,每个响应(其他协议选项包括改变为每个传输段的文字大小和比特率)。
141
142 To make a full duplex request, provide both rx_buf and tx_buf for the
143 same transfer.  It's even OK if those are the same buffer.
-为了使一个全双工请求,中同时提供rx_buf tx_buf相同的传输。它甚至是确定的,如果是相同的缓冲区。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值