auto-sync

This commit is contained in:
rusEfi 2014-09-13 07:02:58 -05:00
parent 86387bca7b
commit 7d335924d3
6 changed files with 18 additions and 18 deletions

View File

@ -333,6 +333,7 @@ void setMiata1996(engine_configuration_s *engineConfiguration, board_configurati
boardConfiguration->ignitionPinMode = OM_DEFAULT; boardConfiguration->ignitionPinMode = OM_DEFAULT;
// harness is sequential but we have a limited board // harness is sequential but we have a limited board
engineConfiguration->crankingInjectionMode = IM_BATCH;
engineConfiguration->injectionMode = IM_BATCH; engineConfiguration->injectionMode = IM_BATCH;
boardConfiguration->injectionPins[0] = GPIOB_9; // Frankenstein: low side - inj #12 boardConfiguration->injectionPins[0] = GPIOB_9; // Frankenstein: low side - inj #12

View File

@ -43,12 +43,20 @@ void Executor::unlock(void) {
unlockAnyContext(); unlockAnyContext();
} }
void Executor::schedule(scheduling_s *scheduling, uint64_t nowUs, int delayUs, schfunc_t callback, void *param) { void Executor::schedule(const char *prefix, scheduling_s *scheduling, uint64_t nowUs, int delayUs, schfunc_t callback, void *param) {
if (delayUs < 0) {
firmwareError("Negative delayUs %s: %d", prefix, delayUs);
return;
}
if (delayUs == 0) {
callback(param);
return;
}
if (!reentrantLock) { if (!reentrantLock) {
// this would guard the queue and disable interrupts // this would guard the queue and disable interrupts
lock(); lock();
} }
queue.insertTask(scheduling, nowUs, delayUs, callback, param); queue.insertTask(scheduling, nowUs + delayUs, callback, param);
if (!reentrantLock) { if (!reentrantLock) {
doExecute(nowUs); doExecute(nowUs);
unlock(); unlock();
@ -97,15 +105,7 @@ void Executor::doExecute(uint64_t nowUs) {
* @param [in] dwell the number of ticks of output duration. * @param [in] dwell the number of ticks of output duration.
*/ */
void scheduleTask(const char *prefix, scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param) { void scheduleTask(const char *prefix, scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param) {
if (delayUs < 0) { instance.schedule(prefix, scheduling, getTimeNowUs(), delayUs, callback, param);
firmwareError("Negative delayUs %s: %d", prefix, delayUs);
return;
}
if (delayUs == 0) {
callback(param);
return;
}
instance.schedule(scheduling, getTimeNowUs(), delayUs, callback, param);
} }
void initSignalExecutorImpl(void) { void initSignalExecutorImpl(void) {

View File

@ -14,7 +14,7 @@
class Executor { class Executor {
public: public:
Executor(); Executor();
void schedule(scheduling_s *scheduling, uint64_t nowUs, int delayUs, schfunc_t callback, void *param); void schedule(const char *prefix, scheduling_s *scheduling, uint64_t nowUs, int delayUs, schfunc_t callback, void *param);
void execute(uint64_t nowUs); void execute(uint64_t nowUs);
private: private:
EventQueue queue; EventQueue queue;

View File

@ -22,16 +22,16 @@ bool EventQueue::checkIfPending(scheduling_s *scheduling) {
return assertNotInList<scheduling_s>(head, scheduling); return assertNotInList<scheduling_s>(head, scheduling);
} }
void EventQueue::insertTask(scheduling_s *scheduling, uint64_t nowUs, int delayUs, schfunc_t callback, void *param) { void EventQueue::insertTask(scheduling_s *scheduling, uint64_t timeUs, schfunc_t callback, void *param) {
if (callback == NULL) if (callback == NULL)
firmwareError("NULL callback"); firmwareError("NULL callback");
uint64_t time = nowUs + delayUs;
int alreadyPending = checkIfPending(scheduling); int alreadyPending = checkIfPending(scheduling);
if (alreadyPending || hasFirmwareError()) if (alreadyPending || hasFirmwareError())
return; return;
scheduling->momentUs = time; scheduling->momentUs = timeUs;
scheduling->callback = callback; scheduling->callback = callback;
scheduling->param = param; scheduling->param = param;

View File

@ -38,8 +38,7 @@ class EventQueue {
public: public:
EventQueue(); EventQueue();
// void insertTask(scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param); void insertTask(scheduling_s *scheduling, uint64_t timeUs, schfunc_t callback, void *param);
void insertTask(scheduling_s *scheduling, uint64_t nowUs, int delayUs, schfunc_t callback, void *param);
void executeAll(uint64_t now); void executeAll(uint64_t now);

View File

@ -235,5 +235,5 @@ void firmwareError(const char *fmt, ...) {
} }
int getRusEfiVersion(void) { int getRusEfiVersion(void) {
return 20140912; return 20140913;
} }