Skip to content

Commit 4ffac30

Browse files
committed
allow user to control ADC chopping
1 parent 4f52ead commit 4ffac30

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

m4/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
.vscode/c_cpp_properties.json
44
.vscode/launch.json
55
.vscode/ipch
6+
*.code-workspace

m4/src/Peripherals/ADC/ADCBoard.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
#define ADC2DOUBLE(vin) ADC2DOUBLE24(vin)
7070

7171
class ADCBoard {
72+
public:
73+
bool chopEnabled = true;
7274
private:
7375
int cs_pin;
7476
int data_ready_pin;
@@ -409,17 +411,15 @@ class ADCBoard {
409411
return comm;
410412
}
411413

412-
// chop = true
413414
float setConversionTime(int channel, float time_us) {
414415
return setConversionTimeFloat(channel, time_us,
415416
isMoreThanOneChannelActive());
416417
}
417418

418-
// chop = true
419419
float setConversionTimeFloat(int channel, float time_us,
420420
bool moreThanOneChannelActive) {
421421
return setConversionTime(
422-
channel, true,
422+
channel, chopEnabled,
423423
calculateFilterWord(time_us, true, moreThanOneChannelActive),
424424
moreThanOneChannelActive);
425425
}

m4/src/Peripherals/ADC/ADCController.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ class ADCController {
7272
registerMemberFunction(setChFullScaleCalibration, "SET_FULL_SCALE_CAL");
7373
registerMemberFunction(resetToPreviousConversionTimesSerial,"RESET_MAINTAIN");
7474
registerMemberFunction(hardResetAllADCBoards, "HARD_RESET");
75+
registerMemberFunction(setChopping, "SET_CHOP");
76+
registerMemberFunction(getChopping, "GET_CHOP");
7577
}
7678

7779
inline static void addBoard(int cs_pin, int data_ready,
@@ -112,6 +114,17 @@ class ADCController {
112114
getChannelIndexFromGlobalIndex(channel_index));
113115
}
114116

117+
inline static OperationResult setChopping(bool chop) {
118+
for (auto& board : adc_boards) {
119+
board.chopEnabled = chop;
120+
}
121+
return OperationResult::Success();
122+
}
123+
124+
inline static OperationResult getChopping() {
125+
return adc_boards[0].chopEnabled ? OperationResult::Success("true") : OperationResult::Success("false");
126+
}
127+
115128
inline static OperationResult getRevisionRegister(int board_index) {
116129
if (board_index < 0 || board_index >= adc_boards.size()) {
117130
return OperationResult::Failure("Invalid board index");

m4/src/Peripherals/God.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -384,13 +384,9 @@ class God {
384384
DACController::setVoltageNoTransactionNoLdac(dacChannels[i], dacV0s[i]);
385385
nextVoltageSet[i] += voltageStepSize[i];
386386
}
387-
DACController::toggleLdac();
387+
388388
steps++;
389389

390-
for (int i = 0; i < numDacChannels; i++) {
391-
DACController::setVoltageNoTransactionNoLdac(dacChannels[i], nextVoltageSet[i]);
392-
nextVoltageSet[i] += voltageStepSize[i];
393-
}
394390

395391
for (int i = 0; i < numAdcChannels; i++) {
396392
ADCController::startContinuousConversion(adcChannels[i]);

0 commit comments

Comments
 (0)