rusEFI needs K-line firmware support #3248

This commit is contained in:
andreika-git 2023-02-17 09:21:09 -05:00 committed by rusefillc
parent f80e7d5513
commit ad57100098
2 changed files with 29 additions and 5 deletions

View File

@ -1,17 +1,20 @@
#include "pch.h"
#include "kline.h"
#if EFI_PROD_CODE
#ifdef EFI_KLINE
static SerialDriver* const klDriver = KLINE_SERIAL_DEVICE;
static THD_WORKING_AREA(klThreadStack, UTILITY_THREAD_STACK_SIZE);
void kLineThread(void*)
{
while(1)
{
// todo: read one by in loop
uint8_t ch = 0;
chnReadTimeout(klDriver, &ch, 1, KLINE_READ_TIMEOUT);
// to begin with just write byte to console
// efiPrintf
chThdSleepMilliseconds(50);
if (ch != 0) {
efiPrintf("kline: %c", ch);
}
}
}
#endif
@ -19,7 +22,17 @@ void kLineThread(void*)
void initKLine() {
#ifdef EFI_KLINE
static const SerialConfig cfg = {
#if EFI_PROD_CODE
.speed = KLINE_BAUD_RATE,
.cr1 = 0,
.cr2 = USART_CR2_STOP1_BITS | USART_CR2_LINEN,
.cr3 = 0
#endif // EFI_PROD_CODE
};
sdStart(klDriver, &cfg);
chThdCreateStatic(klThreadStack, sizeof(klThreadStack), NORMALPRIO + 1, kLineThread, nullptr);
// todo: conditional uart initialization matching 2003 miata k-line
#endif
}

View File

@ -1 +1,12 @@
#pragma once
#define KLINE_SERIAL_DEVICE (&SD2)
// The standard transmission rate
#define KLINE_BAUD_RATE 10400
#define KLINE_READ_TIMEOUT 50
void initKLine();