auto-sync

This commit is contained in:
rusEfi 2014-10-13 13:03:07 -05:00
parent 2ce812f4a1
commit 850f72530c
9 changed files with 36 additions and 25 deletions

View File

@ -277,7 +277,7 @@ void setDefaultConfiguration(engine_configuration_s *engineConfiguration, board_
for (int i = 0; i < MAX31855_CS_COUNT; i++) {
boardConfiguration->max31855_cs[i] = GPIO_NONE;
}
for (int i = 0; i < GPIO_COUNT; i++) {
for (int i = 0; i < LE_COMMAND_COUNT; i++) {
boardConfiguration->gpioPins[i] = GPIO_NONE;
}
for (int i = 0; i < JOYSTICK_PIN_COUNT; i++) {

View File

@ -33,8 +33,6 @@ typedef struct {
#define MAX31855_CS_COUNT 8
#define GPIO_COUNT 8
#define JOYSTICK_PIN_COUNT 5
#define FUEL_RPM_COUNT 16
@ -217,12 +215,12 @@ typedef struct {
spi_device_e max31855spiDevice;
brain_pin_e gpioPins[GPIO_COUNT];
pin_output_mode_e gpioPinModes[GPIO_COUNT];
brain_pin_e gpioPins[LE_COMMAND_COUNT];
pin_output_mode_e gpioPinModes[LE_COMMAND_COUNT];
brain_pin_e joystickPins[JOYSTICK_PIN_COUNT];
int unusedbs[70];
int unusedbs[54];
le_formula_t le_formulas[LE_COMMAND_COUNT];

View File

@ -373,5 +373,14 @@ void initEngineContoller(void) {
addConsoleAction("analoginfo", printAnalogInfo);
for (int i = 0; i < LE_COMMAND_COUNT; i++) {
if (boardConfiguration->gpioPins[i] != GPIO_NONE) {
mySetPadMode2("user-defined", boardConfiguration->gpioPins[i], PAL_STM32_MODE_OUTPUT);
}
}
addConsoleActionSSP("set_user_out", (VoidCharPtrCharPtrVoidPtr) setUserOutput, &engine);
}

View File

@ -53,6 +53,8 @@ static char warningBuffer[WARNING_BUFFER_SIZE];
static MemoryStream warningStream;
/**
* OBD_PCM_Processor_Fault is the general error code for now
*
* @returns TRUE in case there are too many warnings
*/
int warning(obd_code_e code, const char *fmt, ...) {

View File

@ -132,7 +132,7 @@ void startIdleThread() {
// this is idle switch INPUT - sometimes there is a switch on the throttle pedal
// this switch is not used yet
mySetPadMode("idle switch", getHwPort(boardConfiguration->idleSwitchPin), getHwPin(boardConfiguration->idleSwitchPin), PAL_MODE_INPUT);
mySetPadMode2("idle switch", boardConfiguration->idleSwitchPin, PAL_MODE_INPUT);
addConsoleActionI("set_idle_rpm", setIdleRpmAction);
addConsoleActionI("set_idle_pwm", setIdleValvePwm);

View File

@ -156,9 +156,12 @@ void lcd_HD44780_print_string(const char* string) {
}
//getHwPin(boardConfiguration->HD44780_db7)
static void lcdInfo(void) {
scheduleMsg(&logger, "HD44780 RS=%s E=%s", hwPortname(boardConfiguration->HD44780_rs), hwPortname(boardConfiguration->HD44780_e));
scheduleMsg(&logger, "HD44780 D4=%s D5=%s", hwPortname(boardConfiguration->HD44780_db4), hwPortname(boardConfiguration->HD44780_db5));
scheduleMsg(&logger, "HD44780 D6=%s D7=%s", hwPortname(boardConfiguration->HD44780_db6), hwPortname(boardConfiguration->HD44780_db7));
scheduleMsg(&logger, "HD44780 RS=%s E=%s", hwPortname(boardConfiguration->HD44780_rs),
hwPortname(boardConfiguration->HD44780_e));
scheduleMsg(&logger, "HD44780 D4=%s D5=%s", hwPortname(boardConfiguration->HD44780_db4),
hwPortname(boardConfiguration->HD44780_db5));
scheduleMsg(&logger, "HD44780 D6=%s D7=%s", hwPortname(boardConfiguration->HD44780_db6),
hwPortname(boardConfiguration->HD44780_db7));
}
void lcd_HD44780_init(void) {
@ -175,18 +178,12 @@ void lcd_HD44780_init(void) {
if (engineConfiguration->displayMode == DM_HD44780) {
// initialize hardware lines
mySetPadMode("lcd RS", getHwPort(boardConfiguration->HD44780_rs), getHwPin(boardConfiguration->HD44780_rs),
PAL_MODE_OUTPUT_PUSHPULL);
mySetPadMode("lcd E", getHwPort(boardConfiguration->HD44780_e), getHwPin(boardConfiguration->HD44780_e),
PAL_MODE_OUTPUT_PUSHPULL);
mySetPadMode("lcd DB4", getHwPort(boardConfiguration->HD44780_db4), getHwPin(boardConfiguration->HD44780_db4),
PAL_MODE_OUTPUT_PUSHPULL);
mySetPadMode("lcd DB6", getHwPort(boardConfiguration->HD44780_db5), getHwPin(boardConfiguration->HD44780_db5),
PAL_MODE_OUTPUT_PUSHPULL);
mySetPadMode("lcd DB7", getHwPort(boardConfiguration->HD44780_db6), getHwPin(boardConfiguration->HD44780_db6),
PAL_MODE_OUTPUT_PUSHPULL);
mySetPadMode("lcd DB8", getHwPort(boardConfiguration->HD44780_db7), getHwPin(boardConfiguration->HD44780_db7),
PAL_MODE_OUTPUT_PUSHPULL);
mySetPadMode2("lcd RS", boardConfiguration->HD44780_rs, PAL_MODE_OUTPUT_PUSHPULL);
mySetPadMode2("lcd E", boardConfiguration->HD44780_e, PAL_MODE_OUTPUT_PUSHPULL);
mySetPadMode2("lcd DB4", boardConfiguration->HD44780_db4, PAL_MODE_OUTPUT_PUSHPULL);
mySetPadMode2("lcd DB6", boardConfiguration->HD44780_db5, PAL_MODE_OUTPUT_PUSHPULL);
mySetPadMode2("lcd DB7", boardConfiguration->HD44780_db6, PAL_MODE_OUTPUT_PUSHPULL);
mySetPadMode2("lcd DB8", boardConfiguration->HD44780_db7, PAL_MODE_OUTPUT_PUSHPULL);
// and zero values
palWritePad(getHwPort(boardConfiguration->HD44780_rs), getHwPin(boardConfiguration->HD44780_rs), 0);
palWritePad(getHwPort(boardConfiguration->HD44780_e), getHwPin(boardConfiguration->HD44780_e), 0);

View File

@ -114,8 +114,8 @@ void initGps(void) {
sdStart(GPS_SERIAL_DEVICE, &GPSserialConfig);
// GPS we have USART1: PB7 -> USART1_RX and PB6 -> USART1_TX
mySetPadMode("GPS tx", getHwPort(boardConfiguration->gps_tx_pin), getHwPin(boardConfiguration->gps_tx_pin), PAL_MODE_ALTERNATE(7));
mySetPadMode("GPS rx", getHwPort(boardConfiguration->gps_rx_pin), getHwPin(boardConfiguration->gps_rx_pin), PAL_MODE_ALTERNATE(7));
mySetPadMode2("GPS tx", boardConfiguration->gps_tx_pin, PAL_MODE_ALTERNATE(7));
mySetPadMode2("GPS rx", boardConfiguration->gps_rx_pin, PAL_MODE_ALTERNATE(7));
// todo: add a thread which would save location. If the GPS 5Hz - we should save the location each 200 ms
chThdCreateStatic(GPS_WORKING_AREA, sizeof(GPS_WORKING_AREA), LOWPRIO, GpsThreadEntryPoint, NULL);

View File

@ -136,6 +136,10 @@ static inline void markUsed(int index, const char *msg) {
totalPinsUsed++;
}
void mySetPadMode2(const char *msg, brain_pin_e pin, iomode_t mode) {
mySetPadMode(msg, getHwPort(pin), getHwPin(pin), mode);
}
/**
* This method would set an error condition if pin is already used
*/
@ -154,7 +158,7 @@ void mySetPadMode(const char *msg, ioportid_t port, ioportmask_t pin, iomode_t m
int index = portIndex * 16 + pin;
if (PIN_USED[index] != NULL) {
firmwareError("%s%d req by %s used by %s", portname(port), pin, msg, PIN_USED[index]);
warning(OBD_PCM_Processor_Fault, "%s%d req by %s used by %s", portname(port), pin, msg, PIN_USED[index]);
return;
}
markUsed(index, msg);

View File

@ -26,6 +26,7 @@ void initPinRepository(void);
char *hwPortname(brain_pin_e brainPin);
brain_pin_e parseBrainPin(const char *str);
void mySetPadMode(const char *msg, ioportid_t port, ioportmask_t pin, iomode_t mode);
void mySetPadMode2(const char *msg, brain_pin_e pin, iomode_t mode);
char *portname(GPIO_TypeDef* GPIOx);
// does not exactly belong here, but that works better for tests
void outputPinRegister(const char *msg, io_pin_e ioPin, GPIO_TypeDef *port, uint32_t pin);