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

Enumerations

enum  tle9104_drv_state { TLE9104_DISABLED = 0 , TLE9104_WAIT_INIT , TLE9104_READY , TLE9104_FAILED }
 

Functions

static bool parityBit (uint16_t val)
 
 SEMAPHORE_DECL (tle9104_wake, 10)
 
static THD_WORKING_AREA (tle9104_thread_1_wa, 256)
 
static THD_FUNCTION (tle9104_driver_thread, p)
 
int tle9104_add (Gpio base, int index, const tle9104_config *cfg)
 
void initAll9104 (const tle9104_config *configs)
 

Variables

static bool drv_task_ready = false
 
static Tle9104 chips [BOARD_TLE9104_COUNT]
 
static IgnVoltageGatekeeper gatekeeper
 

Enumeration Type Documentation

◆ tle9104_drv_state

Enumerator
TLE9104_DISABLED 
TLE9104_WAIT_INIT 
TLE9104_READY 
TLE9104_FAILED 

Definition at line 27 of file tle9104.cpp.

27 {
tle9104_drv_state
Definition tle9104.cpp:27
@ TLE9104_FAILED
Definition tle9104.cpp:31
@ TLE9104_WAIT_INIT
Definition tle9104.cpp:29
@ TLE9104_READY
Definition tle9104.cpp:30
@ TLE9104_DISABLED
Definition tle9104.cpp:28

Function Documentation

◆ initAll9104()

void initAll9104 ( const tle9104_config configs)

Definition at line 568 of file tle9104.cpp.

568 {
569 for (int chipIndex = 0;chipIndex < BOARD_TLE9104_COUNT;chipIndex++) {
570 int ret = tle9104_add((Gpio)(Gpio::TLE9104_0_OUT_0 + TLE9204_OUT_COUNT * chipIndex), chipIndex, &configs[chipIndex]);
571 if (ret < 0) {
572 criticalError("tle9104_add");
573 }
574 }
575}
@ TLE9104_0_OUT_0
int tle9104_add(Gpio base, int index, const tle9104_config *cfg)
Definition tle9104.cpp:554

Referenced by alphax_4kGDI_boardInitHardware(), and board_init_ext_gpios().

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

◆ parityBit()

static bool parityBit ( uint16_t  val)
static

Definition at line 110 of file tle9104.cpp.

110 {
111 // (1 + number of bits set) mod 2 = parity bit
112 int count = 1 + __builtin_popcount(val);
113
114 return count % 2;
115
116#if 0
117 while (val != 0) {
118 if (val & 0x01) {
119 count++;
120 }
121
122 val = val >> 1;
123 }
124
125 return (count % 2) == 1;
126#endif
127}
uint16_t count
Definition tunerstudio.h:1

◆ SEMAPHORE_DECL()

SEMAPHORE_DECL ( tle9104_wake  ,
10   
)

◆ THD_FUNCTION()

static THD_FUNCTION ( tle9104_driver_thread  ,
 
)
static

Definition at line 301 of file tle9104.cpp.

301 {
302 int i;
303 msg_t msg;
304
305 (void)p;
306
307 chRegSetThreadName(DRIVER_NAME);
308
309 while(1) {
310 if (!gatekeeper.haveVoltage()) {
311 chThdSleepMilliseconds(300);
312 return;
313 }
314
315 msg = chSemWaitTimeout(&tle9104_wake, TIME_MS2I(TLE9104_POLL_INTERVAL_MS));
316
317 /* should we care about msg == MSG_TIMEOUT? */
318 (void)msg;
319
320 for (i = 0; i < BOARD_TLE9104_COUNT; i++) {
321 int ret;
322 Tle9104& chip = chips[i];
323
324 if (!chip.cfg ||
325 (chip.drv_state == TLE9104_DISABLED) ||
326 (chip.drv_state == TLE9104_FAILED))
327 continue;
328
329 ret = chip.updateDiagState();
330 if (ret) {
331 /* set state to TLE6240_FAILED? */
332 }
333 ret = chip.updateStatus();
334 if (ret) {
335 /* set state to TLE6240_FAILED? */
336 }
337 }
338 }
339}
static Tle9104 chips[BOARD_TLE9104_COUNT]
Definition tle9104.cpp:104
static IgnVoltageGatekeeper gatekeeper
Definition tle9104.cpp:299
Here is the call graph for this function:

◆ THD_WORKING_AREA()

static THD_WORKING_AREA ( tle9104_thread_1_wa  ,
256   
)
static

◆ tle9104_add()

int tle9104_add ( Gpio  base,
int  index,
const tle9104_config cfg 
)

Definition at line 554 of file tle9104.cpp.

554 {
555 Tle9104& chip = chips[index];
556
557 /* already added? */
558 if (chip.cfg != nullptr) {
559 return -52;
560 }
561
562 chip.cfg = cfg;
563 chip.drv_state = TLE9104_WAIT_INIT;
564
565 return gpiochip_register(base, DRIVER_NAME, chip, 4);
566}
int gpiochip_register(brain_pin_e base, const char *name, GpioChip &gpioChip, size_t size)
Register gpiochip.
Definition core.cpp:186

Referenced by initAll9104().

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

Variable Documentation

◆ chips

Tle9104 chips[BOARD_TLE9104_COUNT]
static

Definition at line 104 of file tle9104.cpp.

Referenced by THD_FUNCTION(), and tle9104_add().

◆ drv_task_ready

bool drv_task_ready = false
static

Definition at line 25 of file tle9104.cpp.

◆ gatekeeper

IgnVoltageGatekeeper gatekeeper
static

Definition at line 299 of file tle9104.cpp.

Referenced by THD_FUNCTION().

Go to the source code of this file.