Skip to content

Commit

Permalink
uart: directly chprintf() to SD device
Browse files Browse the repository at this point in the history
  • Loading branch information
dron0gus committed Jan 6, 2025
1 parent bbd7a2b commit fd1c2f0
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions firmware/uart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SerialConfig cfg = {
.cr3 = 0
};

static char printBuffer[200];
BaseSequentialStream *chp = (BaseSequentialStream *) &SD1;

static THD_WORKING_AREA(waUartThread, 512);
static void UartThread(void*)
Expand All @@ -42,7 +42,7 @@ static void UartThread(void*)
int batteryVoltageMv = GetSampler(ch).GetInternalHeaterVoltage() * 1000;
int duty = GetHeaterDuty(ch) * 100;

size_t writeCount = chsnprintf(printBuffer, 200,
chprintf(chp,
"[AFR%d]: %d.%03d DC: %4d mV AC: %4d mV ESR: %5d T: %4d C Ipump: %6d uA Vheater: %5d heater: %s (%d)\tfault: %s\r\n",
ch,
lambdaIntPart, lambdaThousandths,
Expand All @@ -54,16 +54,14 @@ static void UartThread(void*)
batteryVoltageMv,
describeHeaterState(GetHeaterState(ch)), duty,
describeFault(GetCurrentFault(ch)));
chnWrite(&SD1, (const uint8_t *)printBuffer, writeCount);
}

#if (EGT_CHANNELS > 0)
for (ch = 0; ch < EGT_CHANNELS; ch++) {
size_t writeCount = chsnprintf(printBuffer, 200,
chprintf(chp,
"EGT[%d]: %d C (int %d C)\r\n",
(int)getEgtDrivers()[ch].temperature,
(int)getEgtDrivers()[ch].coldJunctionTemperature);
chnWrite(&SD1, (const uint8_t *)printBuffer, writeCount);
}
#endif /* EGT_CHANNELS > 0 */

Expand Down

0 comments on commit fd1c2f0

Please sign in to comment.