简体   繁体   English

Bitbanging在Coldfire / ucLinux上的PIO

[英]Bitbanging a PIO on Coldfire/ucLinux

Here's the problem: I need to program some hardware via 2 pins of the PIO (1 clock, 1 data). 这就是问题所在:我需要通过PIO的2个引脚(1个时钟,1个数据)编程一些硬件。 Timing constraints are tight - 10ms clock cycle time. 时序约束很紧 - 时钟周期为10ms。 All this, of course, whilst I maintain very high level services (CAN bus, TCP/IP). 当然,所有这一切,我都保持着非常高水平的服务(CAN总线,TCP / IP)。 The downstream unit also ACKS by asserting a PIO pin, configured as an input, high. 下游单元还通过将PIO引脚(配置为输入)置为高电平来确认。 So this loop has to both read and write. 所以这个循环必须同时读写。 I need to send 16 bits in the serial stream. 我需要在串行流中发送16位。

Is there an established way to do this sort of thing or should I simply get the hardware guys to add a PIC or somesuch. 有没有一种既定的方法来做这种事情,或者我应该只是让硬件人员添加PIC或其他东西。

I'd much prefer to avoid exotics like RTAI extensions at this stage. 我更喜欢在这个阶段避免像RTAI扩展这样的外来物种。 I did once see a reference to user-mode IO which implied a possible interrupt driven driver but lost track of it. 我曾经看到过对用户模式IO的引用,这暗示了一个可能的中断驱动的驱动程序,但却没有跟踪它。

Any pointers welcomed. 任何指针都欢迎。

The easiest way, in my experience, is to write a kernel driver. 根据我的经验,最简单的方法是编写内核驱动程序。 Provided, of course, that one doesn't already exist -- 1 clock, 1 data sounds i2c-like (though 10ms cycle sounds much slower than i2c), and there are bit-banging i2c drivers for Coldfire already in existence. 当然,只提供一个时钟 - 1个时钟,1个数据听起来像i2c一样(虽然10ms周期听起来比i2c慢得多),并且已经存在针对Coldfire的位冲击i2c驱动程序。 Even if it's not i2c, you might find i2c-adap-mcf_gpio of use as a starting point. 即使它不是i2c,你也可以找到i2c-adap-mcf_gpio作为起点。

You're actually lucky in that it's a 10ms cycle -- default kernel tick is 10ms (and it can be adjusted if necessary), so you should be able to use the appropriate kernel sleep functions. 你真的很幸运,因为它是一个10ms周期 - 默认内核标记是10ms(如果需要可以调整它),所以你应该能够使用适当的内核休眠功能。

(This all also depends on which kernel you're using. Easy user-mode I/O is available in 2.6 kernels fairly readily -- there are features in 2.4 kernels, but they may require more work.) (这一切都取决于你正在使用的内核。很容易在2.6内核中提供简单的用户模式I / O-- 2.4内核中有功能,但它们可能需要更多的工作。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM