dey-examples/apix-spi-example/README.md

3.2 KiB

Digi APIX SPI Example Application

The example application writes a page of an external EEPROM memory with random data and then reads the data back to validate it.

Most of EEPROM memories are compatible with the sample specifying the page size and the number of address bytes.

The SPI connections for the sample depends on the running platform:

  • CCIMX6 SBC: SPI connector of the board.

    • VCC: Pin 1
    • GND: Pin 8
    • SPI-1 CLK: Pin 2
    • SPI-1 MISO: Pin 3
    • SPI-1 MOSI: Pin 4
    • SPI-1 SS0: Pin 5
  • CCIMX6UL SBC Express: Expansion connector of the board.

    • VCC: Pin 17
    • GND: Pin 20
    • SPI-3 CLK: Pin 23
    • SPI-3 MISO: Pin 21
    • SPI-3 MOSI: Pin 19
    • SPI-3 SS0: Pin 24
  • CCIMX6UL SBC Pro: SPI connector of the board.

    • VCC: Pin 1
    • GND: Pin 8
    • SPI-1 CLK: Pin 2
    • SPI-1 MISO: Pin 3
    • SPI-1 MOSI: Pin 4
    • SPI-1 SS0: Pin 5

The following device tree modifications are required for the sample to work:

  • CCIMX6 SBC:
&ecspi1 {
	status = "okay";

	spidev@0 {
		reg = <0>;
		compatible = "spidev";
		spi-max-frequency = <1000000>;
		status = "okay";
	};
};
  • CCIMX6UL SBC Express:
&ecspi3 {
	status = "okay";

	spidev@0 {
		reg = <0>;
		compatible = "spidev";
		spi-max-frequency = <1000000>;
		status = "okay";
	};
};
  • CCIMX6UL SBC Pro:
&ecspi1 {
	status = "okay";

	spidev@0 {
		reg = <0>;
		compatible = "spidev";
		spi-max-frequency = <1000000>;
		status = "okay";
	};
};

Running the application

Once the binary is in the target, launch the application:

root@ccimx6ulstarter:~# ./apix-spi-example
Example application using libdigiapix SPI support

Usage: apix-spi-example <spi-dev> <spi-ss> <address-size> <page-size> <page-index>

<spi-dev>       SPI device index to use
<spi-ss>        SPI slave index to use
<address-size>  Number of EEPROM memory address bytes
<page-size>     EEPROM memory page size in bytes
<page-index>    EEPROM memory page index to use

Aliases for SPI can be configured in the library config file

Compiling the application

This example can be compiled using a Digi Embedded Yocto based toolchain. Make sure to source the corresponding toolchain of the platform you are using, e.g:

$ . <DEY-toolchain-path>/environment-setup-cortexa7hf-neon-dey-linux-gnueabi
$ make

More information about Digi Embedded Yocto.

License

Copyright 2017, Digi International Inc.

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.