rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions | Variables
sent.cpp File Reference

Functions

static MAILBOX_DECL (sent_mb, sent_mb_buffer, SENT_MB_SIZE)
 
static THD_WORKING_AREA (waSentDecoderThread, 256)
 
void SENT_ISR_Handler (uint8_t channel, uint16_t clocks, uint8_t flags)
 
static void SentDecoderThread (void *)
 
static void printSentInfo ()
 
float getSentValue (SentInput input)
 
int getSentValues (SentInput input, uint16_t *sig0, uint16_t *sig1)
 
void initSent (void)
 

Variables

static sent_channel channels [SENT_CHANNELS_NUM]
 
static msg_t sent_mb_buffer [SENT_MB_SIZE]
 

Function Documentation

◆ getSentValue()

float getSentValue ( SentInput  input)

Definition at line 135 of file sent.cpp.

135 {
136 size_t index = static_cast<size_t>(input) - static_cast<size_t>(SentInput::INPUT1);
137
138 if (index < SENT_CHANNELS_NUM) {
139 uint16_t sig0, sig1;
140 sent_channel &channel = channels[index];
141
142 if (channel.GetSignals(NULL, &sig0, &sig1) == 0) {
143
144 // GM sig0 + sig1 == 0xfff but Ford does not
145 /* scale to 0.0 .. 1.0 */
146 return sig0;
147 }
148 }
149
150 return NAN;
151}
uint16_t channel
Definition adc_inputs.h:104
static sent_channel channels[SENT_CHANNELS_NUM]
Definition sent.cpp:25

Referenced by configureRusefiLuaHooks(), and sentTpsDecode().

Here is the caller graph for this function:

◆ getSentValues()

int getSentValues ( SentInput  input,
uint16_t *  sig0,
uint16_t *  sig1 
)

Definition at line 153 of file sent.cpp.

153 {
154 size_t index = static_cast<size_t>(input) - static_cast<size_t>(SentInput::INPUT1);
155
156 if (index < SENT_CHANNELS_NUM) {
157 sent_channel &channel = channels[index];
158
159 return channel.GetSignals(NULL, sig0, sig1);
160 }
161
162 /* invalid channel */
163 return -1;
164}

Referenced by configureRusefiLuaHooks(), and sentPressureDecode().

Here is the caller graph for this function:

◆ initSent()

void initSent ( void  )

Definition at line 167 of file sent.cpp.

167 {
168 /* init interval mailbox */
169 chMBObjectInit(&sent_mb, sent_mb_buffer, SENT_MB_SIZE);
170
171 chThdCreateStatic(waSentDecoderThread, sizeof(waSentDecoderThread), NORMALPRIO, SentDecoderThread, nullptr);
172
173 /* Start HW layer */
174 startSent();
175
176 addConsoleAction("sentinfo", &printSentInfo);
177}
void addConsoleAction(const char *token, Void callback)
Register console action without parameters.
static void SentDecoderThread(void *)
Definition sent.cpp:83
static msg_t sent_mb_buffer[SENT_MB_SIZE]
Definition sent.cpp:68
static void printSentInfo()
Definition sent.cpp:122
void startSent()

Referenced by initHardware().

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

◆ MAILBOX_DECL()

static MAILBOX_DECL ( sent_mb  ,
sent_mb_buffer  ,
SENT_MB_SIZE   
)
static

◆ printSentInfo()

static void printSentInfo ( )
static

Definition at line 122 of file sent.cpp.

122 {
123 for (int i = 0; i < SENT_CHANNELS_NUM; i++) {
124 sent_channel &channel = channels[i];
125
127 efiPrintf("---- SENT input %d ---- on %s", i + 1, pinName);
128 channel.Info();
129 efiPrintf("--------------------");
130 }
131}
static constexpr engine_configuration_s * engineConfiguration
const char * getBoardSpecificPinName(brain_pin_e brainPin)

Referenced by initSent().

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

◆ SENT_ISR_Handler()

void SENT_ISR_Handler ( uint8_t  channel,
uint16_t  clocks,
uint8_t  flags 
)

Definition at line 73 of file sent.cpp.

73 {
74 /* encode to fit msg_t */
75 msg_t msg = (flags << 24) | (channel << 16) | clocks;
76
77 /* called from ISR */
78 chSysLockFromISR();
79 chMBPostI(&sent_mb, msg);
80 chSysUnlockFromISR();
81}

Referenced by icuperiodcb().

Here is the caller graph for this function:

◆ SentDecoderThread()

static void SentDecoderThread ( void *  )
static

Definition at line 83 of file sent.cpp.

83 {
84 while (true) {
85 msg_t ret;
86 msg_t msg;
87
88 ret = chMBFetchTimeout(&sent_mb, &msg, TIME_INFINITE);
89
90 if (ret == MSG_OK) {
91 uint16_t tick = msg & 0xffff;
92 uint8_t n = (msg >> 16) & 0xff;
93 uint8_t flags = (msg >> 24) & 0xff;
94
95 if (n < SENT_CHANNELS_NUM) {
96 sent_channel &channel = channels[n];
97
98 if (channel.Decoder(tick, flags) > 0) {
99 /* report only for first channel */
100 if (n == 0) {
101 uint16_t sig0, sig1;
102 channel.GetSignals(NULL, &sig0, &sig1);
103 engine->sent_state.value0 = sig0;
104 engine->sent_state.value1 = sig1;
105
106 #if SENT_STATISTIC_COUNTERS
107 engine->sent_state.errorRate = 100.0 * channel.statistic.getErrorRate();
108 #endif // SENT_STATISTIC_COUNTERS
109 }
110
111 SentInput input = static_cast<SentInput>((size_t)SentInput::INPUT1 + n);
112 /* Call high level decoder from here */
113 /* TODO: implemnet subscribers, like it is done for ADC */
114 sentTpsDecode(input);
115 sentPressureDecode(input);
116 }
117 }
118 }
119 }
120}
sent_state_s sent_state
Definition engine.h:348
static EngineAccessor engine
Definition engine.h:413
void sentPressureDecode(SentInput sentCh)
SentInput
void sentTpsDecode(SentInput sentCh)
Definition tps.cpp:71

Referenced by initSent().

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

◆ THD_WORKING_AREA()

static THD_WORKING_AREA ( waSentDecoderThread  ,
256   
)
static

Variable Documentation

◆ channels

sent_channel channels[SENT_CHANNELS_NUM]
static

Definition at line 25 of file sent.cpp.

Referenced by getSentValue(), getSentValues(), printSentInfo(), and SentDecoderThread().

◆ sent_mb_buffer

msg_t sent_mb_buffer[SENT_MB_SIZE]
static

Definition at line 68 of file sent.cpp.

Referenced by initSent().

Go to the source code of this file.