auto-sync

This commit is contained in:
rusEfi 2015-04-17 21:04:22 -04:00
parent 9b5a79680b
commit 0c5c82a8a4
11 changed files with 40 additions and 21 deletions

View File

@ -215,10 +215,10 @@ float getMap(void) {
void initMapAveraging(Logging *sharedLogger, Engine *engine) {
logger = sharedLogger;
startTimer[0].name = "map start0";
startTimer[1].name = "map start1";
endTimer[0].name = "map end0";
endTimer[1].name = "map end1";
// startTimer[0].name = "map start0";
// startTimer[1].name = "map start1";
// endTimer[0].name = "map end0";
// endTimer[1].name = "map end1";
addTriggerEventListener(&mapAveragingCallback, "MAP averaging", engine);
addConsoleAction("faststat", showMapStats);

View File

@ -153,12 +153,12 @@ void Executor::scheduleTimerCallback() {
* @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) {
scheduling->name = prefix;
// scheduling->name = prefix;
instance.scheduleByTime(scheduling, getTimeNowUs() + delayUs, callback, param);
}
void scheduleByTime(const char *prefix, scheduling_s *scheduling, efitimeus_t time, schfunc_t callback, void *param) {
scheduling->name = prefix;
// scheduling->name = prefix;
instance.scheduleByTime(scheduling, time, callback, param);
}

View File

@ -16,6 +16,12 @@
#include "efitime.h"
#include "efilib2.h"
scheduling_s::scheduling_s() {
callback = NULL;
next = NULL;
isScheduled = false;
}
EventQueue::EventQueue() {
head = NULL;
setLateDelay(100);
@ -34,13 +40,13 @@ bool_t EventQueue::insertTask(scheduling_s *scheduling, uint64_t timeX, schfunc_
#endif
efiAssert(callback != NULL, "NULL callback", false);
int alreadyPending = checkIfPending(scheduling);
if (alreadyPending)
if (scheduling->isScheduled)
return false;
scheduling->momentX = timeX;
scheduling->callback = callback;
scheduling->param = param;
scheduling->isScheduled = true;
if (head == NULL || timeX < head->momentX) {
LL_PREPEND(head, scheduling);
@ -139,6 +145,7 @@ int EventQueue::executeAll(uint64_t now) {
LL_FOREACH_SAFE(executionList, current, tmp)
{
uint32_t before = GET_TIMESTAMP();
current->isScheduled = false;
current->callback(current->param);
// even with overflow it's safe to substract here
lastEventQueueTime = GET_TIMESTAMP() - before;

View File

@ -35,7 +35,7 @@ bool assertNotInList(T *head, T*element) {
* was not scheduled by angle but was scheduled by time. In case of scheduling
* by time with slow RPM the whole next fast revolution might be within the wait period
*/
warning(OBD_PCM_Processor_Fault, "re-adding element into event_queue: [%s]", element->name);
warning(OBD_PCM_Processor_Fault, "re-adding element into event_queue");
return true;
}
}

View File

@ -26,7 +26,6 @@ void PwmConfig::baseConstructor() {
memset(&scheduling, 0, sizeof(scheduling));
memset(&safe, 0, sizeof(safe));
dbgNestingLevel = 0;
scheduling.name = "PwmConfig";
periodNt = NAN;
memset(&outputPins, 0, sizeof(outputPins));
phaseCount = 0;

View File

@ -23,8 +23,7 @@ public:
schfunc_t callback;
void *param;
scheduling_s *next;
const char *name;
// bool_t isScheduled;
bool_t isScheduled;
};
void scheduleTask(const char *prefix, scheduling_s *scheduling, int delayUs, schfunc_t callback, void *param);

View File

@ -236,8 +236,8 @@ float getCrankshaftAngleNt(uint64_t timeNt DECLARE_ENGINE_PARAMETER_S) {
void initRpmCalculator(Engine *engine) {
#if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__)
tdcScheduler[0].name = "tdc0";
tdcScheduler[1].name = "tdc1";
// tdcScheduler[0].name = "tdc0";
// tdcScheduler[1].name = "tdc1";
addTriggerEventListener(tdcMarkCallback, "chart TDC mark", engine);
#endif

View File

@ -68,10 +68,14 @@ void StepperMotor::setTargetPosition(int targetPosition) {
}
void StepperMotor::pulse() {
palWritePad(enablePort, enablePin, false); // ebable stepper
palWritePad(stepPort, stepPin, true);
chThdSleepMilliseconds(ST_DELAY_MS);
palWritePad(stepPort, stepPin, false);
chThdSleepMilliseconds(ST_DELAY_MS);
palWritePad(enablePort, enablePin, true); // disable stepper
}
void StepperMotor::initialize(brain_pin_e stepPin, brain_pin_e directionPin, float reactionTime, int totalSteps,
@ -88,9 +92,13 @@ void StepperMotor::initialize(brain_pin_e stepPin, brain_pin_e directionPin, flo
directionPort = getHwPort(directionPin);
this->directionPin = getHwPin(directionPin);
enablePort = getHwPort(enablePin);
this->enablePin = getHwPin(enablePin);
mySetPadMode2("stepper step", stepPin, PAL_MODE_OUTPUT_PUSHPULL);
mySetPadMode2("stepper dir", directionPin, PAL_MODE_OUTPUT_PUSHPULL);
mySetPadMode2("stepper enable", enablePin, PAL_MODE_OUTPUT_PUSHPULL);
palWritePad(this->enablePort, enablePin, true); // disable stepper
chThdCreateStatic(stThreadStack, sizeof(stThreadStack), NORMALPRIO, (tfunc_t) stThread, this);
}

View File

@ -28,6 +28,9 @@ private:
GPIO_TypeDef * stepPort;
ioportmask_t stepPin;
GPIO_TypeDef * enablePort;
ioportmask_t enablePin;
THD_WORKING_AREA(stThreadStack, UTILITY_THREAD_STACK_SIZE);
};

View File

@ -2728,7 +2728,7 @@
<name>$PROJ_DIR$\..\hw_layer\mcp3208.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\hw_layer\microsecond_timer.c</name>
<name>$PROJ_DIR$\..\hw_layer\microsecond_timer.cpp</name>
</file>
<file>
<name>$PROJ_DIR$\..\hw_layer\microsecond_timer.h</name>

View File

@ -107,22 +107,24 @@ void testSignalExecutor(void) {
callbackCounter = 0;
eq.executeAll(10);
assertEqualsM("callbackCounter", 2, callbackCounter);
assertEqualsM("callbackCounter/2", 2, callbackCounter);
callbackCounter = 0;
eq.executeAll(11);
assertEquals(1, callbackCounter);
eq.clear();
assertEqualsM("callbackCounter/1#1", 1, callbackCounter);
eq.executeAll(100);
assertEquals(0, eq.size());
eq.insertTask(&s1, 12, callback, NULL);
eq.insertTask(&s2, 11, callback, NULL);
eq.insertTask(&s3, 10, callback, NULL);
callbackCounter = 0;
eq.executeAll(10);
assertEquals(1, callbackCounter);
assertEqualsM("callbackCounter/1#2", 1, callbackCounter);
callbackCounter = 0;
eq.executeAll(11);
assertEquals(1, callbackCounter);
eq.clear();
eq.executeAll(100);
assertEquals(0, eq.size());
callbackCounter = 0;
eq.insertTask(&s1, 10, callback, NULL);
@ -143,7 +145,8 @@ void testSignalExecutor(void) {
eq.executeAll(1);
assertEquals(10, eq.getNextEventTime(0));
eq.clear();
eq.executeAll(100);
assertEquals(0, eq.size());
callbackCounter = 0;
// both events are scheduled for the same time
eq.insertTask(&s1, 10, callback, NULL);