This commit is contained in:
rusefi 2018-02-25 21:17:59 -05:00
parent 675df4bdaa
commit 316fab8800
4 changed files with 49 additions and 1 deletions

View File

@ -107,7 +107,7 @@ static bool isGpsEnabled() {
}
void initGps(void) {
if(!isGpsEnabled())
if (!isGpsEnabled())
return;

View File

@ -9,4 +9,50 @@
#include "servo.h"
#include "pin_repository.h"
#include "engine.h"
// todo: remove this hack once we have next incompatible configuration change
#define TEMP_FOR_COMPATIBILITY GPIOA_0
EXTERN_ENGINE;
THD_WORKING_AREA(seThreadStack, UTILITY_THREAD_STACK_SIZE);
OutputPin pin;
static int countServos() {
int result = 0;
for (int i = 0; i < SERVO_COUNT; i++) {
if (engineConfiguration->servoOutputPins[i] != GPIO_UNASSIGNED &&
engineConfiguration->servoOutputPins[i] != TEMP_FOR_COMPATIBILITY) {
result++;
}
}
return result;
}
static msg_t seThread(void *arg) {
(void)arg;
chRegSetThreadName("servo");
while (true) {
int count = countServos();
chThdSleepMilliseconds(19 - 2 * count);
}
return 0;
}
void initServo(void) {
brain_pin_e p = engineConfiguration->servoOutputPins[0];
if (p != TEMP_FOR_COMPATIBILITY) {
pin.initPin("servo", p);
}
chThdCreateStatic(seThreadStack, sizeof(seThreadStack), NORMALPRIO, (tfunc_t) seThread, NULL);
}

View File

@ -9,5 +9,6 @@
#include "main.h"
void initServo(void);
#endif /* HW_LAYER_SERVO_H_ */

View File

@ -1299,6 +1299,7 @@ cmd_stop_engine = "w\x00\x99\x00\x00"
field = "clutchDownPin", clutchDownPin
field = "clutchUpPin", clutchUpPin
field = "brakePedalPin", brakePedalPin
field = "servo#1", servoOutputPins1
dialog = allPins2
field = "Tachometer output Pin", tachOutputPin