rusefi-1/firmware/controllers/PwmTester.cpp

50 lines
1.5 KiB
C++
Raw Normal View History

2014-08-29 07:52:33 -07:00
/**
* @file PwmTester.cpp
* This is a tool to measure rusEfi PWM generation quality
*
* @date Apr 29, 2014
2015-01-12 15:04:10 -08:00
* @author Andrey Belomutskiy, (c) 2012-2015
2014-08-29 07:52:33 -07:00
*/
#include "main.h"
2014-12-24 10:05:36 -08:00
#if EFI_PWM_TESTER
2014-08-29 07:52:33 -07:00
#include "PwmTester.h"
#include "EfiWave.h"
#include "pwm_generator_logic.h"
#include "engine_configuration.h"
#include "pwm_generator.h"
static Logging logger;
static SimplePwm pwmTest[5];
extern board_configuration_s *boardConfiguration;
2015-01-08 07:03:44 -08:00
extern OutputPin warningPin;
extern OutputPin outputs[IO_PIN_COUNT];
2014-08-29 07:52:33 -07:00
static void startPwmTest(int freq) {
scheduleMsg(&logger, "running pwm test @%d", freq);
2014-11-10 07:03:20 -08:00
// PD13, GPIO_UNASSIGNED because pin is initialized elsewhere already
2015-01-08 07:03:44 -08:00
startSimplePwm(&pwmTest[0], "tester", &warningPin, 10, 0.5f, applyPinState);
2014-08-29 07:52:33 -07:00
// currently this is PB9 by default - see boardConfiguration->injectionPins
2015-01-08 07:03:44 -08:00
startSimplePwm(&pwmTest[1], "tester", &outputs[(int)INJECTOR_1_OUTPUT], freq / 1.3333333333, 0.5f, applyPinState);
2014-08-29 07:52:33 -07:00
// currently this is PB8 by default
2015-01-08 07:03:44 -08:00
startSimplePwm(&pwmTest[2], "tester", &outputs[(int)INJECTOR_2_OUTPUT], freq / 1000, 0.5f, applyPinState);
2014-08-29 07:52:33 -07:00
// currently this is PE3 by default
2015-01-08 07:03:44 -08:00
startSimplePwm(&pwmTest[3], "tester", &outputs[(int)INJECTOR_3_OUTPUT], freq, 0.5, applyPinState);
2014-08-29 07:52:33 -07:00
// currently this is PE5 by default
2015-01-08 07:03:44 -08:00
startSimplePwm(&pwmTest[4], "tester", &outputs[(int)INJECTOR_4_OUTPUT], freq / 33.33333333333, 0.5, applyPinState);
2014-08-29 07:52:33 -07:00
}
void initPwmTester(void) {
initLogging(&logger, "pwm test");
addConsoleActionI("pwmtest", startPwmTest);
// un-comment this to start pwm test on start up startPwmTest(1000);
}
2014-12-24 10:05:36 -08:00
#endif