Skip to content

Commit f104c3a

Browse files
committed
API function documentation added (using Doxygen)
1 parent 0104a41 commit f104c3a

File tree

10 files changed

+488
-58
lines changed

10 files changed

+488
-58
lines changed

.github/workflows/pack.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,16 @@ jobs:
2828
2929
- name: Setup Python
3030
uses: actions/setup-python@v5
31-
31+
3232
- name: Install MkDocs
3333
run: |
3434
pip install mkdocs
3535
pip install mkdocs-mermaid2-plugin
36+
pip install mkdoxy
3637
3738
- uses: Open-CMSIS-Pack/gen-pack-action@main
3839
with:
39-
doxygen-version: none
40+
doxygen-version: 1.13.2
4041
packchk-version: 1.3.95
4142
gen-pack-script: ./gen_pack.sh
4243
gen-pack-output: ./output

README.md

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,37 @@
22

33
The **Synchronous Data Stream (SDS) Framework** implements a data stream management, provides methods and helper tools for developing and optimizing embedded applications that integrate DSP and ML algorithms. This framework may be used stand-alone, but also in combination with [**CMSIS-Stream**](https://github.com/ARM-software/CMSIS-Stream) that allows to combine algorithms using a compute graph.
44

5-
## Overview
5+
## Features
66

7-
- Implements a flexible data stream management for sensor and audio data interfaces
8-
- Supports data streams from multiple interfaces including provisions for time drifts.
7+
- Implements a flexible data stream management for sensor, audio, and video interfaces that process data streams.
8+
- Supports data streams from multiple interfaces (i.e. for sensor fusion) including provisions for time drifts.
9+
- **Record real-world data** with original data sources of the target hardware for analysis and development.
10+
- **Playback real-world data** for algorithm validation using target hardware or [Arm Virtual Hardware - FVP](https://github.com/arm-software/avh).
911

10-
- Provides methods to **record real-world data** for analysis and development
11-
- Input to Digital Signal Processing (DSP) development tools such as filter designers
12-
- Input to Machine Learning (ML) model classification, training, and performance optimization
13-
- Verify execution of DSP algorithm on Cortex-M targets with off-line tools
12+
The captured data streams are stored in SDS data files. A [YAML metadata file](./schema/README.md) can be used to describe the content. The SDS data files have several use cases such as:
1413

15-
- **Playback real-world data** for algorithm validation using Arm Virtual Hardware
16-
- Input to Digital Signal Processing (DSP) development tools such as filter designers
17-
- Input to Machine Learning (ML) model classification, training, and performance optimization
18-
- Verify execution of DSP algorithm on Cortex-M targets with off-line tools
14+
- Input to Digital Signal Processing (DSP) development tools such as filter designers
15+
- Input to Machine Learning (ML) model classification, training, and performance optimization
16+
- Verify execution of DSP algorithm on Cortex-M targets with off-line tools
1917

20-
- Defines binary data format with [YAML metadata file](./schema/README.md).
18+
[Python-based utilities](./utilities/README.md) are provided for recording, playback, visualization, and data conversion
2119

22-
- [Python-based utilities](./utilities/README.md) for recording, playback, visualization, and data conversion
23-
24-
Refer to ["ML Developers Guide for Cortex-M Processors and Ethos-U NPU" - "Tool Support" - "SDS Framework Usage"](https://developer.arm.com/documentation/109267/0100/Tool-Support-for-the-Arm-Ethos-U-NPU/SDS-Framework-Usage) for more information.
25-
26-
## Interfaces
27-
28-
The [SDS Framework interfaces](./sds/README.md) implement the SDS streaming interfaces via different methods. The functions of the **sds.h Circular Buffer Handling** may be used at any level of a Compute Graph to provide inputs or capture outputs of an DSP or ML algorithm.
29-
30-
![Interfaces](./documentation/images/SDS-Interfaces.png "Interfaces")
31-
32-
## Repository top-level structure
20+
## Repository structure
3321

3422
Directory | Description
3523
----------------------------------|-------------------------------
3624
[examples](./examples) | Example implementations for various evaluation boards
37-
[documentation](./documentation/) | User documentation of the SDS Framework
25+
[documentation](./documentation/) | [User documentation](https://arm-software.github.io/SDS-Framework/main/index.html) of the SDS Framework
3826
[schema](./schema) | Schema for SDS File Format
3927
[sds](./sds) | Interfaces of the SDS Framework for Cortex-M devices
4028
[utilities](./utilities) | Python scripts for processing of SDS binary data files
4129

30+
## Related
31+
32+
- [SDS Examples](https://github.com/Arm-Examples/sds-examples)
33+
- [ML Developers Guide for Cortex-M Processors and Ethos-U NPU](https://developer.arm.com/documentation/109267)
34+
- [Arm Virtual Hardware - FVP](https://github.com/arm-software/avh)
35+
4236
## License
4337

4438
The SDS Framework is licensed under [![License](https://img.shields.io/github/license/arm-software/sds-framework?label)](https://github.com/ARM-software/sds-framework/blob/main/LICENSE).
@@ -47,6 +41,11 @@ The SDS Framework is licensed under [![License](https://img.shields.io/github/li
4741

4842
Contributions are accepted under [![License](https://img.shields.io/github/license/arm-software/CMSIS_6?label)](https://github.com/ARM-software/CMSIS_6/blob/main/LICENSE). Only submit contributions where you have authored all of the code.
4943

44+
The documentation is generated using [MKDocs](https://www.mkdocs.org/) with the following additional plugins:
45+
46+
- [mermaid2](https://mkdocs-mermaid2.readthedocs.io/en/latest/) for sequence diagrams.
47+
- [mkdoxy](https://pypi.org/project/mkdoxy) for API documentation.
48+
5049
### Issues and Labels
5150

5251
Please feel free to raise an [issue on GitHub](https://github.com/ARM-software/sds-framework/issues)

documentation/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ This user's guide assumes basic knowledge about Cortex-M software development. I
1313
- [**SDS Interface**](sds_interface.md) describes the various interfaces (USB, Socket, File System) for connecting to the target.
1414
- [**Examples**](examples.md) lists the examples that are available.
1515
- [**Utilities**](utilities.md) explains Python based utilities that operate with SDS data files for converting, viewing, recording, and playback.
16+
- [**API Modules**](SDS_API\modules.md) describes the C interface of the SDS functions that may be used in the target system.
1617

1718
## Revision History
1819

documentation/theory.md

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ The SDS Framework enables to record and playback one or more data streams to an
77

88
The DSP or ML algorithms that are tested operate on blocks and are executed periodically. This documentation uses these terms:
99

10-
- **Block size**: is the number of bytes processed by a DSP or ML compute node.
10+
- **Data Block**: is a set of input or output data which is processed in one step by a DSP or ML compute note.
11+
- **Block size**: is the number of bytes of a data block.
1112
- **Interval**: is the periodic time interval that the compute node executes.
1213

1314
![SDSIO Interface for Player and Recorder](images/SDS-InOut.png)
@@ -121,7 +122,7 @@ In most cases the granularity of an RTOS tick (typically 1ms) is a good choice f
121122
## SDS File Format
122123
123124
The SDS file format is described [here](https://github.com/ARM-software/SDS-Framework/tree/main/schema). Each call to
124-
`sdsRecWrite` creates one record.
125+
`sdsRecWrite` writes one data block.
125126
126127
## SDSIO Server Protocol
127128
@@ -294,3 +295,89 @@ but sds_rec.c does not really use this information
294295

295296
https://github.com/Arm-Examples/SDS-Examples/blob/main/Hardware/DataTest/rec_management.c
296297
- do we really need `recdone`?
298+
299+
## Guidelines for Stream Buffer sizing and Threshold settings
300+
301+
### Overview
302+
303+
The **SDS Recorder/Player** uses memory buffers to manage data recording and playback efficiently.
304+
Proper buffer and threshold configurations optimize performance by balancing data production, consumption, and system resource utilization.
305+
306+
### Stream Buffer Size
307+
308+
The size of memory buffers affects the balance between data production and consumption.
309+
310+
The **absolute minimum stream buffer size** should be large enough to store **one maximum record along with its header (8 bytes)**.
311+
312+
The **recommended stream buffer size** should be large enough to store **at least two maximum records along with headers (8 bytes per record)** and
313+
can be rounded up for convenience.
314+
315+
The record size generally corresponds to the data size used by the underlying technology.
316+
For example, in typical **ML applications**, the record size should ideally match the **data slice required by the DSP process**.
317+
318+
If sufficient RAM is available, increasing the buffer size can improve performance.
319+
320+
### Threshold Settings for SDS Recorder/Player
321+
322+
#### **Function of Thresholds**
323+
324+
- **For the SDS Recorder:** Determines when data writing to the **I/O** begins.
325+
- **For the SDS Player:** Determines when data reading from the **I/O** begins.
326+
327+
The **recommended threshold setting** is **half of the stream buffer size**, enabling a **double-buffering technique** where one half of the buffer is transferred while the other half continues to fill or be consumed.
328+
329+
A well-optimized system ensures timely data transfer over the I/O:
330+
331+
- For the **Recorder**: Previously acquired data must be transferred before the remaining of the buffer fills with new data.
332+
- For the **Player**: New playback data should be transferred before the previously transferred playback data is consumed.
333+
334+
#### **Impact on System Performance**
335+
336+
The threshold setting directly affects system performance, as **I/O transfers temporarily occupy the CPU**.
337+
During these operations, other system processes may experience limited CPU availability.
338+
339+
If the system requires additional CPU resources for other tasks, adjustments can be made by:
340+
341+
1. **Increasing the priority of critical threads**.
342+
2. **Reducing the threshold setting**, which shortens the duration of each transfer but increases the frequency of transfers.
343+
344+
> **Note:** Thresholds operate based on discrete record sizes. A threshold is only triggered when a write or read operation
345+
> surpasses (for write) or falls below (for read) the set limit.
346+
> When handling large records, breaking them into smaller chunks may be necessary to optimize system performance.
347+
348+
### Additional Settings Affecting I/O Bandwidth
349+
350+
Several additional factors influence I/O bandwidth, including:
351+
352+
1. **Temporary Recorder/Player buffer size** (configured in the `sds_rec_config.h` / `sds_play_config.h` files).
353+
2. **I/O low-level buffering**.
354+
355+
#### **Optimizing I/O Buffering**
356+
357+
For **optimal performance**, the **temporary Recorder/Player buffer size should match the I/O low-level buffer size**.
358+
359+
For some interfaces, the I/O low-level buffer size can be configurable, for others, it is fixed.
360+
361+
Example: The **USB Virtual COM interface** allows I/O low-level buffer size configuration.
362+
It is recommended to set this buffer size as a multiple of the **bulk endpoint maximum packet size** (512 bytes for USB high-speed connections).
363+
364+
### Example configurations for typical ML use cases
365+
366+
| **ML Use Case** | **DSP slice** | **Calculation** | **Buffer Size** | **Threshold** |
367+
| -------------------- | ----------------------------------- | ------------------------------------------------------------------------------------ | ---------------- | ------------- |
368+
| **Motion detection** | 125 accelerometer samples | `2 × [(125 samples × 3 axes × 4 bytes per axis) + 8] = 3016 -> rounded to 3072` | **3072 bytes** | **1536** |
369+
| **Keyword spotting** | 250 ms of audio data samples (16kHz)| `2 × [(4,000 audio samples × 4 bytes per sample) + 8] = 32,016 -> rounded to 32,768` | **32768 bytes** | **16384** |
370+
| **Object detection** | 1 picture (320x320) | `2 × [(320 × 320 pixels × 4 bytes per pixel) + 8] = 819,216` | **819216 bytes** | **409608** |
371+
372+
### **Best Practices Summary**
373+
374+
- **Ensure buffer sizes align with DSP ata slice sizes** for efficient ML processing.
375+
376+
- **Use double-buffering** to enhance I/O efficiency.
377+
378+
- **Adjust threshold settings** to balance performance and CPU usage.
379+
380+
- **Match temporary buffer sizes to I/O low-level buffer sizes** where possible.
381+
382+
By following these guidelines, the **SDS Recorder/Player** can be configured efficiently to balance **performance, latency, and CPU utilization**,
383+
ensuring smooth data processing and system stability.

mkdocs.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,20 @@ nav:
88
- SDS Interface: sds_interface.md
99
- Examples: examples.md
1010
- Utilities: utilities.md
11+
- API Modules: SDS_API\modules.md
1112

1213
plugins:
1314
- search
1415
- mermaid2 # pip install mkdocs-mermaid2-plugin
16+
- mkdoxy: # pip install mkdoxy (may require PYTHONPATH to be set)
17+
projects:
18+
SDS_API:
19+
src-dirs: ./sds/include
20+
full-doc: true
21+
doxy-cfg:
22+
FILE_PATTERNS: "*.h *.txt"
23+
24+
1525
theme:
1626
name: readthedocs
1727
markdown_extensions:

sds/include/sds.h

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extern "C"
2929
// ==== Synchronous Data Stream (SDS) ====
3030

3131
/// Identifier
32-
typedef void *sdsId_t;
32+
typedef void *sdsId_t; ///< handle to SDS stream
3333

3434
/// Function return codes
3535
#define SDS_OK (0) ///< Operation completed successfully
@@ -39,7 +39,12 @@ typedef void *sdsId_t;
3939
#define SDS_EVENT_DATA_LOW (1UL << 0) ///< Data bellow or equal to threshold
4040
#define SDS_EVENT_DATA_HIGH (1UL << 1) ///< Data above or equal to threshold
4141

42-
/// Event callback function
42+
/**
43+
\typedef void (*sdsPlayEvent_t) (sdsPlayId_t id, uint32_t event)
44+
\brief Call back function for SDS circular buffer handling
45+
\param[in] id handle to SDS file for playback
46+
\param[in] event event code
47+
*/
4348
typedef void (*sdsEvent_t) (sdsId_t id, uint32_t event, void *arg);
4449

4550
/**
@@ -49,22 +54,22 @@ typedef void (*sdsEvent_t) (sdsId_t id, uint32_t event, void *arg);
4954
\param[in] buf_size buffer size in bytes
5055
\param[in] threshold_low data low threshold in bytes
5156
\param[in] threshold_high data high threshold in bytes
52-
\return \ref sdsId_t
57+
\return \ref sdsId_t Handle to SDS stream
5358
*/
5459
sdsId_t sdsOpen (void *buf, uint32_t buf_size, uint32_t threshold_low, uint32_t threshold_high);
5560

5661
/**
5762
\fn int32_t sdsClose (sdsId_t id)
5863
\brief Close stream.
59-
\param[in] id \ref sdsId_t
64+
\param[in] id \ref sdsId_t handle to SDS stream
6065
\return return code
6166
*/
6267
int32_t sdsClose (sdsId_t id);
6368

6469
/**
6570
\fn int32_t sdsRegisterEvents (sdsId_t id, sdsEvent_t event_cb, uint32_t event_mask, void *event_arg)
6671
\brief Register stream events.
67-
\param[in] id \ref sdsId_t
72+
\param[in] id \ref sdsId_t handle to SDS stream
6873
\param[in] event_cb pointer to \ref sdsEvent_t
6974
\param[in] event_mask event mask
7075
\param[in] event_arg event argument
@@ -75,7 +80,7 @@ int32_t sdsRegisterEvents (sdsId_t id, sdsEvent_t event_cb, uint32_t event_mask,
7580
/**
7681
\fn uint32_t sdsWrite (sdsId_t id, const void *buf, uint32_t buf_size)
7782
\brief Write data to stream.
78-
\param[in] id \ref sdsId_t
83+
\param[in] id \ref sdsId_t handle to SDS stream
7984
\param[in] buf pointer to buffer with data to write
8085
\param[in] buf_size buffer size in bytes
8186
\return number of bytes written
@@ -85,7 +90,7 @@ uint32_t sdsWrite (sdsId_t id, const void *buf, uint32_t buf_size);
8590
/**
8691
\fn uint32_t sdsRead (sdsId_t id, void *buf, uint32_t buf_size)
8792
\brief Read data from stream.
88-
\param[in] id \ref sdsId_t
93+
\param[in] id \ref sdsId_t handle to SDS stream
8994
\param[out] buf pointer to buffer for data to read
9095
\param[in] buf_size buffer size in bytes
9196
\return number of bytes read
@@ -95,15 +100,15 @@ uint32_t sdsRead (sdsId_t id, void *buf, uint32_t buf_size);
95100
/**
96101
\fn int32_t sdsClear (sdsId_t id)
97102
\brief Clear stream data.
98-
\param[in] id \ref sdsId_t
103+
\param[in] id \ref sdsId_t handle to SDS stream
99104
\return return code
100105
*/
101106
int32_t sdsClear (sdsId_t id);
102107

103108
/**
104109
\fn uint32_t sdsGetCount (sdsId_t id)
105110
\brief Get data count in stream.
106-
\param[in] id \ref sdsId_t
111+
\param[in] id \ref sdsId_t handle to SDS stream
107112
\return number of bytes in stream
108113
*/
109114
uint32_t sdsGetCount (sdsId_t id);

0 commit comments

Comments
 (0)