Skip to content

Commit

Permalink
extract PortPrepareAnalogSampling
Browse files Browse the repository at this point in the history
  • Loading branch information
mck1117 committed Jan 28, 2025
1 parent aa23d10 commit 2374ac7
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 1 deletion.
5 changes: 5 additions & 0 deletions firmware/boards/f0_module/port.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

#define ADC_CHANNEL_COUNT 3

void PortPrepareAnalogSampling()
{
adcStart(&ADCD1, nullptr);
}

static adcsample_t adcBuffer[ADC_CHANNEL_COUNT * ADC_OVERSAMPLE];

const ADCConversionGroup convGroup =
Expand Down
5 changes: 5 additions & 0 deletions firmware/boards/f1_dual/port.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

#include "hal.h"

void PortPrepareAnalogSampling()
{
adcStart(&ADCD1, nullptr);
}

#define ADC_CHANNEL_COUNT 8
#define ADC_SAMPLE ADC_SAMPLE_7P5

Expand Down
5 changes: 5 additions & 0 deletions firmware/boards/f1_dual_rev1/port.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

#include "hal.h"

void PortPrepareAnalogSampling()
{
adcStart(&ADCD1, nullptr);
}

#define ADC_CHANNEL_COUNT 10
#define ADC_SAMPLE ADC_SAMPLE_7P5

Expand Down
5 changes: 5 additions & 0 deletions firmware/boards/f1_rev2/port.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

#include "hal.h"

void PortPrepareAnalogSampling()
{
adcStart(&ADCD1, nullptr);
}

#define ADC_CHANNEL_COUNT 5
#define ADC_SAMPLE ADC_SAMPLE_7P5

Expand Down
5 changes: 5 additions & 0 deletions firmware/boards/f1_rev3/port.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

#include "wideband_config.h"

void PortPrepareAnalogSampling()
{
adcStart(&ADCD1, nullptr);
}

#define ADC_CHANNEL_COUNT 5
#define ADC_SAMPLE ADC_SAMPLE_7P5

Expand Down
2 changes: 2 additions & 0 deletions firmware/boards/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ struct AnalogResult
#endif
};

// Enable ADCs, configure pins, etc
void PortPrepareAnalogSampling();
AnalogResult AnalogSample();

enum class SensorType : uint8_t {
Expand Down
3 changes: 2 additions & 1 deletion firmware/sampling_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ void StartSampling()
samplers[i].Init();
}

adcStart(&ADCD1, nullptr);
PortPrepareAnalogSampling();

chThdCreateStatic(waSamplingThread, sizeof(waSamplingThread), NORMALPRIO + 5, SamplingThread, nullptr);
}

0 comments on commit 2374ac7

Please sign in to comment.