Enable SPI 1.0 and 1.1 with device tre overlays on BeagleBone
For most people the above image means absolutely nothing, but for that one guy that has been searching for two days straight with no luck and finally arrives here, he has never ever seen anything more beautiful. To that guy: Dude, you are in safe hands. I’ll guide you through it : )
With Linux Kernel 3.8.x, the use of device tree overlays are used for enabling and configuring drivers. This post gives an example of how to enable Both the channels of SPI1 on a BeagleBone. Note that a kernel should be compatible with both an Angstrom file system or any other suitable file system like Debian, although this one has been developed with Ubuntu 12.04.
To get some background info on this topic have a look at Enable PWM on BeagleBone with DT overlays and Adding BeagleBone cape support to a kernel with Device Tree in Ubuntu.
Mux the pins
In the first fragment, the pins must be muxed. Note that at the time of this writing, only the mode (the first three bits) and not the mux is working so the configuration must be done by the driver. The SPI driver fixes this.
- bone_replicape_spi1_pins: pinmux_replicape_spi1_pins {
- pinctrl-single,pins = <
- 0x190 0x13 /* P9_31 = mcasp0_aclkx.spi1_sclk , OUTPUT_PULLUP | MODE3 */
- 0x194 0x33 /* P9_29 = mcasp0_fsx.spi1_d0 , INPUT_PULLUP | MODE3 */
- 0x198 0x13 /* P9_30 = mcasp0_axr0.spi1_d1 , OUTPUT_PULLUP | MODE3 */
- 0x19c 0x13 /* P9_28 = mcasp0_ahclkr.spi1_cs0 , OUTPUT_PULLUP | MODE3 */
- 0x164 0x12 /* P9_42 = GPIO0_7 = eCAP0_in_PWM0_out.gpio0[7] , OUTPUT_PULLUP | MODE2 */
- >;
- };
Enable the driver
To enable the driver, you must override the status of the spi1 or spi2 (or both) targets.
- fragment@1 {
- target = <&spi1>;
- __overlay__ {
- #address-cells = <1>;
- #size-cells = <0>;
- status = "okay";
- pinctrl-names = "default";
- pinctrl-0 = <&bone_replicape_spi1_pins>;
- cs-gpios = <&gpio4 17 0>, <&gpio1 7 0>;
- stepper_control{
- #address-cells = <1>;
- #size-cells = <0>;
- compatible = "spidev";
- reg = <0>;
- spi-max-frequency = <16000000>;
- spi-cpha; // Stepper control has mode 1 (CPOL = 0, CPHA = 1)
- };
- stepper_current{
- #address-cells = <1>;
- #size-cells = <0>;
- compatible = "spidev";
- reg = <1>;
- spi-max-frequency = <16000000>;
- // Stepper current has mode 0 (CPOL = 0, CPHA = 0)
- };
- };
- };
Status mus be “okay” here to override the default “disabled” in am33xxdtsi.
There are also a couple of more things to consider.
Pincontrol-names – “The list of names to assign states” from the documentation.
pincontrol-pins refrences the cell in the pinmux fragment.
cs-gpios – This refers to the pins used for Chip Selects. Since there are two channels,
(SPI1.0 and SPI1.1) activated, these must be defined. The arguments in the brackets refer to
GPIO bank, but there is a gotcha: If the pin is called GPIO3_17 in the datasheet, it becomes
<&GPIO4 17 ?> in the device tree, so one higher for the bank nr. The last number is the flags to send to the GPIO controller.
Output is 0, input is 1.
Look in the kernel documentation on GPIO for more info:
https://www.kernel.org/doc/Documentation/gpio.txt
Enable the SPIDEV
The next two nodes are the two next SPI channels. Call them whatever. To use the spidev user interface (the one that makes /dev/spi1.* show up), specify compatible = “spidev”.
If you have an SPI display or similar, there are drivers for that as well. Look in the folder
- KERNEL/fimrware/capes/
and look at the cape overlay for Koen Kooi’s HEXY robot, it has an SPI display from Adafruit:
http://www.youtube.com/watch?v=iH5OPj-Yybc (Getting a very good framerate on an SPI display, I might add..)
The variable “reg” refers to which Chip Select to use.
Max frequency is just that, guess.
There are also options for CPHA, CPOL,
Acronyms
McSPI – Multi channel Serial Peripheral Interface
CS – chip select
Files involved
McSPI – KERNEL/drivers/spi/spi-omap2-mcspi.c
spidev – KERNEL/drivers/spi/spidev.c
spi – KERNEL/drivers/spi/spi.c
Enable SPI 1.0 and 1.1 with device tre overlays on BeagleBone的更多相关文章
- Help for enable SSL 3.0 and disable TLS 1.0..
https://support.mozilla.org/en-US/questions/967266 i cant find tab Encryption for enable SSL 3.0 and ...
- Android Studio 3.0找不到Android Device Monitor
因为自Android Studio 3.0开始弃用Android Device Monitor,Android Developers官网上的原话是: Android Device Monitor is ...
- Android-Android Studio 3.0找不到Android Device Monitor
原文:https://blog.csdn.net/yuanxiang01/article/details/80494842?utm_source=copy 为什么Android Studio 3. ...
- spi子系统之驱动SSD1306 OLED
spi子系统之驱动SSD1306 OLED 接触Linux之前,曾以为读源码可以更快的学习软件,于是前几个博客都是一边读源码一边添加注释,甚至精读到每一行代码,实际上效果并不理想,看过之后就忘记了.主 ...
- Blackfin DSP(五):BF533的SPI接口
533SPI的特性 最高速度可达SCLK/4: 支持主模式和从模式: 可使用8个GPIO口作为从选择线: 1 slave select input pins 7 slave select output ...
- SPI在linux3.14.78 FS_S5PC100(Cortex A8)和S3C2440上驱动移植(deep dive)
由于工作的原因,对SPI的理解最为深刻,也和SPI最有感情了,之前工作都是基于OSEK操作系统上进行实现,也在US/OS3上实现过SPI驱动的实现和测试,但是都是基于基本的寄存器操作,没有一个系统软件 ...
- 痞子衡嵌入式:飞思卡尔i.MX RT系列MCU启动那些事(13)- 从Serial(1-bit SPI) EEPROM/NOR恢复启动
大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家介绍的是飞思卡尔i.MX RT系列MCU的Serial EEPROM/NOR恢复启动. 在前几篇里痞子衡介绍的Boot Device都属于主动启 ...
- 【转】SPI总线协议
SPI总线协议 By Xiaomin | April 17, 2016| 技术 概述 SPI(Serial Peripheral Interface)总线是主要应用于嵌入式系统内部通信的串行同步传输总 ...
- SPI SWD Protocol Implement
//================================================================================= // ARM SWD Mode ...
随机推荐
- Django单元测试(二)------测试工具
The test client test client是一个python类,来模拟一个简单的“哑”浏览器,允许你来测试你的view函数.你可以使用test client完成下列事情: 1.模拟&quo ...
- Yorhom浅谈:作为一名初中生,自学编程的点点滴滴 - Yorhom's Game Box
Yorhom浅谈:作为一名初中生,自学编程的点点滴滴 我是一名不折不扣的初中生,白天要背着书包去上学,晚上要拿起笔写作业.天天如此,年年如此. 我的爱好很广泛,喜欢了解历史,读侦探小说,骑车,打篮球, ...
- Tolerance (定义发票允差)
(N) AP > Setup > Invoice > Tolerance (定义发票允差) 这里只对价格进行了设置,其他保持了默认.To set tolerance levels f ...
- URAL1029. Ministry(DP+路径)
链接 路径麻烦啊 很多细节 倒回去搜一遍 卡了一节数据库.. #include <iostream> #include<cstdio> #include<cstring& ...
- PHP数组排列
一.先看最简单的情况.有两个数组: $arr1 = array(1,9,5);$arr2 = array(6,2,4); array_multisort($arr1,$arr2); print_r($ ...
- If-Modified-Since & If-None-Match
google告诉网站站长:您的网络服务器支持 If-Modified-Since HTTP 标头.通过该功能,您的网络服务器可以告诉 Google 自上次抓取您的网站以来,内容是否已发生变化.该功能可 ...
- RESTLET开发实例(三)基于spring的REST服务
http://www.lifeba.org/arch/restlet_spring_3.html 前面两篇文章,我们介绍了基于JAX-RS的REST服务以及Application的Rest服务.这里将 ...
- LoadRunner调用Java程序—性能测试
为了充分利用LoadRunner的场景控制和分析器,帮助我们更好地控制脚本加载过程,从而展现更直观有效的场景分析图表.本次将重点讨论LoadRunner如何调用Java测试代码,完成压力测试. 通常我 ...
- Nginx配置中运行与启动的详细介绍【转】
原文:http://developer.51cto.com/art/201003/190944.htm 我们在进行Nginx配置的时候会出现很多不明白的地方,其实有些时候只要换一个思维的方式就能找多你 ...
- Git branch (分支学习)
以前总结的一些git操作,分享在这里. Git 保存的不是文件差异或者变化量,而只是一系列文件快照. - 列出当前所有分支 git branch <--merge> | <--n ...