Basic SPI Stream

Demonstrates using the SPI stream API to read and write bulk flash.

API Features Demonstrated


This app works on:

Requirements and Prerequisites

This app requires a ZentriOS evaluation board. See the Platforms list above.

It also requires connection to a SPI bulk flash device. See Hardware, Bulk Flash.


This app demonstrates using the SPI Stream API to read and write a bulk flash device. It was written for the EN25Q80A SPI flash chip, but can be modified to work with other supported SPI bulk flash chips.

Usage Instructions

Before building the app, check that in the spi_stream.c source, SPI_STREAM_CS_GPIO is defined to be the ZentriOS device GPIO connected to the bulk flash device chip select. For example, if you are using the AMW106 with a ASG001 Monitor Backpack, define:


Open a ZentriOS serial terminal to the device. See Getting Started, Opening a ZentriOS Terminal.

The ZAP requires no interaction. It runs once and displays output on the terminal similar to the following:

> Starting SPI Stream Example App ...
Configuring SPI Stream with flags: 0x17, clock: 1000000, CS: 19
Opening SPI Stream
[Opened: 0]
> Reading chip ID ...
Chip ID: 0xC22017
Erasing flash ...
Writing flash ...
Reading flash ...
Buffer: 0x20010a50 (64): RX DATA
 Address 0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
20010A50 53 50 49 20 53 74 72 65 61 6D 20 74 65 73 74 20 SPI Stream test
20010A60 77 72 69 74 65 20 64 61 74 61 20 2E 2E 2E 2E 2E write data .....
20010A70 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ................
20010A80 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ................
ZAP exited. Reboot to run again.




Reads the chip ID and logs it.


Sends 'erase flash' instruction:


Sends 'write' instruction and then writes dummy date to flash: