auto-sync

This commit is contained in:
rusEfi 2014-12-07 18:03:14 -06:00
parent 72af5eabcd
commit 38b2784263
6 changed files with 74 additions and 65 deletions

View File

@ -120,26 +120,6 @@ bool isSerialOverUart(void) {
return is_serial_over_uart; return is_serial_over_uart;
} }
static THD_WORKING_AREA(consoleThreadStack, 2 * UTILITY_THREAD_STACK_SIZE);
static msg_t consoleThreadThreadEntryPoint(void *arg) {
(void) arg;
chRegSetThreadName("console thread");
while (TRUE) {
efiAssert(getRemainingStack(chThdSelf()) > 256, "lowstck#9e", 0);
bool end = getConsoleLine((BaseSequentialStream*) getConsoleChannel(), consoleInput, sizeof(consoleInput));
if (end) {
// firmware simulator is the only case when this happens
continue;
}
(console_line_callback)(consoleInput);
}
#if defined __GNUC__
return false;
#endif
}
#if EFI_PROD_CODE #if EFI_PROD_CODE
static SerialConfig serialConfig = { SERIAL_SPEED, 0, USART_CR2_STOP1_BITS | USART_CR2_LINEN, 0 }; static SerialConfig serialConfig = { SERIAL_SPEED, 0, USART_CR2_STOP1_BITS | USART_CR2_LINEN, 0 };
@ -162,6 +142,35 @@ bool isConsoleReady(void) {
#endif /* EFI_PROD_CODE */ #endif /* EFI_PROD_CODE */
static THD_WORKING_AREA(consoleThreadStack, 2 * UTILITY_THREAD_STACK_SIZE);
static msg_t consoleThreadThreadEntryPoint(void *arg) {
(void) arg;
chRegSetThreadName("console thread");
#if EFI_PROD_CODE
if (!isSerialOverUart()) {
/**
* This method contains a long delay, that's the reason why this is not done on the main thread
*/
usb_serial_start();
}
#endif /* EFI_PROD_CODE */
while (true) {
efiAssert(getRemainingStack(chThdSelf()) > 256, "lowstck#9e", 0);
bool end = getConsoleLine((BaseSequentialStream*) getConsoleChannel(), consoleInput, sizeof(consoleInput));
if (end) {
// firmware simulator is the only case when this happens
continue;
}
(console_line_callback)(consoleInput);
}
#if defined __GNUC__
return false;
#endif
}
void consolePutChar(int x) { void consolePutChar(int x) {
chSequentialStreamPut(getConsoleChannel(), (uint8_t )(x)); chSequentialStreamPut(getConsoleChannel(), (uint8_t )(x));
} }
@ -198,18 +207,15 @@ void startConsole(void (*console_line_callback_p)(char *)) {
palSetPadMode(EFI_CONSOLE_RX_PORT, EFI_CONSOLE_RX_PIN, PAL_MODE_ALTERNATE(EFI_CONSOLE_AF)); palSetPadMode(EFI_CONSOLE_RX_PORT, EFI_CONSOLE_RX_PIN, PAL_MODE_ALTERNATE(EFI_CONSOLE_AF));
palSetPadMode(EFI_CONSOLE_TX_PORT, EFI_CONSOLE_TX_PIN, PAL_MODE_ALTERNATE(EFI_CONSOLE_AF)); palSetPadMode(EFI_CONSOLE_TX_PORT, EFI_CONSOLE_TX_PIN, PAL_MODE_ALTERNATE(EFI_CONSOLE_AF));
isSerialConsoleStarted = TRUE; isSerialConsoleStarted = true;
chEvtRegisterMask((EventSource *) chnGetEventSource(EFI_CONSOLE_UART_DEVICE), &consoleEventListener, 1); chEvtRegisterMask((EventSource *) chnGetEventSource(EFI_CONSOLE_UART_DEVICE), &consoleEventListener, 1);
} else {
usb_serial_start();
} }
#endif /* EFI_PROD_CODE */ #endif /* EFI_PROD_CODE */
chThdCreateStatic(consoleThreadStack, sizeof(consoleThreadStack), NORMALPRIO, consoleThreadThreadEntryPoint, NULL); chThdCreateStatic(consoleThreadStack, sizeof(consoleThreadStack), NORMALPRIO, consoleThreadThreadEntryPoint, NULL);
} }
extern cnt_t dbg_isr_cnt;
/** /**
* @return TRUE if already in locked context * @return TRUE if already in locked context
*/ */

View File

@ -345,6 +345,23 @@ static THD_WORKING_AREA(lcdThreadStack, UTILITY_THREAD_STACK_SIZE);
*/ */
static THD_WORKING_AREA(comBlinkingStack, UTILITY_THREAD_STACK_SIZE); static THD_WORKING_AREA(comBlinkingStack, UTILITY_THREAD_STACK_SIZE);
static io_pin_e leds[] = { LED_WARNING, LED_RUNNING, LED_ERROR, LED_COMMUNICATION_1, LED_DEBUG, LED_EXT_1,
LED_CHECK_ENGINE };
/**
* This method would blink all the LEDs just to test them
*/
static void initialLedsBlink(void) {
int size = sizeof(leds) / sizeof(leds[0]);
for (int i = 0; i < size; i++)
setOutputPinValue(leds[i], 1);
chThdSleepMilliseconds(100);
for (int i = 0; i < size; i++)
setOutputPinValue(leds[i], 0);
}
/** /**
* error thread to show error condition (blinking LED means non-fatal error) * error thread to show error condition (blinking LED means non-fatal error)
*/ */
@ -354,7 +371,10 @@ static THD_WORKING_AREA(errBlinkingStack, UTILITY_THREAD_STACK_SIZE);
static void comBlinkingThread(void *arg) { static void comBlinkingThread(void *arg) {
(void) arg; (void) arg;
chRegSetThreadName("communication blinking"); chRegSetThreadName("communication blinking");
while (TRUE) {
initialLedsBlink();
while (true) {
int delay; int delay;
if (getNeedToWriteConfiguration()) { if (getNeedToWriteConfiguration()) {

View File

@ -372,13 +372,29 @@ static uint8_t secondByte;
static uint8_t crcIoBuffer[300]; static uint8_t crcIoBuffer[300];
static msg_t tsThreadEntryPoint(void *arg) { static msg_t tsThreadEntryPoint(void *arg) {
(void) arg; (void) arg;
chRegSetThreadName("tunerstudio thread"); chRegSetThreadName("tunerstudio thread");
#if EFI_PROD_CODE
if (isSerialOverUart()) {
print("TunerStudio over USB serial");
/**
* This method contains a long delay, that's the reason why this is not done on the main thread
*/
usb_serial_start();
} else {
print("TunerStudio over USART");
mySetPadMode("tunerstudio rx", TS_SERIAL_RX_PORT, TS_SERIAL_RX_PIN, PAL_MODE_ALTERNATE(TS_SERIAL_AF));
mySetPadMode("tunerstudio tx", TS_SERIAL_TX_PORT, TS_SERIAL_TX_PIN, PAL_MODE_ALTERNATE(TS_SERIAL_AF));
tsSerialConfig.speed = boardConfiguration->tunerStudioSerialSpeed;
sdStart(TS_SERIAL_UART_DEVICE, &tsSerialConfig);
}
#endif /* EFI_PROD_CODE */
int wasReady = false; int wasReady = false;
while (true) { while (true) {
int isReady = ts_serial_ready(); int isReady = ts_serial_ready();
@ -506,21 +522,6 @@ void startTunerStudioConnectivity(void) {
firmwareError("TS outputs size mismatch: %d/%d", sizeof(TunerStudioOutputChannels), TS_OUTPUT_SIZE); firmwareError("TS outputs size mismatch: %d/%d", sizeof(TunerStudioOutputChannels), TS_OUTPUT_SIZE);
memset(&tsState, 0, sizeof(tsState)); memset(&tsState, 0, sizeof(tsState));
#if EFI_PROD_CODE
if (isSerialOverUart()) {
print("TunerStudio over USB serial");
usb_serial_start();
} else {
print("TunerStudio over USART");
mySetPadMode("tunerstudio rx", TS_SERIAL_RX_PORT, TS_SERIAL_RX_PIN, PAL_MODE_ALTERNATE(TS_SERIAL_AF));
mySetPadMode("tunerstudio tx", TS_SERIAL_TX_PORT, TS_SERIAL_TX_PIN, PAL_MODE_ALTERNATE(TS_SERIAL_AF));
tsSerialConfig.speed = boardConfiguration->tunerStudioSerialSpeed;
sdStart(TS_SERIAL_UART_DEVICE, &tsSerialConfig);
}
#endif /* EFI_PROD_CODE */
syncTunerStudioCopy(); syncTunerStudioCopy();
addConsoleAction("tsinfo", printStats); addConsoleAction("tsinfo", printStats);

View File

@ -27,8 +27,6 @@ static Logging logger;
extern pin_output_mode_e *pinDefaultState[IO_PIN_COUNT]; extern pin_output_mode_e *pinDefaultState[IO_PIN_COUNT];
extern OutputPin outputs[IO_PIN_COUNT]; extern OutputPin outputs[IO_PIN_COUNT];
static io_pin_e leds[] = { LED_WARNING, LED_RUNNING, LED_ERROR, LED_COMMUNICATION_1, LED_DEBUG, LED_EXT_1,
LED_CHECK_ENGINE };
static GPIO_TypeDef *PORTS[] = { GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH }; static GPIO_TypeDef *PORTS[] = { GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH };
@ -96,20 +94,6 @@ void outputPinRegister(const char *msg, io_pin_e ioPin, GPIO_TypeDef *port, uint
outputPinRegisterExt(msg, ioPin, port, pin, &DEFAULT_OUTPUT); outputPinRegisterExt(msg, ioPin, port, pin, &DEFAULT_OUTPUT);
} }
/**
* This method would blink all the LEDs just to test them
*/
static void initialLedsBlink(void) {
int size = sizeof(leds) / sizeof(leds[0]);
for (int i = 0; i < size; i++)
setOutputPinValue(leds[i], 1);
chThdSleepMilliseconds(100);
for (int i = 0; i < size; i++)
setOutputPinValue(leds[i], 0);
}
void initPrimaryPins(void) { void initPrimaryPins(void) {
outputPinRegister("LED_ERROR", LED_ERROR, LED_ERROR_PORT, LED_ERROR_PIN); outputPinRegister("LED_ERROR", LED_ERROR, LED_ERROR_PORT, LED_ERROR_PIN);
} }
@ -158,8 +142,6 @@ void initOutputPins(void) {
outputPinRegisterExt2("trg_err", LED_TRIGGER_ERROR, boardConfiguration->triggerErrorPin, &boardConfiguration->triggerErrorPinMode); outputPinRegisterExt2("trg_err", LED_TRIGGER_ERROR, boardConfiguration->triggerErrorPin, &boardConfiguration->triggerErrorPinMode);
outputPinRegisterExt2("A/C relay", AC_RELAY, boardConfiguration->acRelayPin, &boardConfiguration->acRelayPinMode); outputPinRegisterExt2("A/C relay", AC_RELAY, boardConfiguration->acRelayPin, &boardConfiguration->acRelayPinMode);
initialLedsBlink();
// digit 1 // digit 1
/* /*
ledRegister(LED_HUGE_0, GPIOB, 2); ledRegister(LED_HUGE_0, GPIOB, 2);

View File

@ -127,7 +127,7 @@ void initPinRepository(void) {
for (int i = 0; i < PIN_REPO_SIZE; i++) for (int i = 0; i < PIN_REPO_SIZE; i++)
PIN_USED[i] = 0; PIN_USED[i] = 0;
initialized = TRUE; initialized = true;
addConsoleAction("pins", reportPins); addConsoleAction("pins", reportPins);
} }

View File

@ -1,5 +1,5 @@
// This file was generated by Version2Header // This file was generated by Version2Header
// Sat Nov 29 23:31:29 EST 2014 // Sun Dec 07 18:26:23 EST 2014
#ifndef VCS_VERSION #ifndef VCS_VERSION
#define VCS_VERSION "5638" #define VCS_VERSION "5721"
#endif #endif