blob: 38a4859376498a88a2f1f73b6f1301682807e419 [file] [log] [blame]
/*
* ./kernel_modules/qcom-adc/adc_averaging.h
*
* This is the header file for adc_averaging and defines the interface for
* users of the averaging logic
*
* Author: Cradlepoint Technology, Inc. <source@cradlepoint.com>
* Kyle Swenson <kswenson@cradlepoint.com>
*
* Copyright 2017 Cradlepoint Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
*/
#ifndef __ADC_AVERAGING_H__
#define __ADC_AVERAGING_H__
#include <linux/kernel.h>
#include <linux/mutex.h>
#define MAX_SAMPLE_LENGTH 128
struct adc_channel {
uint16_t *samples;
uint16_t total_length;
uint16_t index;
struct mutex lock;
struct device * parent;
};
void free_adc_channel(struct adc_channel *ch);
struct adc_channel *create_adc_channel(struct device * dev, uint16_t fifo_length);
uint16_t compute_average(struct adc_channel *ch);
void add_sample(struct adc_channel *ch, uint16_t sample);
void show_data(struct adc_channel *ch);
int verify_average(struct adc_channel *ch);
#endif