SPI Examples (Blocking API)
Overview
The blocking SPI examples are available for both C and C++:
C:
examples/blocking_api/spi/c/C++:
examples/blocking_api/spi/cpp/
These examples are intended for both Supernova and Pulsar USB host adapters.
Hardware Setup
Required hardware:
One Binho Supernova or Pulsar
One Binho mikroBUS Adapter Board
One MikroE Flash 6 Click board (Winbond W25Q128JV, 128 M-bit NOR Flash)
Useful references:
Binho mikroBUS Adapter Board: binho.io/test-measurement/products/usb-host-adapters/accessories/mikrobus-adapter-board/
Flash 6 Click: mikroe.com/flash-6-click
W25Q128JV datasheet: download.mikroe.com/documents/datasheets/w25q128jv.pdf
What The SPI Examples Do
Connect to the Binho adapter and read device information.
- Set target voltage to
3300 mVusing the SPI voltage API: C:
CosmicSDK_SpiSetBusVoltageC++:
spiSetBusVoltage
- Set target voltage to
- Initialize the SPI controller on
CS0: Mode:
SPI_MODE_0Data width:
8 bitsBit order:
MSB firstFrequency:
10 MHz
- Initialize the SPI controller on
Read JEDEC ID with opcode
0x9Fand validate0xEF 0x40 0x18.Enable writes (
0x06), then erase sector at address0x00 0x20 0x00(0x20).Poll Status Register-1 (
0x05) until WIP bit clears.Enable writes again (
0x06), then page program random data (1..256 bytes) with0x02.Poll Status Register-1 again until ready.
Read back memory (
0x03) and verify read data matches written data.
Expected JEDEC ID Response
The command 0x9F requests manufacturer and device identification from the flash.
For W25Q128JV, the validated JEDEC bytes are:
Manufacturer:
0xEF(Winbond)Memory type:
0x40Capacity:
0x18(128 M-bit)
Build and Run (SPI C/C++)
SPI example directories build binaries with different names:
- C (
examples/blocking_api/spi/c/): example_c_dynamicexample_c_static
- C (
- C++ (
examples/blocking_api/spi/cpp/): example_cpp_dynamicexample_cpp_static
- C++ (
See also: