rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions | Variables
trigger_scope.cpp File Reference

Functions

static void completionCallback (ADCDriver *adcp)
 
static void startSampling ()
 
void triggerScopeEnable ()
 
void triggerScopeDisable ()
 
const BigBufferHandletriggerScopeGetBuffer ()
 
void initTriggerScope ()
 

Variables

static BigBufferHandle buffer
 
static bool isRunning = false
 
static const uint32_t smpr1
 
static const uint32_t smpr2
 
static const ADCConversionGroup adcConvGroupCh1
 
static constexpr size_t sampleCount = BIG_BUFFER_SIZE / (2 * sizeof(uint8_t))
 
static scheduling_s restartTimer
 

Function Documentation

◆ completionCallback()

static void completionCallback ( ADCDriver *  adcp)
static

Definition at line 12 of file trigger_scope.cpp.

12 {
13 if (isRunning && adcp->state == ADC_COMPLETE) {
15 }
16}
TunerStudioOutputChannels outputChannels
Definition engine.h:109
static EngineAccessor engine
Definition engine.h:413
static bool isRunning

◆ initTriggerScope()

void initTriggerScope ( )

Definition at line 104 of file trigger_scope.cpp.

104 {
105 // Trigger scope and knock currently mutually exclusive
107 adcStart(&TRIGGER_SCOPE_ADC, nullptr);
108
109 // Manually set ADC DMA to byte mode, as we'll be taking 8 bit samples
110 // Defaults are to sample at 12 bits, and DMA 16-bit words
111 ADCD3.dmamode &= ~(STM32_DMA_CR_PSIZE_MASK | STM32_DMA_CR_MSIZE_MASK);
112 ADCD3.dmamode |= STM32_DMA_CR_PSIZE_BYTE | STM32_DMA_CR_MSIZE_BYTE;
113
114 efiSetPadMode("trg ch1", TRIGGER_SCOPE_PIN_CH1, PAL_MODE_INPUT_ANALOG);
115#if TRIGGER_SCOPE_HAS_CH2
116 efiSetPadMode("trg ch2", TRIGGER_SCOPE_PIN_CH2, PAL_MODE_INPUT_ANALOG);
117#endif
118 }
119}
void efiSetPadMode(const char *msg, brain_pin_e brainPin, iomode_t mode)
static constexpr engine_configuration_s * engineConfiguration
ADCDriver ADCD3
ADC3 driver identifier.
Definition hal_adc_lld.c:54

Referenced by initHardware().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ startSampling()

static void startSampling ( )
static

Definition at line 56 of file trigger_scope.cpp.

56 {
57 chibios_rt::CriticalSectionLocker csl;
58
60 // Cancel if ADC isn't ready
61 if (!((TRIGGER_SCOPE_ADC.state == ADC_READY) ||
62 (TRIGGER_SCOPE_ADC.state == ADC_COMPLETE) ||
63 (TRIGGER_SCOPE_ADC.state == ADC_ERROR))) {
65 return;
66 }
67
68 adcStartConversionI(&TRIGGER_SCOPE_ADC, &adcConvGroupCh1, buffer.get<adcsample_t>(), sampleCount);
69 }
70}
const TBuffer * get() const
Definition big_buffer.h:34
uint16_t adcsample_t
ADC sample data type.
static constexpr size_t sampleCount
static BigBufferHandle buffer
void triggerScopeDisable()
static const ADCConversionGroup adcConvGroupCh1

Referenced by triggerScopeEnable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ triggerScopeDisable()

void triggerScopeDisable ( )

Definition at line 81 of file trigger_scope.cpp.

81 {
82 // we're done with the buffer - let somebody else have it
83 buffer = {};
84
85 isRunning = false;
87}

Referenced by TunerStudio::handleCrcCommand(), and startSampling().

Here is the caller graph for this function:

◆ triggerScopeEnable()

void triggerScopeEnable ( )

Definition at line 73 of file trigger_scope.cpp.

73 {
75
76 isRunning = true;
77
79}
BigBufferHandle getBigBuffer(BigBufferUser user)
static void startSampling()

Referenced by TunerStudio::handleCrcCommand().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ triggerScopeGetBuffer()

const BigBufferHandle & triggerScopeGetBuffer ( )

Definition at line 92 of file trigger_scope.cpp.

92 {
94
95 // Start the next sample once we've read out this one
96 if (isRunning) {
97 static auto const startSamplingAction{ action_s::make<startSampling>() };
98 engine->scheduler.schedule("trigger scope", &restartTimer, getTimeNowNt() + MS2NT(10), startSamplingAction);
99 }
100
101 return buffer;
102}
SingleTimerExecutor scheduler
Definition engine.h:271
void schedule(const char *msg, scheduling_s *scheduling, efitick_t timeNt, action_s const &action) override
Schedule an action to be executed in the future.
efitick_t getTimeNowNt()
Definition efitime.cpp:19
static scheduling_s restartTimer

Referenced by TunerStudio::handleCrcCommand().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ adcConvGroupCh1

const ADCConversionGroup adcConvGroupCh1
static
Initial value:
= { FALSE, 2, &completionCallback, nullptr,
ADC_CR1_RES_1,
ADC_CR2_SWSTART,
0,
0,
0,
0,
ADC_SQR3_SQ1_N(TRIGGER_SCOPE_ADC_CH1) | ADC_SQR3_SQ2_N(TRIGGER_SCOPE_ADC_CH2)
}
static const uint32_t smpr1
static void completionCallback(ADCDriver *adcp)
static const uint32_t smpr2

Definition at line 38 of file trigger_scope.cpp.

38 { FALSE, 2, &completionCallback, nullptr,
39 ADC_CR1_RES_1, // Sample in 8-bit mode
40 ADC_CR2_SWSTART,
41 // sample times for channels 10...18
42 smpr1,
43 // sample times for channels 0...9
44 smpr2,
45
46 0, // htr
47 0, // ltr
48
49 0, // sqr1
50 0, // sqr2
51 ADC_SQR3_SQ1_N(TRIGGER_SCOPE_ADC_CH1) | ADC_SQR3_SQ2_N(TRIGGER_SCOPE_ADC_CH2)
52};

Referenced by startSampling().

◆ buffer

BigBufferHandle buffer
static

◆ isRunning

bool isRunning = false
static

◆ restartTimer

scheduling_s restartTimer
static

Definition at line 89 of file trigger_scope.cpp.

Referenced by triggerScopeGetBuffer().

◆ sampleCount

constexpr size_t sampleCount = BIG_BUFFER_SIZE / (2 * sizeof(uint8_t))
staticconstexpr

Definition at line 54 of file trigger_scope.cpp.

Referenced by startSampling().

◆ smpr1

const uint32_t smpr1
static
Initial value:
=
ADC_SMPR1_SMP_AN10(TRIGGER_SCOPE_SAMPLE_TIME) |
ADC_SMPR1_SMP_AN11(TRIGGER_SCOPE_SAMPLE_TIME) |
ADC_SMPR1_SMP_AN12(TRIGGER_SCOPE_SAMPLE_TIME) |
ADC_SMPR1_SMP_AN13(TRIGGER_SCOPE_SAMPLE_TIME) |
ADC_SMPR1_SMP_AN14(TRIGGER_SCOPE_SAMPLE_TIME) |
ADC_SMPR1_SMP_AN15(TRIGGER_SCOPE_SAMPLE_TIME)

Definition at line 18 of file trigger_scope.cpp.

◆ smpr2

const uint32_t smpr2
static
Initial value:
=
ADC_SMPR2_SMP_AN0(TRIGGER_SCOPE_SAMPLE_TIME) |
ADC_SMPR2_SMP_AN1(TRIGGER_SCOPE_SAMPLE_TIME) |
ADC_SMPR2_SMP_AN2(TRIGGER_SCOPE_SAMPLE_TIME) |
ADC_SMPR2_SMP_AN3(TRIGGER_SCOPE_SAMPLE_TIME) |
ADC_SMPR2_SMP_AN4(TRIGGER_SCOPE_SAMPLE_TIME) |
ADC_SMPR2_SMP_AN5(TRIGGER_SCOPE_SAMPLE_TIME) |
ADC_SMPR2_SMP_AN6(TRIGGER_SCOPE_SAMPLE_TIME) |
ADC_SMPR2_SMP_AN7(TRIGGER_SCOPE_SAMPLE_TIME) |
ADC_SMPR2_SMP_AN8(TRIGGER_SCOPE_SAMPLE_TIME) |
ADC_SMPR2_SMP_AN9(TRIGGER_SCOPE_SAMPLE_TIME)

Definition at line 26 of file trigger_scope.cpp.

Go to the source code of this file.