This page introduces the SPI-to-USB data streaming interface from Apollo3 Blue to PC. This is a high speed interface using IOM module on Apollo3 Blue device to stream data out to PC for debug purpose. The SPI slave to USB converter is FT4222H from FTDI. One can use FT4222H-EV-D evaluation board from FTDI for this purpose, or use the Apollo3 Blue Plus EVB which has on board FT4222H.
Transfer speed can reach 200 KBytes/sec or higher. The user can send generic data and audio data to PC over AMU2S interface at same time. Audio data is supported in raw PCM (16bit/16Khz), SPP or OPUS format.
Driver in the firmware
In the firmware, include the amu2s.c and amu2s.h source files to enable the feature. Here we are taking IOM0 as an example, where the IOM instance to be used and pins can be defined as needed.
In the application, include the amu2s.h in the source file where you need to send data. Call "amu2s_send()" function to send the data over SPI.
The IOM is configured as non-blocking transfer. The feature uses around 16 KBytes of RAM as the data buffer. This can be reduced by changing the settings in the amu2s.h file.
For more details, please check the amu2s.h header file.
Amu2s PC tools
Update: amu2s_tool_1122.7z
Updates are:
- AmU2S.exe updated to v0.6 to support fast SPI data packages
- AmU2S.exe updated to v0.6 to reset SPI slave when error occurs.
- Press any key to stop recording instead of "ctrl+c".
- ftdi_bin_recorder.py updated to speed up the data processing.
In the tool folder, there are tools to capture and convert SPI data stream.
- ftdi_bin_decoder.py is the main script. It starts the data collection and parse received data upon finish
- rtt_to_wav.py is the binary to wave file converter. Once you have all the data received and parsed as desired, you can use this script to convert them into .wav files.
How to use
1. Connect hardware.
On Apollo3 Blue EVB
By default, we are using the following signals from Apollo3 Blue as SPI signal lines and to the corresponding signals of FT4222H-EV, as shown below:
Apollo3 Blue: FT4222H-EV
GPIO5: SCK (IOM0)------------------SCK (pin9 of JP5)
GPIO7: MOSI (IOM0)----------------MOSI (pin7 of JP5)
GPIO42: CS (IOM0)------------------SS (pin11 of JP4)
GND (any)------------------------------GND (any)
On Apollo3 Blue Plus EVB
The Apollo3 Blue Plus EVB comes with FT4222H device on board, the on board connection between Apollo3Blue Plus and FT4222H is shown below:
Apollo3 Blue Plus: FT4222H
GPIO27: SCK (IOM2)----------------SCK (pin8 of FT4222H)
GPIO28: MOSI (IOM2)--------------MOSI (pin10 of FT4222H)
GPIO25: MISO (IOM2)--------------MISO (pin9 of FT4222H)
GPIO15: CS (IOM2)-----------------SS (pin32 of FT4222H)
GND (any)----------------------------GND (any)
2. Build and download the binary into Apollo3Blue EVB and run.
3. Run ftdi_bin_decoder.py on PC.
Example command option is: python ftdi_bin_decoder.py -c logger
You should be able to see some output of the console as below:
4. Keep recording until you think you have collected enough data.
You can still monitor SWO log for output in parallel.
5. Press any key to stop recording.
After you stop the recording, the script will save a master data file (Apollo_spi.bin) and 4 child files: Apollo_spi_log_general, Apollo_spi_log_pcm, Apollo_spi_log_spp, Apollo_spi_log_opus.
(we currently implement only the pcm and spp, so other files should be empty.)
6. Run rtt_to_wav.py script to convert raw binary into .wav files.
Example command options are:
python rtt_to_wav.py pcm -I apollo_spi_log_pcm
python rtt_to_wav.py dspc -I apollo_spi_log_spp
There will be .wav files generated in the same folder as the tool scripts:
Files with names starting from pcm_wav_xxxxx are left and right separated PCM raw audio (original and normalized).
Files with names starting from dspc_wav_xxxx are mono audio after SPP (original and normalized).
You can play them or check the spectrogram.
Comments
0 comments
Article is closed for comments.