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

Functions

void initSent ()
 
void SENT_ISR_Handler (uint8_t channels, uint16_t clocks, uint8_t flags)
 
void startSent ()
 
void stopSent ()
 
float getSentValue (SentInput input)
 
int getSentValues (SentInput input, uint16_t *sig0, uint16_t *sig1)
 

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 ( )

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:

◆ SENT_ISR_Handler()

void SENT_ISR_Handler ( uint8_t  channels,
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:

◆ startSent()

void startSent ( )

Definition at line 95 of file sent_hw_icu.cpp.

95 {
96 for (int i = 0; i < SENT_INPUT_COUNT; i++) {
98
99 if (!isBrainPinValid(sentPin)) {
100 continue;
101 }
102
103 ICUConfig *cfg = &icucfg[i];
104 ICUDriver *icu;
105 iomode_t pinAF;
106 uint32_t baseClock;
107
108 if (getIcuParams(sentPin, &pinAF, &icu, &cfg->channel, &baseClock) != true) {
109 /* this pin has no ICU functionality or ICU driver is not enabled for TIM on this pin */
110 criticalError("No ICU on selected SENT pin");
111 continue;
112 }
113
114 efiSetPadMode("SENT", sentPin, PAL_MODE_ALTERNATE(pinAF));
115
116 icuStart(icu, cfg);
117 icuStartCapture(icu);
118 icuEnableNotifications(icu);
119 }
120}
void efiSetPadMode(const char *msg, brain_pin_e brainPin, iomode_t mode)
static constexpr engine_configuration_s * engineConfiguration
uint32_t iomode_t
Digital I/O modes.
Definition hal_pal_lld.h:83
bool getIcuParams(brain_pin_e hwPin, iomode_t *af_ptr, ICUDriver **icu_ptr, icuchannel_t *channel_ptr, uint32_t *clock_ptr)
bool isBrainPinValid(brain_pin_e brainPin)
static ICUConfig icucfg[SENT_INPUT_COUNT]

Referenced by applyNewHardwareSettings(), and initSent().

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

◆ stopSent()

void stopSent ( )

Definition at line 122 of file sent_hw_icu.cpp.

122 {
123 for (int i = 0; i < SENT_INPUT_COUNT; i++) {
125
126 if (!isBrainPinValid(sentPin)) {
127 continue;
128 }
129
130 ICUDriver *icu;
131
132 if (getIcuParams(sentPin, NULL, &icu, NULL, NULL) != true) {
133 /* this pin has no ICU functionality or ICU driver is not enabled for TIM on this pin */
134 /* throw error? */
135 continue;
136 }
137
138 icuDisableNotifications(icu);
139 icuStopCapture(icu);
140 icuStop(icu);
141
142 efiSetPadUnused(sentPin);
143 }
144}
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.