ATMEL-based SPI Model
Let's take a look at this article.ArticleAnalysis:
Http://blog.chinaunix.net/u3/96265/showart_1925533.html
[Post indicated source] http://blog.csdn.net/lanmanck
However, some details are not mentioned. I would like to add it. If not, please point it out:
1. the driver has the concept of bus and equipment.
SPI controller is the bus (SPI bus), corresponding to atmel_spi.c
An external chip on the SPI controller, such as serial flash, can transceiver, and cl
* / * mode becomes spi_device.mode, and is essential for chips : * Where the default of Spi_cs_high = 0 is wrong. : * / : u8 mode; £ º * / * Need additional Spi_device chip config data here. : * Avoid stuff protocol drivers can set; but include stuff* needed to behave without being bound to a driver: *-quirks like clock rate mattering if not selected * / 1: /* Add by Xuyonghong for test * / 2: struct spi_board_info jz_sp
interface driver--spidev, which is the SPI standard interface specified by our company1. Modify the device treeThe SPI statement in Sama5d3.dtsi is as follows:SPI1: [email protected] {#address-cells = #size-cells = compatible = "ATMEL,AT91RM9200-SPI";Reg = interrupts = DMAs = Dma-names = "TX", "RX";Pinctrl-names = "Default";pinctrl-0 = Clocks = Clock-names = "SPI_CLK";Status = "Disabled";};Then our own DTS file after inheriting Sama5d3.dtsi this file
This time with SPI. BBB is available in two sets of SPI interfaces, both of which are default disable and need to be enabled in overlay mode, i.e.: echo bb-spidev0 >/sys/devices/bone_capemgr.9/slots My BBB current configuration is currently configured/opt/source/userspace-arduino/overlay/bb-spi0-01-00a0.dts/dts-v1/;/plugin/; / {compatible = "Ti,beaglebone", "Ti,beaglebone-black"; /* Identification */Part-number = "Spi0pinmux"; [Email protected] {target = __overlay__ {SPI0_PINS_S0:SPI0_PINS_S0 {
Hardware Platform:
1 master: SMDK Exynos4412 POP S5M8767A
2 RFID module: RC522 module provided by jundun Group
3. Communication Interface: SPI
Software Platform: Android ICS kernel version 3.0.15
1. enable the master SPI
1 hardware enabling:
From the SMDK schematic, we can see that SPI0 is shared with I2C. SPI1 has been connected to other devices, and SPI2 is not used. Therefore, SPI2 is used here.
2 software enabling:
The SPI interface has been configured on the SMDK Exynos4412 master. You o
SPI bus, which is initialized with Spi_board_info, and these processes are done by the predecessors.1 /*2 * Take MMC SPI Peripherals as an example3 */4 Static structS3c64xx_spi_csinfo smdk_spi0_csi[] = {5[Smdk_mmcspi_cs] = {6. Line = S5PV210_GPB (1),7. Set_level =Gpio_set_value,8. Fb_delay =0x2,9 },Ten }; One Static structS3c64xx_spi_csinfo smdk_spi1_csi[] = { A[Smdk_mmcspi_cs] = { -. Line = S5PV210_GPB (5), -. Set_level =Gpio_set_value, the. Fb_delay =0x2, - }, - }; - //Modify the con
= port:pi11Spi_mosi = port:pi12Spi_miso = port:pi13Among them, the need is particularly important, understanding SPI_CS0 = port:pi10Port:pi10 means to use PI10 this pin,Output, as for the value of 2~7, according to the different pins, different values have different functions but 2~7 is mainly representative of the reuse of ports, as to what the reuse into the port, please refer to[Url]http://linux-sunxi.org/a10/pio[/url]You can see from the diagram, if you want to use SPI, you should use MUX2,
The SPI-driven migration under Linux2.6.32 is shown in the following illustration:
the following needs to modify some of the kernel code, the following actions: 1. Modify the arch/arm/mach-s3c2440/mach-mini2440.c file
Add the following code after the include header file code line
SPI Add by Shiguang#include #include static struct Spi_board_info s3c2410_spi0_board[] = {[0] = {. Modalias = "Spidev",. Bus_num = 0,. Chip_select = 0,. IRQ = Irq_eint9,
: =1 is used, =0 means no use;Spi_cs_bitmap:=1 indicates that the chip selection uses the spi2_cs0,=2 to indicate that the chip selection uses the spi2_cs1,=3 to use Spi2_cs0 and SPI2_CS1;I'm using Pb14-pb17, a set of SPI2 interfaces, where 2 of the angle brackets represent the choice of the Multiplexing function (SPI).spi_devices Device Quantity setup[Spi_devices]spi_dev_num = 1Spi_dev_num: Represents the total number of SPI used, here I only use one so write 1, this need to be with the back "S
Mail: bookworepeng@Hotmail.com
QQ: 196568501
Author: drivermonkey
Phone: 13410905075
Tested hardware platform: Ti am335x
Test code:
/* * SPI testing utility (using spidev driver) * * Copyright (c) 2007 MontaVista Software, Inc. * Copyright (c) 2007 Anton Vorontsov
Test results:
Currently, the SPI Driver Interface transfers up to 4 K bytes of data at a time.
Linux Device Driver inquiry 1st days ---- spi Driver (1), 1st days ---- spi
This document allows reprinting. Please indicate the source:Http://blog.csdn.net/fulinus
The Linux kernel code is too big, and a small module will make you feel helpless. This afternoon, I am determined to take a good look at the spi driver.
First, analyze the spidev. c file, which defines the members in the struct file_operations structure. The members include spidev_write, s
driver and the kernel. I'm not sure how it fits.In some cases, the driver can be implemented in user space, using the following conditions:1, the kernel provides direct access to the hardware mechanism2, there is no need to leverage an existing kernel subsystem such as the networking stack or lesystems.3, the kernel does not need to handle the concurrent access hardware, only one application instance will access the hardwarePossible user-space device driversUSB with Libusb, http://www.libusb.or
configure the kernel. Add the following content to the LED module:
Device Drivers --->
[*] Led support --->
Compile the kernel, download the compiled kernel to the Development Board, and run:
[Root @ zhaocj/] # ls
Bin etc lib proc sys USR
Dev home linuxrc sbin temp
[Root @ zhaocj/] # cd sys
[Root @ zhaocj/sys] # ls
Block class devices FS Module
Bus Dev firmware kernel power
Go to the Sys directory, and we can see that there are some subdirectories under this directory.
[Root @ zhaocj/sys] # c
T_xxxconfig:1) Some pin names attached to the peripheral and the host controller, Cspinidrstpinid2) Chip types Type page size pagesize page total pagenum capacity capacity address Peugeot I2cflag read-write time-out timeout3. Device object Structure Body T_xxxdev: a few parts.1) Peripheral driver status, Spiflag I2cflag SPI I²c probe success2) Register Array RegcacheParameter configuration structure Body T_xxxconfig3) Related structures interacting with modules4) kernel-related drive mechanismA
Download and install gvim gvim71.exeDownload ec57w32.zip (ctags) to connect to ctags
Decompress the package and copy ctags.exe to C:/Windows/system32/Download the taglist
Decompress the package and copy the plug-in/taglist. Vim DOC/taglist.txt files to the corresponding directory of the vim installation directory.
Run ctags-r XXX in cmd terminal to generate tagsCtags-r -- C ++-kinds = + p -- fields = + IAS -- extra = + qEdit vimrcAdd"Add By liyazhouSet Ts = 4Set ICSet nuSet incsearchSet hlsea
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.