19#include "sent_decoder.h"
21#ifndef SENT_CHANNELS_NUM
22#define SENT_CHANNELS_NUM 4
25static sent_channel
channels[SENT_CHANNELS_NUM];
27void sent_channel::Info() {
31 efiPrintf(
"Unit time %lu timer ticks", tickPerUnit);
32 efiPrintf(
"Pause pulse detected %s", pausePulseReceived ?
"Yes" :
"No");
33 efiPrintf(
"Total pulses %lu", pulseCounter);
35 if (GetSignals(&stat, &sig0, &sig1) == 0) {
36 efiPrintf(
"Last valid fast msg Status 0x%01x Sig0 0x%03x Sig1 0x%03x", stat, sig0, sig1);
39 efiPrintf(
"Slow channels:");
41 for (
int i = 0; i < 256; i++) {
43 value = GetSlowChannelValue(i);
46 efiPrintf(
" ID %d: %d\n", i, value);
49 #if SENT_STATISTIC_COUNTERS
50 efiPrintf(
"HW overflows %lu\n", statistic.hwOverflowCnt);
52 efiPrintf(
"Pause pulses %lu\n", statistic.PauseCnt);
53 efiPrintf(
"Restarts %lu", statistic.RestartCnt);
54 efiPrintf(
"Interval errors %lu short, %lu long", statistic.ShortIntervalErr, statistic.LongIntervalErr);
55 efiPrintf(
"Total frames %lu with CRC error %lu (%f%%)", statistic.FrameCnt, statistic.CrcErrCnt, statistic.CrcErrCnt * 100.0 / statistic.FrameCnt);
56 efiPrintf(
"Total slow channel messages %lu with crc6 errors %lu (%f%%)", statistic.sc12 + statistic.sc16, statistic.scCrcErr, (statistic.sc12 + statistic.sc16) ? statistic.scCrcErr * 100.0 / (statistic.sc12 + statistic.sc16) : 0);
57 efiPrintf(
"Sync errors %lu", statistic.SyncErr);
66#define SENT_MB_SIZE (4 * SENT_CHANNELS_NUM)
75 msg_t msg = (flags << 24) | (
channel << 16) | clocks;
79 chMBPostI(&sent_mb, msg);
88 ret = chMBFetchTimeout(&sent_mb, &msg, TIME_INFINITE);
91 uint16_t tick = msg & 0xffff;
92 uint8_t n = (msg >> 16) & 0xff;
93 uint8_t flags = (msg >> 24) & 0xff;
95 if (n < SENT_CHANNELS_NUM) {
98 if (
channel.Decoder(tick, flags) > 0) {
102 channel.GetSignals(NULL, &sig0, &sig1);
106 #if SENT_STATISTIC_COUNTERS
123 for (
int i = 0; i < SENT_CHANNELS_NUM; i++) {
127 efiPrintf(
"---- SENT input %d ---- on %s", i + 1, pinName);
129 efiPrintf(
"--------------------");
136 size_t index =
static_cast<size_t>(input) -
static_cast<size_t>(
SentInput::INPUT1);
138 if (index < SENT_CHANNELS_NUM) {
142 if (
channel.GetSignals(NULL, &sig0, &sig1) == 0) {
154 size_t index =
static_cast<size_t>(input) -
static_cast<size_t>(
SentInput::INPUT1);
156 if (index < SENT_CHANNELS_NUM) {
159 return channel.GetSignals(NULL, sig0, sig1);
171 chThdCreateStatic(waSentDecoderThread,
sizeof(waSentDecoderThread), NORMALPRIO,
SentDecoderThread,
nullptr);
void addConsoleAction(const char *token, Void callback)
Register console action without parameters.
static EngineAccessor engine
static constexpr engine_configuration_s * engineConfiguration
const char * getBoardSpecificPinName(brain_pin_e brainPin)
void sentPressureDecode(SentInput sentCh)
static MAILBOX_DECL(sent_mb, sent_mb_buffer, SENT_MB_SIZE)
static void SentDecoderThread(void *)
static sent_channel channels[SENT_CHANNELS_NUM]
static THD_WORKING_AREA(waSentDecoderThread, 256)
void SENT_ISR_Handler(uint8_t channel, uint16_t clocks, uint8_t flags)
float getSentValue(SentInput input)
int getSentValues(SentInput input, uint16_t *sig0, uint16_t *sig1)
static msg_t sent_mb_buffer[SENT_MB_SIZE]
static void printSentInfo()
sent_input_pin_e sentInputPins[SENT_INPUT_COUNT]
void sentTpsDecode(SentInput sentCh)