rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Typedefs | Functions
kline.h File Reference

Typedefs

typedef size_t(* ByteSource) (uint8_t *, int)
 

Functions

void initKLine ()
 
void startKLine ()
 
void stopKLine ()
 
size_t readWhileGives (ByteSource source, uint8_t *buffer, size_t bufferSize)
 

Typedef Documentation

◆ ByteSource

typedef size_t(* ByteSource) (uint8_t *, int)

Definition at line 23 of file kline.h.

Function Documentation

◆ initKLine()

void initKLine ( )

Definition at line 198 of file kline.cpp.

198 {
200 return;
201 }
202#ifdef EFI_KLINE
203 startKLine();
204
205 memset(kvalues, 0, sizeof(kvalues));
206 kvalues[0] = 0x2;
207
208 chThdCreateStatic(klThreadStack, sizeof(klThreadStack), NORMALPRIO + 1, kLineThread, nullptr);
209 addConsoleAction("kline", [](){
210 efiPrintf("kline totalBytes %d", totalBytes);
211 });
212 addConsoleAction("klineyes", [](){
214 efiPrintf("kline send %d", engineConfiguration->kLineDoHondaSend);
215 });
216 addConsoleAction("klineno", [](){
218 efiPrintf("kline send %d", engineConfiguration->kLineDoHondaSend);
219 });
220 addConsoleActionII("temp_k", [](int index, int value) {
221 kvalues[index] = value;
222 });
223
224#endif // EFI_KLINE
225}
void addConsoleAction(const char *token, Void callback)
Register console action without parameters.
void addConsoleActionII(const char *token, VoidIntInt callback)
Register a console command with two Integer parameters.
static constexpr engine_configuration_s * engineConfiguration
void startKLine()
Definition kline.cpp:157
void kLineThread(void *)
Definition kline.cpp:50
static int totalBytes
Definition kline.cpp:48
static uint8_t kvalues[8]
Definition kline.cpp:26

Referenced by initHardware().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readWhileGives()

size_t readWhileGives ( ByteSource  source,
uint8_t *  buffer,
size_t  bufferSize 
)

this file is mostly about SEFMJ early 2000s specific honda K-line protocol https://rusefi.com/forum/viewtopic.php?f=4&t=2514

Definition at line 11 of file kline.cpp.

11 {
12 size_t totalBytes = 0;
13 while (totalBytes < bufferSize) {
14 size_t readThisTime = source(&buffer[totalBytes], bufferSize - totalBytes);
15 if (readThisTime == 0) {
16 // looks like idle gap
17 break;
18 }
19 totalBytes += readThisTime;
20 }
21 return totalBytes;
22}
static BigBufferHandle buffer

Referenced by kLineThread().

Here is the caller graph for this function:

◆ startKLine()

void startKLine ( )

Definition at line 157 of file kline.cpp.

157 {
158#ifdef EFI_KLINE
160 return;
161 }
162#if EFI_PROD_CODE
163 efiSetPadMode("K-Line UART RX", Gpio::KLINE_SERIAL_DEVICE_RX, PAL_MODE_ALTERNATE(TS_SERIAL_AF));
164 efiSetPadMode("K-Line UART TX", Gpio::KLINE_SERIAL_DEVICE_TX, PAL_MODE_ALTERNATE(TS_SERIAL_AF));
165#endif /* EFI_PROD_CODE */
166
167 static SerialConfig cfg = {
168 #if EFI_PROD_CODE
169 .speed = 0,
170 .cr1 = 0,
171 .cr2 = USART_CR2_STOP1_BITS | USART_CR2_LINEN,
172 .cr3 = 0
173 #endif // EFI_PROD_CODE
174 };
175
177 engineConfiguration->kLineBaudRate = KLINE_BAUD_RATE;
179
180 sdStart(klDriver, &cfg);
181#endif // EFI_KLINE
182}
void efiSetPadMode(const char *msg, brain_pin_e brainPin, iomode_t mode)
static SerialDriver *const klDriver
Definition kline.cpp:45

Referenced by applyNewHardwareSettings(), and initKLine().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stopKLine()

void stopKLine ( )

Definition at line 184 of file kline.cpp.

184 {
185#ifdef EFI_KLINE
186#if EFI_PROD_CODE
188 efiSetPadUnused(Gpio::KLINE_SERIAL_DEVICE_RX);
189 efiSetPadUnused(Gpio::KLINE_SERIAL_DEVICE_TX);
190
191 sdStop(klDriver);
192 }
193
194#endif /* EFI_PROD_CODE */
195#endif // EFI_KLINE
196}
engine_configuration_s & activeConfiguration
void efiSetPadUnused(brain_pin_e brainPin)
Definition io_pins.cpp:20

Referenced by applyNewHardwareSettings().

Here is the call graph for this function:
Here is the caller graph for this function:

Go to the source code of this file.