Open main menu

DAVE Developer's Wiki β

Changes

SBCX-TN-001: Android Things and SPI bus

831 bytes added, 11:35, 5 January 2021
no edit summary
{{InfoBoxTop}}
{{AppliesToSBCX}}
{{AppliesToSBC Axel TN}}
{{AppliesToAxel}}
{{AppliesToAxelLite}}
{{AppliesToAxelEsatta}}
{{AppliesToIoT}}
{{AppliesTo IoT TN}}
{{InfoBoxBottom}}
== History ==
* Android Version: 4.4.3 (Jelly Bean).
To verify the functionality of the SPI buslibrary, a simple device (serial [https://www.micron.com/~/media/documents/products/data-sheet/nor-flash/serial-nor/m25p/m25p40.pdf NOR flash memory]) has been connected to the expansion connector (J33). Specifically, the SPI4 bus has been used.To build the example application using the library, the following version [https://developer.android.com/studio/index.html Android Studio] has been used: <pre>Android Studio 3.1Build #AI-173.4670197, built on March 22, 2018JRE: 1.8.0_152-release-1024-b02 amd64JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.oAndroid SDK API 27</pre>
=== Wiring ===
 
[[File:SBCX-Android-4.4.3-SPI-hw.png|thumb|center|600px|Simplyfied diagram of the serial flash memory interfacing]]
As depicted in the previous image, the serial flash memory has been connected to the SPI4 bus by using SBCX's expansion connector (J33).
==Software implementation==
The following picture shows how the organization of the software layelayers.
[[File:SBCX-Android-4.4.3-SPI.png|thumb|center|600px|Software stack]]
To implement such solution, the following requirements must be met:
*The Linux kernel must support [https://www.kernel.org/doc/Documentation/spi/spidev spidev]
*The device file must have the permissions as shown in [[#Managing the device connection|this section]].*The device tree must be modified in order to instantiate the SPI bus to be accessed*The : it is enough to enable the <code>escpi4</code> peripheral into SBCX device file must instantiate TBDtree
<pre>
&ecspi4 {
status = "okay";
};
</pre>
=== Example project===
An [[#Downloads|example project]] is provided to illustrate how to use the native library. It includes the library itself and a simple application which reads the device identification code data of the flash memory(<code>READ IDENTIFICATION</code> command).[[File:Spi test.png|thumb|center|600px|Test application]]
==== Managing the device connection ====
In order to open a connection to a particular SPI slave, you need to know the unique name of the bus. The get this name,
</pre>
==== Transferring data ====
Is important to note that async I/O are not supported in userspace at this time [https://www.kernel.org/doc/Documentation/spi/spidev ref], furthermore '''LSB''' mode is not supported by the i.MX6 processor [https://community.nxp.com/thread/388187 ref].
To communicate with the device the following methods are available
*<code> void WriteByte(byte symbol)</code> For : to transfer a byte without reading the response from the device.*<code> void WriteBuffer(byte[] data, int len)</code> For : to transfer a buffer to the device without processing the response.*<code> void Transfer(byte[] tx_data, byte[] rx_data, int len)</code> For : to transfer a buffer smaller than the length of the receiving one.*<code> void Transfer(byte[] tx_data, byte[] rx_data) </code> For : to transfer and read a buffer with the same length.*<code> void Transfer(byte symbol, byte[] rx_data, int len)</code> For : to transfer a byte and read a buffer of length ''len''.
<pre>
</pre>
 
==Downloads==
The library can be downloaded from example project is available for download at [http://mirror.dave.eu/axel/SBCX-TN-001 this link].
dave_user, Administrators
5,178
edits