1
0
mirror of https://github.com/elua/elua.git synced 2025-01-25 01:02:54 +08:00
elua/inc/elua_adc.h
James Snyder 554dd7126b ADC can now run in freerunning mode (keep collecting samples after ring buffer
is full). Clock and sampling frequency have been moved to a separate function
from burst.  There is now one function to initiate sampling called sample
which takes a channel and count.  setclock takes a channel, clock_id, and
frequency.  Adjustments should be made to make channel groupings somewhat
cleaner, but this is functional.

Suggestions are welcome for simplification :-)

I'll try and make some doc updates in the coming day or so to reflect
finalized adjustments.
2009-02-24 07:58:10 +00:00

38 lines
1.2 KiB
C

#ifndef __ELUA_ADC_H__
#define __ELUA_ADC_H__
#include "type.h"
typedef struct
{
// Status Bit Flags
volatile u8 op_pending: 1, // Is there a pending conversion?
blocking: 1, // Are we in blocking or non-blocking mode? (0 - blocking, 1 - nonblocking)
freerunning: 1, // If true, we don't stop when we've acquired the requested number of samples
clocked: 1, // Acquiring at fixed rate using a clock
smooth_ready: 1; // Has smoothing filter warmed up (i.e. smoothlen samples collected)
unsigned id, timer_id;
u8 logsmoothlen;
volatile u16 smoothidx;
volatile u32 smoothsum;
u16 *smoothbuf;
volatile u16 reqsamples;
} elua_adc_state;
void adc_smooth_data( unsigned id );
elua_adc_state *adc_get_ch_state( unsigned id );
u16 adc_get_processed_sample( unsigned id );
void adc_init_state( unsigned id );
int adc_update_smoothing( unsigned id, u8 loglen );
void adc_flush_smoothing( unsigned id );
u16 adc_samples_requested( unsigned id );
u16 adc_samples_available( unsigned id );
void adc_wait_samples( unsigned id, unsigned samples );
#endif