forked from nrfconnect/sdk-nrf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwave_gen.h
77 lines (61 loc) · 1.4 KB
/
wave_gen.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
* Copyright (c) 2021 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/
/** @file
* @brief Wave generator header.
*/
#ifndef _WAVE_GEN_H
#define _WAVE_GEN_H
/**
* @defgroup wave_gen Wave generator
* @{
* @brief Library for generating wave signals.
*
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <zephyr/types.h>
/** @brief Available generated wave types.
*/
enum wave_gen_type {
WAVE_GEN_TYPE_SINE,
WAVE_GEN_TYPE_TRIANGLE,
WAVE_GEN_TYPE_SQUARE,
WAVE_GEN_TYPE_NONE,
WAVE_GEN_TYPE_COUNT,
};
/** @brief Generated wave parameters.
*/
struct wave_gen_param {
/** Type of the wave signal. */
enum wave_gen_type type;
/** Period of the wave signal [ms]. */
uint32_t period_ms;
/** Offset of the wave signal. */
double offset;
/** Amplitude of the wave signal. */
double amplitude;
/** Amplitude of the added noise signal. */
double noise;
};
/**
* @brief Generate wave value.
*
* @param[in] time Time for generated value.
* @param[in] params Parameters describing generated wave signal.
* @param[out] out_val Pointer to the variable that is used to store generated value.
*
* @retval 0 If the operation was successful.
* Otherwise, a (negative) error code is returned.
*/
int wave_gen_generate_value(uint32_t time, const struct wave_gen_param *params, double *out_val);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* _WAVE_GEN_H */