#616 idle for simulator
This commit is contained in:
parent
61a39de21e
commit
6d933ceb82
|
@ -226,3 +226,30 @@ void PwmConfig::weComplexInit(const char *msg, int phaseCount, float *switchTime
|
||||||
// let's start the indefinite callback loop of PWM generation
|
// let's start the indefinite callback loop of PWM generation
|
||||||
timerCallback(this);
|
timerCallback(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void startSimplePwm(PwmConfig *state, const char *msg, OutputPin *output, float frequency, float dutyCycle, pwm_gen_callback *stateChangeCallback) {
|
||||||
|
efiAssertVoid(CUSTOM_ERR_6665, dutyCycle >= 0 && dutyCycle <= 1, "dutyCycle");
|
||||||
|
if (frequency < 1) {
|
||||||
|
warning(CUSTOM_OBD_LOW_FREQUENCY, "low frequency %.2f", frequency);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float switchTimes[] = { dutyCycle, 1 };
|
||||||
|
pin_state_t pinStates0[] = { 0, 1 };
|
||||||
|
|
||||||
|
pin_state_t *pinStates[1] = { pinStates0 };
|
||||||
|
|
||||||
|
state->outputPins[0] = output;
|
||||||
|
|
||||||
|
state->setFrequency(frequency);
|
||||||
|
state->weComplexInit(msg, 2, switchTimes, 1, pinStates, NULL, stateChangeCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
void startSimplePwmExt(PwmConfig *state, const char *msg, brain_pin_e brainPin, OutputPin *output, float frequency,
|
||||||
|
float dutyCycle, pwm_gen_callback *stateChangeCallback) {
|
||||||
|
|
||||||
|
output->initPin(msg, brainPin);
|
||||||
|
|
||||||
|
startSimplePwm(state, msg, output, frequency, dutyCycle, stateChangeCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,6 +101,22 @@ private:
|
||||||
single_wave_s waveInstance;
|
single_wave_s waveInstance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start a one-channel software PWM driver.
|
||||||
|
*
|
||||||
|
* This method should be called after scheduling layer is started by initSignalExecutor()
|
||||||
|
*/
|
||||||
|
void startSimplePwm(PwmConfig *state, const char *msg, OutputPin *output,
|
||||||
|
float dutyCycle, float frequency, pwm_gen_callback *stateChangeCallback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* initialize GPIO pin and start a one-channel software PWM driver.
|
||||||
|
*
|
||||||
|
* This method should be called after scheduling layer is started by initSignalExecutor()
|
||||||
|
*/
|
||||||
|
void startSimplePwmExt(PwmConfig *state, const char *msg, brain_pin_e brainPin, OutputPin *output,
|
||||||
|
float frequency, float dutyCycle, pwm_gen_callback *stateChangeCallback);
|
||||||
|
|
||||||
void copyPwmParameters(PwmConfig *state, int phaseCount, float *switchTimes,
|
void copyPwmParameters(PwmConfig *state, int phaseCount, float *switchTimes,
|
||||||
int waveCount, pin_state_t **pinStates);
|
int waveCount, pin_state_t **pinStates);
|
||||||
|
|
||||||
|
|
|
@ -32,32 +32,6 @@ void applyPinState(PwmConfig *state, int stateIndex) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void startSimplePwm(PwmConfig *state, const char *msg, OutputPin *output, float frequency, float dutyCycle, pwm_gen_callback *stateChangeCallback) {
|
|
||||||
efiAssertVoid(CUSTOM_ERR_6665, dutyCycle >= 0 && dutyCycle <= 1, "dutyCycle");
|
|
||||||
if (frequency < 1) {
|
|
||||||
warning(CUSTOM_OBD_LOW_FREQUENCY, "low frequency %.2f", frequency);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
float switchTimes[] = { dutyCycle, 1 };
|
|
||||||
pin_state_t pinStates0[] = { 0, 1 };
|
|
||||||
|
|
||||||
pin_state_t *pinStates[1] = { pinStates0 };
|
|
||||||
|
|
||||||
state->outputPins[0] = output;
|
|
||||||
|
|
||||||
state->setFrequency(frequency);
|
|
||||||
state->weComplexInit(msg, 2, switchTimes, 1, pinStates, NULL, stateChangeCallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void startSimplePwmExt(PwmConfig *state, const char *msg, brain_pin_e brainPin, OutputPin *output, float frequency,
|
|
||||||
float dutyCycle, pwm_gen_callback *stateChangeCallback) {
|
|
||||||
|
|
||||||
output->initPin(msg, brainPin);
|
|
||||||
|
|
||||||
startSimplePwm(state, msg, output, frequency, dutyCycle, stateChangeCallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
void initPwmGenerator(void) {
|
void initPwmGenerator(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,22 +17,6 @@
|
||||||
|
|
||||||
void initPwmGenerator(void);
|
void initPwmGenerator(void);
|
||||||
|
|
||||||
/**
|
|
||||||
* Start a one-channel software PWM driver.
|
|
||||||
*
|
|
||||||
* This method should be called after scheduling layer is started by initSignalExecutor()
|
|
||||||
*/
|
|
||||||
void startSimplePwm(PwmConfig *state, const char *msg, OutputPin *output,
|
|
||||||
float dutyCycle, float frequency, pwm_gen_callback *stateChangeCallback);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* initialize GPIO pin and start a one-channel software PWM driver.
|
|
||||||
*
|
|
||||||
* This method should be called after scheduling layer is started by initSignalExecutor()
|
|
||||||
*/
|
|
||||||
void startSimplePwmExt(PwmConfig *state, const char *msg, brain_pin_e brainPin, OutputPin *output,
|
|
||||||
float frequency, float dutyCycle, pwm_gen_callback *stateChangeCallback);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* default implementation of pwm_gen_callback which simply toggles the pins
|
* default implementation of pwm_gen_callback which simply toggles the pins
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue