|
本帖最后由 Willian.Mo 于 2015-8-18 10:29 编辑
MYD-SAMA5D3X的SPI1的SPI1_SPCK与LED d6复用冲突,默认SPI1是没有开启的。启用SPI1需要禁用d6,配置设备树以及修改一下内核配置。[mw_shl_code=bash,true]PC22 SPI1_MISO
PC23 SPI1_MOSI
PC24 SPI1_SPCK -->LED d6复用
PC25 SPI1_NPCS0[/mw_shl_code]
下面介绍启用导出SPI1的步骤:
1.禁用LED d6:
打开arch/arm/boot/dts/sama5d3mb.dtsi文件,注释掉d6配置如下图所示:
2.配置导出SPI1设备节点:
打开arch/arm/boot/dts/sama5d3mb.dtsi文件,在spi0下面添加如下内容:
[mw_shl_code=bash,true]spi1: spi@f8008000 {
spidev@0 {
compatible = "spidev";
spi-max-frequency = <50000000>;
reg = <0>;
};
};[/mw_shl_code]
3.启用SPI1:
打开arch/arm/boot/dts/sama5d3xek.dts(sama5d3xek.dts根据CPU型号匹配)文件,在spi0下面添加如下内容:
[mw_shl_code=bash,true]spi1: spi@f8008000 {
status = "okay";
};[/mw_shl_code]
4.重新编译设备树:
[mw_shl_code=bash,true]$ export PATH=$PATH: /opt/gcc-linaro-arm-linux-gnueabihf-4.7-2013.04-20130415_linux/bin/
$ make ARCH=arm dtbs CROSS_COMPILE=arm-linux-gnueabihf-[/mw_shl_code]
5.配置内核,导出spidev节点:
进入linux-at91目录,依次执行如下命令:
[mw_shl_code=bash,true](1)配置.config
$ make ARCH=arm sama5_defconfig
(2)添加spidev设备支持,选上User mode SPI device driver support
$ make ARCH=arm menuconfig
Device Drivers --->
SPI support --->
<*> User mode SPI device driver support
(3)编译内核
$ make ARCH=arm uImage CROSS_COMPILE=arm-linux-gnueabihf-[/mw_shl_code]
6.测试,将SPI1_MOSI与SPI1_MISO短接:
[mw_shl_code=bash,true]# ./spidev_test -D /dev/spidev32765.0 -s 50000000
spi mode: 0
bits per word: 8
max speed: 5000000 Hz (5000 KHz)
FF FF FF FF FF FF
40 00 00 00 00 95
FF FF FF FF FF FF
FF FF FF FF FF FF
FF FF FF FF FF FF
DE AD BE EF BA AD
F0 0D [/mw_shl_code]
测试程序:
spidev_test.rar
(3.86 KB, 下载次数: 10220)
|
|