Speeduino
Loading...
Searching...
No Matches
idleController_state.h
Go to the documentation of this file.
1#pragma once
2
4#include "stepper.h"
8#include "src/pins/inputPin.h"
10#include "config_pages.h"
11
12namespace idleController {
13
14namespace detail {
15
16using fnCurMicros_t = decltype(micros)*;
17
18struct state_t
19{
20 uint8_t idleCounter = 0; //Used for tracking the number of calls to the idle control function
21 uint8_t idleTaper = 0;
22
24 bool idleOn = false; //Simply tracks whether idle was on last time around
25 uint8_t idleInitComplete = 99; //Tracks which idle method was initialised. 99 is a method that will never exist
26 unsigned int iacStepTime_uS = 0;
27 unsigned int iacCoolTime_uS = 0;
28
29 volatile bool idle_pwm_state = false;
30 bool lastDFCOValue = false;
31 uint16_t idle_pwm_max_count = 0; //Used for variable PWM frequency
32 volatile unsigned int idle_pwm_cur_value = 0;
34 int32_t FeedForwardTerm = 0;
36 int32_t idle_cl_target_rpm = 0;
37
42
43 integerPID idlePID; //This is the PID object if that algorithm is used. Needs to be global as it maintains state outside of each function call
44
45 state_t() = default;
46 state_t(const pinNumbers_t &pins, const config2 &page2, const config6 &page6, const config9 &page9);
47
48 void setPinHigh(void)
49 {
51 idle2_pin.setPinLow(); //If 2 idle channels are in use, flip idle2 to be the opposite of idle1
52 }
53
54 void setPinLow(void)
55 {
57 idle2_pin.setPinHigh(); //If 2 idle channels are in use, flip idle2 to be the opposite of idle1
58 }
59};
60
61} // detail
62
63} // fuelPumpController
A class for input pin operations.
Definition inputPin.h:12
Definition integerPID.h:7
An output pin that, optionally, can be have it's state inverted.
Definition invertableOutputPin.h:13
void setPinHigh(void) noexcept
Set the pin high.
Definition invertableOutputPin.h:22
void setPinLow(void) noexcept
Set the pin low.
Definition invertableOutputPin.h:31
The tune page structs and related defines.
const config2 & page2
Definition engineProtection.cpp:455
const config4 const config6 const config9 & page9
Definition engineProtection.cpp:172
const config4 const config6 & page6
Definition engineProtection.cpp:172
decltype(micros) * fnCurMicros_t
Definition idleController_state.h:16
Definition idleController_state.cpp:5
static fastOutputPin_t pins[_countof(coil_pins_t::_M_elems)]
Definition scheduledIO_direct_ign.cpp:10
Definition config_pages.h:179
Definition config_pages.h:461
Definition config_pages.h:578
Definition idleController_state.h:19
unsigned int iacCoolTime_uS
Definition idleController_state.h:27
invertableOutputPinAdaper_t< fastOutputPin_t > idle_pin
Definition idleController_state.h:38
stepperState_t idleStepper
Definition idleController_state.h:23
volatile bool idle_pwm_state
Definition idleController_state.h:29
int32_t idle_pid_target_value
Definition idleController_state.h:33
int32_t idle_cl_target_rpm
Definition idleController_state.h:36
inputPin_t pinIdleUpInput
Definition idleController_state.h:41
volatile unsigned int idle_pwm_cur_value
Definition idleController_state.h:32
bool idleOn
Definition idleController_state.h:24
uint8_t idleCounter
Definition idleController_state.h:20
uint8_t idleInitComplete
Definition idleController_state.h:25
void setPinLow(void)
Definition idleController_state.h:54
uint16_t idle_pwm_max_count
Definition idleController_state.h:31
uint8_t idleTaper
Definition idleController_state.h:21
invertableOutputPinAdaper_t< fastOutputPin_t > idle2_pin
Definition idleController_state.h:39
void setPinHigh(void)
Definition idleController_state.h:48
int32_t FeedForwardTerm
Definition idleController_state.h:34
unsigned int iacStepTime_uS
Definition idleController_state.h:26
invertableOutputPinAdaper_t< outputPin_t > pinIdleUpOutput
Definition idleController_state.h:40
bool lastDFCOValue
Definition idleController_state.h:30
integerPID idlePID
Definition idleController_state.h:43
uint32_t idle_pwm_target_value
Definition idleController_state.h:35
Captures the state of the stepper motor.
Definition stepper.h:29
Store the pin assignments, as defined by the board.
Definition pinNumbers_t.h:41