-
Notifications
You must be signed in to change notification settings - Fork 0
/
ASPC.h
72 lines (63 loc) · 2.32 KB
/
ASPC.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
#ifndef ASPC_H
#define ASPC_H
#endif
#include "stdio.h"
#include "stdlib.h"
#include "stdint.h"
#include "math.h"
#define ASPC_SCANRATE_50MV 50
#define ASPC_SCANRATE_100MV 100
#define ASPC_SCANRATE_300MV 300
#define ASPC_SCANRATE_500MV 500
#define ASPC_5V_REF 5.0
#define ASPC_3_3V_REF 3.3
#define SAMPLERATE 20 //#samples generated per second
#define DAC_RESOLUTION 12 //12-bit
#define TIA_RESISTOR 1000 //1k Resistor is placed in the TIA potentiostat
extern volatile uint16_t DACIndex;
typedef struct
{
/* data all voltages are in mV*/
uint16_t V_scanRate;
uint16_t V_ref;
int16_t V_initial; //initial voltage scan set the same as the V_ref to disable it.
int16_t V_start; //start scan
int16_t V_final; //final scan
uint8_t DAC_RES;
uint16_t rate;
uint8_t mode;
//private generated from get_dac_sequence
uint16_t _dac_size;
uint16_t *dac_sequence;
int16_t *raw_data;
}ASPC;
typedef enum {
LINEAR_SWEEP_VOLTAMMETRY = 1,
CYCLIC_VOLTAMMETRY,
}ASPC_Mode_t;
void ASPC_init(ASPC *_ASPC);
void ASPC_configure(ASPC *_ASPC,int16_t * data);
void ASPC_deinit(ASPC *_ASPC);
int16_t get_voltage(ASPC *_ASPC,uint16_t DACValue);
float get_DAC_step_value(ASPC *_ASPC);
uint16_t get_DAC_initial_voltage(ASPC *_ASPC);
void set_ASPC_DAC_resolution(ASPC *_ASPC,uint8_t _DAC_RES);
void set_ASPC_reference_voltage(ASPC *_ASPC,uint16_t Vref);
void set_ASPC_start_voltage(ASPC *_ASPC,int16_t VStart);
void set_ASPC_initial_voltage(ASPC *_ASPC,int16_t Vinit);
void set_ASPC_final_voltage(ASPC *_ASPC,int16_t Vfinal);
void set_ASPC_scan_rate(ASPC *_ASPC,uint16_t VScan);
void set_ASPC_mode(ASPC *_ASPC, uint8_t mode);
void set_ASPC_DAC_Resolution(ASPC *_ASPC, uint8_t resolution);
void set_ASPC_sample_rate(ASPC *_ASPC,uint16_t sample_rate);
uint16_t get_DAC_final_voltage(ASPC *_ASPC);
uint16_t get_dac_desired_voltage(uint16_t vRef, int16_t vTarget);
uint16_t * get_dac_sequence(ASPC *_ASPC);
float get_current_value(ASPC *_ASPC, uint16_t Rval, int16_t adcValue);
void enableDataAcquisition(ASPC* _ASPC);
void disableDataAcquisition(ASPC* _ASPC);
uint8_t isDAQEnabled(ASPC* _ASPC);
uint16_t *sequence_generator(ASPC *_ASPC, int16_t V_start,int16_t V_final, uint8_t cyclic);
uint16_t voltage_to_DAC(int16_t voltage,uint16_t vRef, uint16_t dacResolution);
void get_raw_data(ASPC* _ASPC);
void acquireData(ASPC* _ASPc);