auto-sync
This commit is contained in:
parent
d63915758b
commit
493f09337a
|
@ -22,19 +22,22 @@ static SimplePwm pwmTest[5];
|
||||||
|
|
||||||
extern board_configuration_s *boardConfiguration;
|
extern board_configuration_s *boardConfiguration;
|
||||||
|
|
||||||
|
extern OutputPin warningPin;
|
||||||
|
extern OutputPin outputs[IO_PIN_COUNT];
|
||||||
|
|
||||||
static void startPwmTest(int freq) {
|
static void startPwmTest(int freq) {
|
||||||
scheduleMsg(&logger, "running pwm test @%d", freq);
|
scheduleMsg(&logger, "running pwm test @%d", freq);
|
||||||
|
|
||||||
// PD13, GPIO_UNASSIGNED because pin is initialized elsewhere already
|
// PD13, GPIO_UNASSIGNED because pin is initialized elsewhere already
|
||||||
startSimplePwm(&pwmTest[0], "tester", LED_WARNING, 10, 0.5f, applyPinState);
|
startSimplePwm(&pwmTest[0], "tester", &warningPin, 10, 0.5f, applyPinState);
|
||||||
// currently this is PB9 by default - see boardConfiguration->injectionPins
|
// currently this is PB9 by default - see boardConfiguration->injectionPins
|
||||||
startSimplePwm(&pwmTest[1], "tester", INJECTOR_1_OUTPUT, freq / 1.3333333333, 0.5f, applyPinState);
|
startSimplePwm(&pwmTest[1], "tester", &outputs[(int)INJECTOR_1_OUTPUT], freq / 1.3333333333, 0.5f, applyPinState);
|
||||||
// currently this is PB8 by default
|
// currently this is PB8 by default
|
||||||
startSimplePwm(&pwmTest[2], "tester", INJECTOR_2_OUTPUT, freq / 1000, 0.5f, applyPinState);
|
startSimplePwm(&pwmTest[2], "tester", &outputs[(int)INJECTOR_2_OUTPUT], freq / 1000, 0.5f, applyPinState);
|
||||||
// currently this is PE3 by default
|
// currently this is PE3 by default
|
||||||
startSimplePwm(&pwmTest[3], "tester", INJECTOR_3_OUTPUT, freq, 0.5, applyPinState);
|
startSimplePwm(&pwmTest[3], "tester", &outputs[(int)INJECTOR_3_OUTPUT], freq, 0.5, applyPinState);
|
||||||
// currently this is PE5 by default
|
// currently this is PE5 by default
|
||||||
startSimplePwm(&pwmTest[4], "tester", INJECTOR_4_OUTPUT, freq / 33.33333333333, 0.5, applyPinState);
|
startSimplePwm(&pwmTest[4], "tester", &outputs[(int)INJECTOR_4_OUTPUT], freq / 33.33333333333, 0.5, applyPinState);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initPwmTester(void) {
|
void initPwmTester(void) {
|
||||||
|
|
|
@ -162,10 +162,10 @@ void copyPwmParameters(PwmConfig *state, int phaseCount, float *switchTimes, int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void weComplexInit(const char *msg, PwmConfig *state, int phaseCount, float *switchTimes, int waveCount,
|
void PwmConfig::weComplexInit(const char *msg, int phaseCount, float *switchTimes, int waveCount,
|
||||||
int **pinStates, pwm_cycle_callback *cycleCallback, pwm_gen_callback *stateChangeCallback) {
|
int **pinStates, pwm_cycle_callback *cycleCallback, pwm_gen_callback *stateChangeCallback) {
|
||||||
|
|
||||||
efiAssertVoid(state->periodNt != 0, "period is not initialized");
|
efiAssertVoid(periodNt != 0, "period is not initialized");
|
||||||
if (phaseCount == 0) {
|
if (phaseCount == 0) {
|
||||||
firmwareError("signal length cannot be zero");
|
firmwareError("signal length cannot be zero");
|
||||||
return;
|
return;
|
||||||
|
@ -181,18 +181,18 @@ void weComplexInit(const char *msg, PwmConfig *state, int phaseCount, float *swi
|
||||||
efiAssertVoid(waveCount > 0, "waveCount should be positive");
|
efiAssertVoid(waveCount > 0, "waveCount should be positive");
|
||||||
checkSwitchTimes2(phaseCount, switchTimes);
|
checkSwitchTimes2(phaseCount, switchTimes);
|
||||||
|
|
||||||
state->multiWave.waveCount = waveCount;
|
this->cycleCallback = cycleCallback;
|
||||||
|
this->stateChangeCallback = stateChangeCallback;
|
||||||
|
|
||||||
copyPwmParameters(state, phaseCount, switchTimes, waveCount, pinStates);
|
multiWave.waveCount = waveCount;
|
||||||
|
|
||||||
state->cycleCallback = cycleCallback;
|
copyPwmParameters(this, phaseCount, switchTimes, waveCount, pinStates);
|
||||||
state->stateChangeCallback = stateChangeCallback;
|
|
||||||
|
|
||||||
state->safe.phaseIndex = 0;
|
safe.phaseIndex = 0;
|
||||||
state->safe.periodNt = -1;
|
safe.periodNt = -1;
|
||||||
state->safe.iteration = -1;
|
safe.iteration = -1;
|
||||||
state->name = msg;
|
name = msg;
|
||||||
|
|
||||||
// let's start the indefinite callback loop of PWM generation
|
// let's start the indefinite callback loop of PWM generation
|
||||||
timerCallback(state);
|
timerCallback(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,12 @@ public:
|
||||||
PwmConfig(float *switchTimes, single_wave_s *waves);
|
PwmConfig(float *switchTimes, single_wave_s *waves);
|
||||||
void init(float *switchTimes, single_wave_s *waves);
|
void init(float *switchTimes, single_wave_s *waves);
|
||||||
|
|
||||||
|
void weComplexInit(const char *msg,
|
||||||
|
int phaseCount, float *swithcTimes, int waveCount, int **pinStates,
|
||||||
|
pwm_cycle_callback *cycleCallback,
|
||||||
|
pwm_gen_callback *callback);
|
||||||
|
|
||||||
|
|
||||||
void handleCycleStart();
|
void handleCycleStart();
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,22 +93,7 @@ public:
|
||||||
float _switchTimes[2];
|
float _switchTimes[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
void copyPwmParameters(PwmConfig *state, int phaseCount, float *switchTimes,
|
void copyPwmParameters(PwmConfig *state, int phaseCount, float *switchTimes,
|
||||||
int waveCount, int **pinStates);
|
int waveCount, int **pinStates);
|
||||||
|
|
||||||
void weComplexInit(const char *msg, PwmConfig *state,
|
|
||||||
int phaseCount, float *swithcTimes, int waveCount, int **pinStates,
|
|
||||||
pwm_cycle_callback *cycleCallback,
|
|
||||||
pwm_gen_callback *callback);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* PWM_GENERATOR_LOGIC_H_ */
|
#endif /* PWM_GENERATOR_LOGIC_H_ */
|
||||||
|
|
|
@ -140,7 +140,7 @@ void initTriggerEmulatorLogic(Engine *engine) {
|
||||||
setTriggerEmulatorRPM(engineConfiguration->bc.triggerSimulatorFrequency, engine);
|
setTriggerEmulatorRPM(engineConfiguration->bc.triggerSimulatorFrequency, engine);
|
||||||
int *pinStates[PWM_PHASE_MAX_WAVE_PER_PWM] = { s->wave.waves[0].pinStates, s->wave.waves[1].pinStates,
|
int *pinStates[PWM_PHASE_MAX_WAVE_PER_PWM] = { s->wave.waves[0].pinStates, s->wave.waves[1].pinStates,
|
||||||
s->wave.waves[2].pinStates };
|
s->wave.waves[2].pinStates };
|
||||||
weComplexInit("position sensor", &triggerSignal, s->getSize(), s->wave.switchTimes, PWM_PHASE_MAX_WAVE_PER_PWM,
|
triggerSignal.weComplexInit("position sensor", s->getSize(), s->wave.switchTimes, PWM_PHASE_MAX_WAVE_PER_PWM,
|
||||||
pinStates, updateTriggerShapeIfNeeded, emulatorApplyPinState);
|
pinStates, updateTriggerShapeIfNeeded, emulatorApplyPinState);
|
||||||
|
|
||||||
addConsoleActionIP("rpm", (VoidIntVoidPtr)setTriggerEmulatorRPM, engine);
|
addConsoleActionIP("rpm", (VoidIntVoidPtr)setTriggerEmulatorRPM, engine);
|
||||||
|
|
|
@ -17,9 +17,6 @@
|
||||||
#include "pin_repository.h"
|
#include "pin_repository.h"
|
||||||
#include "datalogging.h"
|
#include "datalogging.h"
|
||||||
|
|
||||||
static Logging logger;
|
|
||||||
extern OutputPin outputs[IO_PIN_COUNT];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method controls the actual hardware pins
|
* This method controls the actual hardware pins
|
||||||
*
|
*
|
||||||
|
@ -46,7 +43,7 @@ void startSimplePwm(PwmConfig *state, const char *msg, OutputPin *output, float
|
||||||
state->outputPins[0] = output;
|
state->outputPins[0] = output;
|
||||||
|
|
||||||
state->periodNt = US2NT(frequency2periodUs(frequency));
|
state->periodNt = US2NT(frequency2periodUs(frequency));
|
||||||
weComplexInit(msg, state, 2, switchTimes, 1, pinStates, NULL, stateChangeCallback);
|
state->weComplexInit(msg, 2, switchTimes, 1, pinStates, NULL, stateChangeCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void startSimplePwmExt(PwmConfig *state, const char *msg, brain_pin_e brainPin, OutputPin *output, float frequency,
|
void startSimplePwmExt(PwmConfig *state, const char *msg, brain_pin_e brainPin, OutputPin *output, float frequency,
|
||||||
|
@ -60,6 +57,5 @@ void startSimplePwmExt(PwmConfig *state, const char *msg, brain_pin_e brainPin,
|
||||||
}
|
}
|
||||||
|
|
||||||
void initPwmGenerator(void) {
|
void initPwmGenerator(void) {
|
||||||
initLogging(&logger, "PWM gen");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,23 @@
|
||||||
|
|
||||||
#include "gpio_helper.h"
|
#include "gpio_helper.h"
|
||||||
|
|
||||||
void startSimplePwm(PwmConfig *state, const char *msg, OutputPin *output,
|
|
||||||
float dutyCycle, float frequency, pwm_gen_callback *stateChangeCallback);
|
|
||||||
void applyPinState(PwmConfig *state, int stateIndex);
|
|
||||||
|
|
||||||
void initPwmGenerator(void);
|
void initPwmGenerator(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* start a one-channel PWM driver
|
||||||
|
*/
|
||||||
|
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 PWM driver
|
||||||
|
*/
|
||||||
void startSimplePwmExt(PwmConfig *state, const char *msg, brain_pin_e brainPin, OutputPin *output,
|
void startSimplePwmExt(PwmConfig *state, const char *msg, brain_pin_e brainPin, OutputPin *output,
|
||||||
float frequency, float dutyCycle, pwm_gen_callback *stateChangeCallback);
|
float frequency, float dutyCycle, pwm_gen_callback *stateChangeCallback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* default implementation of pwm_gen_callback which simply toggles the pins
|
||||||
|
*/
|
||||||
|
void applyPinState(PwmConfig *state, int stateIndex);
|
||||||
|
|
||||||
#endif /* PWM_GENERATOR_H_ */
|
#endif /* PWM_GENERATOR_H_ */
|
||||||
|
|
|
@ -268,5 +268,5 @@ int getRusEfiVersion(void) {
|
||||||
return 1; // this is here to make the compiler happy about the unused array
|
return 1; // this is here to make the compiler happy about the unused array
|
||||||
if (UNUSED_CCM_SIZE == 0)
|
if (UNUSED_CCM_SIZE == 0)
|
||||||
return 1; // this is here to make the compiler happy about the unused array
|
return 1; // this is here to make the compiler happy about the unused array
|
||||||
return 20150107;
|
return 20150108;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue