搜索
bottom↓
回复: 1

mmap the gpio寄存器在raspberry pi 3上使用peter代码注意的一个问题

[复制链接]

出0入0汤圆

发表于 2016-5-22 22:44:30 | 显示全部楼层 |阅读模式
本帖最后由 reloaded 于 2016-5-22 22:55 编辑

参考链接
http://www.pieter-jan.com/node/15
https://www.raspberrypi.org/foru ... 142439&p=942349

首先,不要用wiring pi或者传统的python脚本,bash脚本做高速的gpio操作,或高速外设访问,因为这两个一个是电子积木毒害较深,一个是高级语言速度慢
所以还是要用传统的low level c ,通过mmap的方式读写io

问题: raspberry pi2,3 的地址变了,如果你不修改库文件的h文件,并且重新建立库,你肯定是没法用的。

办法:     #define BCM2708_PERI_BASE       0x3F000000   //注释到和2代无关的一代部分的定义
           重新cmake 库,cmake 例子 运行 ok


ps: 关于高速操作io或外设如spi adc 芯片,有个文章讲了下mmap才是真正的底层操作
http://www.hertaville.com/interf ... rry-pi-using-c.html
  亦可参考下一链接http://forum.lemaker.org/thread-22815-1-1.html
  可见spi部分的代码通过此方法可以构建并正常工作

  This solution is meant for applications where real-time constraints such as sampling speed requirements are very modest or even non-existent.

If you have strict sampling requirements, consider one of the following approaches:

    Access the SPI registers directly by mmaping into /dev/mem or via the bcm2835 library.
    Bitbang SPI via GPIO or use a Parallel ADC connected to the RPI's GPIOs. The RPI GPIOs can be controlled by many different methods, one of which can achieve  20MHz + toggling speed (also mmaping into /dev/mem  or via the bcm2835 library but for GPIOs)
    Write your own custom/optimized ADC device driver. Have a look at the 24th (June 2014) edition of the MagPi Magazine. The first article explains how to write a Linux driver for a 6-bit 10MSPS ADC and use it in conjunction with GNUplot to plot the waveforms.
    Use a microcontroller with a decent built-in ADC and generous amounts of memory for buffering....and maybe a DMA unit e.g. STM32F0/1/2/3/4, TIVA C , PIC32MX, PIC32MZ, e.t.c. The micro can then transmit ADC data to the RPI over UART, SPI or I2C.


阿莫论坛20周年了!感谢大家的支持与爱护!!

曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……

出0入0汤圆

 楼主| 发表于 2016-5-23 21:07:59 | 显示全部楼层
本帖最后由 reloaded 于 2016-5-23 21:18 编辑

发现一个很酷酷的项目,用raspberry pi 和zero做数字钟
参考
https://github.com/n0bel/PiClock
https://www.pinterest.com/kevinu ... berry-pi-arduino-d/
http://www.n0bel.net/v1/index.ph ... te-another-saturday


看不到图片的,要到pinterest里头注册一个账户再刷新下,,这个小伙比较认真,做了两年多的一个玩具,还带一些实体传感器的读取接口,用python做的。
原作者的注释,应该还用到了qt
I decided I needed to learn #python to where I can write, not just hack it. So I needed a project, and decided to rewrite the #PiClock on the #RaspberryPi. I used PyQt as the gui. After about a week, sneaking in spare time here and there, I ended up with a good result, and a few extra features: Auto Scaling, Multi-Platform. I'll update my blog n0bel.net with all this in the next week or so.

附加一个 python qt 在raspi上安装开发的第一个例子教程
https://www.baldengineer.com/raspberry-pi-gui-tutorial.html
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片。注意:要连续压缩2次才能满足要求!!】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-8-25 19:56

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表