dey-examples/apix-spi-example
Francisco Gil 8176b68510 spi: remove header from example
The stdint header is needed by the library to work.
Removed from here and added in the spi.h.

Signed-off-by: Francisco Gil <francisco.gilmartinez@digi.com>
2022-06-10 11:10:01 +02:00
..
Makefile debug: changes in the makefile to reduce the optimization level. 2017-11-30 13:12:58 +01:00
README.md readme: reorganize the platform from newest to eldest 2020-02-06 16:35:20 +01:00
main.c spi: remove header from example 2022-06-10 11:10:01 +02:00

README.md

Digi APIX SPI Example Application

Example application to access and manage SPI slaves using the Digi APIX library.

This application writes a page of an external EEPROM memory with random data. Afterward, it reads the data back to validate it.

Most EEPROM memories are compatible with the example. You only need to specify the page size and the address size in bytes.

The SPI connections for this example depends on the running platform:

  • ConnectCore 8X SBC Pro: Expansion connector of the board (J27).
    • VCC: Pin D1
    • GND: Pin C1
    • SPI-0 CLK: Pin D2
    • SPI-0 MISO: Pin D3
    • SPI-0 MOSI: Pin D4
    • SPI-0 SS0: Pin C2
  • ConnectCore 8X SBC Express: Raspberry Pi expansion connector of the board (J11).
    • VCC: Pin 1
    • GND: Pin 6
    • SPI-3 CLK: Pin 23
    • SPI-3 MISO: Pin 21
    • SPI-3 MOSI: Pin 19
    • SPI-3 SS0: Pin 24
  • ConnectCore 6UL SBC Pro: SPI connector of the board (J34).
    • 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
  • ConnectCore 6UL SBC Express: Expansion connector of the board (J8).
    • 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
  • ConnectCore 6 Plus SBC: SPI connector of the board (J34).
    • 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
  • ConnectCore 6 SBC: SPI connector of the board (J34).
    • 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

Running the application

Before launching the application, you must enable the SPI module with the following command:

~# modprobe spidev

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

~# ./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 or alias
<spi-ss>        SPI slave index to use or alias
<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

If no arguments are provided, the example will use the default values:

  • For the interfaces, default values are configured in /etc/libdigiapix.conf.
  • Specific application default values are defined in the main 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, for example, for ConnectCore 6UL:

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

For more information, see the Digi Embedded Yocto online documentation.

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.