|
| 1 | +/* |
| 2 | + * Copyright (c) 2018 Nordic Semiconductor ASA |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause |
| 5 | + */ |
| 6 | + |
| 7 | +#ifndef CONTIN_ARRAY_H |
| 8 | +#define CONTIN_ARRAY_H |
| 9 | + |
| 10 | +#include <zephyr/kernel.h> |
| 11 | + |
| 12 | +/** |
| 13 | + * @file contin_array.h |
| 14 | + * |
| 15 | + * @defgroup contin_array Continuous array |
| 16 | + * @{ |
| 17 | + * @brief Basic continuous array. |
| 18 | + */ |
| 19 | + |
| 20 | +/** @brief Creates a continuous array from a finite array. |
| 21 | + * |
| 22 | + * @param pcm_cont Pointer to the destination array. |
| 23 | + * @param pcm_cont_size Size of pcm_cont. |
| 24 | + * @param pcm_finite Pointer to an array of samples or data. |
| 25 | + * @param pcm_finite_size Size of pcm_finite. |
| 26 | + * @param finite_pos Variable used internally. Must be set |
| 27 | + * to 0 for the first run and not changed. |
| 28 | + * |
| 29 | + * @note This function serves the purpose of e.g. having a set of audio samples |
| 30 | + * stored in pcm_finite. This can then be fetched in smaller pieces into ram and |
| 31 | + * played back in a loop using the results in pcm_cont. |
| 32 | + * The function keeps track of the current position in finite_pos, |
| 33 | + * so that the function can be called multiple times and maintain the correct |
| 34 | + * position in pcm_finite. |
| 35 | + * |
| 36 | + * @retval 0 If the operation was successful. |
| 37 | + * @retval -EPERM If any sizes are zero. |
| 38 | + * @retval -ENXIO On NULL pointer. |
| 39 | + */ |
| 40 | +int contin_array_create(void *pcm_cont, uint32_t pcm_cont_size, void const *const pcm_finite, |
| 41 | + uint32_t pcm_finite_size, uint32_t *const finite_pos); |
| 42 | + |
| 43 | +/** |
| 44 | + * @} |
| 45 | + */ |
| 46 | +#endif /* CONTIN_ARRAY_H */ |
0 commit comments