-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathARXsettings.h
110 lines (81 loc) · 2.51 KB
/
ARXsettings.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/********************************************************
* ARXsettings.h: Header file for ARXsettings.cpp file *
* *
* Author: Devin Cody *
* *
* Date: February 2, 2018 *
********************************************************/
#ifndef __ARXsett__
#define __ARXsett__
//#define __ASSERT_USE_STDERR
#include "Arduino.h"
#include <SPI.h>
#include <math.h>
#define _MK(x,y) ((x & (1 << y))>0)
#define _CH(x) (8-x)
#define NCHAN 8
#define BAUD 62000
class ARXsetting{
private:
byte reg1[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; //corresponds to 4C
byte reg2[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; //corresponds to 54
byte reg3[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; //corresponds to 5C
int registers[3] = {0x4C, 0x54, 0x5C};
//looking for [16,8,4,2]
int at1[4] = {0,3,2,1};
int at2[4] = {0,2,3,1};
int ats[4] = {0,3,2,1};
//Variable to ensure spi initialization
bool SPI_INIT = false;
//Slave select pin
int NCS = 10;
//ARX Register Setters
void setReg1(int channel, byte setting);
void setReg2(int channel, byte setting);
void setReg3(int channel, byte setting);
//ARX Register Getters
byte getReg1(int channel);
byte getReg2(int channel);
byte getReg3(int channel);
//Send via SPI
void sendReg1();
void sendReg2();
void sendReg3();
//SPI Base Methods
void writeRegister(byte thisRegister, byte thisValue);
void write8(byte reg, byte val);
void write8_diff(byte reg, byte val[]);
void init_ARX_reg();
public:
typedef enum{
SPLIT,
REDUCED,
THRU,
BLOCKED
} filter_t;
//Initialization
ARXsetting();
void init();
void setCS(int ncs);
//ARX Attenuator Settings
void setAt1(int channel, int setting);
void setAt2(int channel, int setting);
void setAts(int channel, int setting);
void setAt1_all(int setting);
void setAt2_all(int setting);
void setAts_all(int setting);
//ARX FEE Settings
void setFEE(int channel, bool setting);
void setFEE_A(int channel, bool setting);
void setFEE_B(int channel, bool setting);
void setFEE_all(bool setting);
//ARX Filter Settings
void setFilter(int channel, filter_t setting);
void setFilter_all(filter_t setting);
//SPI ARX Methods
void sendReg_all();
//Printing Methods
void printreg(int reg); //one indexed
void print_all();
};
#endif