Kyle Swenson | cc33c24 | 2022-05-16 10:38:04 -0600 | [diff] [blame^] | 1 | /* |
| 2 | * ./kernel_modules/qcom-adc/adc_averaging.h |
| 3 | * |
| 4 | * This is the header file for adc_averaging and defines the interface for |
| 5 | * users of the averaging logic |
| 6 | * |
| 7 | * Author: Cradlepoint Technology, Inc. <source@cradlepoint.com> |
| 8 | * Kyle Swenson <kswenson@cradlepoint.com> |
| 9 | * |
| 10 | * Copyright 2017 Cradlepoint Technology, Inc. |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify it |
| 13 | * under the terms of the GNU General Public License version 2 as published by |
| 14 | * the Free Software Foundation. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 17 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 19 | * more details. |
| 20 | * |
| 21 | */ |
| 22 | #ifndef __ADC_AVERAGING_H__ |
| 23 | #define __ADC_AVERAGING_H__ |
| 24 | |
| 25 | #include <linux/kernel.h> |
| 26 | #include <linux/mutex.h> |
| 27 | |
| 28 | #define MAX_SAMPLE_LENGTH 128 |
| 29 | struct adc_channel { |
| 30 | uint16_t *samples; |
| 31 | uint16_t total_length; |
| 32 | uint16_t index; |
| 33 | struct mutex lock; |
| 34 | }; |
| 35 | |
| 36 | |
| 37 | |
| 38 | void free_adc_channel(struct adc_channel *ch); |
| 39 | struct adc_channel *create_adc_channel(uint16_t fifo_length); |
| 40 | uint16_t compute_average(struct adc_channel *ch); |
| 41 | void add_sample(struct adc_channel *ch, uint16_t sample); |
| 42 | |
| 43 | void show_data(struct adc_channel *ch); |
| 44 | int verify_average(struct adc_channel *ch); |
| 45 | |
| 46 | |
| 47 | #endif |