Skip to content

Commit 472ebef

Browse files
committed
Add doxygen documentation for low_pass_filter.c functions
1 parent 9aaadbe commit 472ebef

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

common/low_pass_filter.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,17 @@
44
#include "common.h"
55
#include "low_pass_filter.h"
66

7-
// Initialize the low-pass filter
7+
/**
8+
* @brief Initializes the low-pass filter by calculating and storing the alpha value
9+
*
10+
* This function calculates the alpha value based on the given response time and stores
11+
* it in the provided pointer. The alpha value is used in subsequent filter updates.
12+
*
13+
* @param alpha Pointer to store the calculated alpha value
14+
* @param response_time Response time constant in milliseconds (must be > 0)
15+
* @return w_status_t Returns W_SUCCESS on success, W_INVALID_PARAM if alpha is NULL or
16+
* response_time is invalid
17+
*/
818
w_status_t low_pass_filter_init(double *alpha, double response_time) {
919
if (alpha == NULL || response_time <= 0) {
1020
return W_INVALID_PARAM; // Return specific error for invalid parameters
@@ -14,7 +24,19 @@ w_status_t low_pass_filter_init(double *alpha, double response_time) {
1424
return W_SUCCESS; // Return success after initialization
1525
}
1626

17-
// Update the low-pass filter with a new value
27+
/**
28+
* @brief Updates the low-pass filter with a new value and returns the operation status
29+
*
30+
* This function applies the low-pass filter algorithm to the new input value using the
31+
* provided alpha value. The filtered result is stored in low_pass_value and updated
32+
* in-place for the next iteration.
33+
*
34+
* @param alpha Alpha value (0.0 to 1.0) for the low-pass filter
35+
* @param new_input_value New input value to filter
36+
* @param low_pass_value Pointer to the current filtered value (updated in-place)
37+
* @return w_status_t Returns W_SUCCESS on success, W_INVALID_PARAM if low_pass_value is
38+
* NULL or alpha is out of valid range (0.0 to 1.0)
39+
*/
1840
w_status_t update_low_pass(double alpha, uint16_t new_input_value, double *low_pass_value) {
1941
// Check if low_pass_value pointer is NULL
2042
if (low_pass_value == NULL) {

0 commit comments

Comments
 (0)