在 Coldfire/ucLinux 上对 PIO 进行 Bitbanging

发布于 2024-08-26 00:45:28 字数 334 浏览 4 评论 0原文

问题是:我需要通过 PIO 的 2 个引脚(1 个时钟,1 个数据)对一些硬件进行编程。时序限制很严格 - 10ms 时钟周期时间。当然,所有这一切都是在我保持非常高水平的服务(CAN 总线、TCP/IP)的同时进行的。下游单元还通过将配置为输入的 PIO 引脚置位为高电平来进行确认。所以这个循环必须同时进行读取和写入。我需要在串行流中发送 16 位。

有没有既定的方法来做这种事情,或者我应该简单地让硬件人员添加 PIC 或类似的东西。

在这个阶段,我更愿意避免像 RTAI 扩展这样的外来事物。我曾经看到过对用户模式 ​​IO 的引用,其中暗示了可能的中断驱动驱动程序,但我忘记了它。

欢迎任何指点。

Here's the problem: I need to program some hardware via 2 pins of the PIO (1 clock, 1 data). Timing constraints are tight - 10ms clock cycle time. All this, of course, whilst I maintain very high level services (CAN bus, TCP/IP). The downstream unit also ACKS by asserting a PIO pin, configured as an input, high. So this loop has to both read and write. I need to send 16 bits in the serial stream.

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.

I'd much prefer to avoid exotics like RTAI extensions at this stage. I did once see a reference to user-mode IO which implied a possible interrupt driven driver but lost track of it.

Any pointers welcomed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忘年祭陌 2024-09-02 00:45:28

根据我的经验,最简单的方法是编写内核驱动程序。当然,前提是这个驱动程序还不存在——1 个时钟、1 个数据听起来像 i2c(尽管 10ms 周期听起来比 i2c 慢得多),并且已经存在用于 Coldfire 的 bit-banging i2c 驱动程序。即使它不是 i2c,您也可能会发现 i2c-adap-mcf_gpio 可以用作起点。

实际上你很幸运,因为它是一个 10 毫秒的周期——默认的内核时钟周期是 10 毫秒(如果需要的话可以调整),所以你应该能够使用适当的内核睡眠函数。

(这一切还取决于您使用的内核。简单的用户模式 ​​I/O 在 2.6 内核中相当容易实现——2.4 内核中有一些功能,但它们可能需要更多的工作。)

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. Even if it's not i2c, you might find i2c-adap-mcf_gpio of use as a starting point.

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.

(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.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文