auto-sync
This commit is contained in:
parent
662f02f28a
commit
37244f5e35
|
@ -57,15 +57,18 @@ static void testCallback(void *arg) {
|
|||
*/
|
||||
float delayMs = 0.1;
|
||||
float durationMs = 1.6;
|
||||
scheduleOutput(&outSignals[0], delayMs, durationMs);
|
||||
scheduleOutput(&outSignals[1], delayMs, durationMs);
|
||||
scheduleOutput(&outSignals[2], delayMs, durationMs);
|
||||
scheduleOutput(&outSignals[3], delayMs, durationMs);
|
||||
|
||||
scheduleOutput(&outSignals[4], delayMs, durationMs);
|
||||
scheduleOutput(&outSignals[5], delayMs, durationMs);
|
||||
scheduleOutput(&outSignals[6], delayMs, durationMs);
|
||||
scheduleOutput(&outSignals[7], delayMs, durationMs);
|
||||
efitimeus_t nowUs = getTimeNowUs();
|
||||
|
||||
scheduleOutput(&outSignals[0], nowUs, delayMs, durationMs);
|
||||
scheduleOutput(&outSignals[1], nowUs, delayMs, durationMs);
|
||||
scheduleOutput(&outSignals[2], nowUs, delayMs, durationMs);
|
||||
scheduleOutput(&outSignals[3], nowUs, delayMs, durationMs);
|
||||
|
||||
scheduleOutput(&outSignals[4], nowUs, delayMs, durationMs);
|
||||
scheduleOutput(&outSignals[5], nowUs, delayMs, durationMs);
|
||||
scheduleOutput(&outSignals[6], nowUs, delayMs, durationMs);
|
||||
scheduleOutput(&outSignals[7], nowUs, delayMs, durationMs);
|
||||
|
||||
/**
|
||||
* this would re-schedule another callback in 2ms from now
|
||||
|
|
|
@ -118,7 +118,7 @@ int getRevolutionCounter(void);
|
|||
* @param dwell the number of ticks of output duration
|
||||
*
|
||||
*/
|
||||
void scheduleOutput(OutputSignal *signal, float delayMs, float durationMs) {
|
||||
void scheduleOutput(OutputSignal *signal, efitimeus_t nowUs, float delayMs, float durationMs) {
|
||||
#if EFI_GPIO
|
||||
if (durationMs < 0) {
|
||||
firmwareError("duration cannot be negative: %d", durationMs);
|
||||
|
@ -134,8 +134,6 @@ void scheduleOutput(OutputSignal *signal, float delayMs, float durationMs) {
|
|||
scheduling_s * sUp = &signal->signalTimerUp[index];
|
||||
scheduling_s * sDown = &signal->signalTimerDown[index];
|
||||
|
||||
efitimeus_t nowUs = getTimeNowUs();
|
||||
|
||||
scheduleByTime("out up", sUp, nowUs + (int) MS2US(delayMs), (schfunc_t) &turnPinHigh, signal->output);
|
||||
scheduleByTime("out down", sDown, nowUs + (int) MS2US(delayMs + durationMs), (schfunc_t) &turnPinLow, signal->output);
|
||||
#endif
|
||||
|
|
|
@ -39,19 +39,10 @@ struct OutputSignal_struct {
|
|||
scheduling_s signalTimerDown[2];
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
void scheduleOutput(OutputSignal *signal, float delayMs, float durationMs);
|
||||
|
||||
void scheduleOutput(OutputSignal *signal, efitimeus_t nowUs, float delayMs, float durationMs);
|
||||
void initSignalExecutor(void);
|
||||
void scheduleByAngle(int rpm, scheduling_s *timer, angle_t angle, schfunc_t callback, void *param);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
void scheduleByAngle(int rpm, scheduling_s *timer, angle_t angle, schfunc_t callback, void *param);
|
||||
|
||||
void initSignalExecutorImpl(void);
|
||||
|
||||
|
|
|
@ -154,10 +154,12 @@ static void updateErrorCodes(void) {
|
|||
|
||||
Overflow64Counter halTime;
|
||||
|
||||
//todo: macro to save method invocation
|
||||
efitimeus_t getTimeNowUs(void) {
|
||||
return getTimeNowNt() / (CORE_CLOCK / 1000000);
|
||||
}
|
||||
|
||||
//todo: macro to save method invocation
|
||||
efitick_t getTimeNowNt(void) {
|
||||
return halTime.get();
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(InjectionEvent *event, int rp
|
|||
scheduleTask("out down", sDown, (int) MS2US(delayMs) + MS2US(fuelMs), (schfunc_t) &endSimultaniousInjection, engine);
|
||||
|
||||
} else {
|
||||
scheduleOutput(event->actuator, delayMs, fuelMs);
|
||||
scheduleOutput(event->actuator, getTimeNowUs(), delayMs, fuelMs);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,15 +17,13 @@
|
|||
EventQueue schedulingQueue;
|
||||
|
||||
void scheduleTask(const char *msg, scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param) {
|
||||
schedulingQueue.insertTask(scheduling, getTimeNowUs() + delayUs, callback, param);
|
||||
scheduleByTime(msg, scheduling, getTimeNowUs() + delayUs, callback, param);
|
||||
}
|
||||
|
||||
void scheduleTask2(const char *prefix, scheduling_s *scheduling, uint64_t time, schfunc_t callback, void *param) {
|
||||
firmwareError("not implemented");
|
||||
//schedulingQueue.insertTask(scheduling, getTimeNowUs() + delayUs, callback, param);
|
||||
void scheduleByTime(const char *prefix, scheduling_s *scheduling, efitimeus_t time, schfunc_t callback, void *param) {
|
||||
schedulingQueue.insertTask(scheduling, time, callback, param);
|
||||
}
|
||||
|
||||
|
||||
void initSignalExecutorImpl(void) {
|
||||
}
|
||||
|
||||
|
|
|
@ -9,16 +9,6 @@
|
|||
#define TEST_SIGNAL_EXECUTOR_H_
|
||||
|
||||
int getRevolutionCounter();
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
void testSignalExecutor(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* TEST_SIGNAL_EXECUTOR_H_ */
|
||||
|
|
Loading…
Reference in New Issue