|
本帖最后由 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周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|