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

Enumerations

enum  l9779_drv_state { L9779_DISABLED = 0 , L9779_WAIT_INIT , L9779_READY , L9779_FAILED }
 

Functions

static THD_FUNCTION (l9779_driver_thread, p)
 
int l9779_add (brain_pin_e base, unsigned int index, const l9779_config *cfg)
 L9779 driver add.
 

Variables

static L9779 chips [BOARD_L9779_COUNT]
 
static const charl9779_pin_names [L9779_SIGNALS]
 

Enumeration Type Documentation

◆ l9779_drv_state

Enumerator
L9779_DISABLED 
L9779_WAIT_INIT 
L9779_READY 
L9779_FAILED 

Definition at line 50 of file l9779.cpp.

50 {
l9779_drv_state
Definition l9779.cpp:50
@ L9779_DISABLED
Definition l9779.cpp:51
@ L9779_READY
Definition l9779.cpp:53
@ L9779_FAILED
Definition l9779.cpp:54
@ L9779_WAIT_INIT
Definition l9779.cpp:52

Function Documentation

◆ l9779_add()

int l9779_add ( brain_pin_e  base,
unsigned int  index,
const l9779_config cfg 
)

L9779 driver add.

Checks for valid config

Returns
return gpio chip base

Definition at line 733 of file l9779.cpp.

733 {
734
735 efiAssert(ObdCode::OBD_PCM_Processor_Fault, cfg != NULL, "L9779CFG", 0)
736
737 /* no config or no such chip */
738 if ((!cfg) || (!cfg->spi_bus) || (index >= BOARD_L9779_COUNT))
739 return -1;
740
741 L9779* chip = &chips[index];
742
743 /* already initted? */
744 if (chip->cfg)
745 return -1;
746
747 /* config */
748 chip->cfg = cfg;
749 /* reset to defaults */
750 chip->drv_state = L9779_WAIT_INIT;
751
752 /* register */
753 int ret = gpiochip_register(base, DRIVER_NAME, *chip, L9779_SIGNALS);
754 if (ret < 0)
755 return ret;
756
757 /* set default pin names, board init code can rewrite */
759
760 return ret;
761}
return
int gpiochip_register(brain_pin_e base, const char *name, GpioChip &gpioChip, size_t size)
Register gpiochip.
Definition core.cpp:186
int gpiochips_setPinNames(brain_pin_e base, const char **names)
Set pins names for registered gpiochip.
Definition core.cpp:266
static const char * l9779_pin_names[L9779_SIGNALS]
Definition l9779.cpp:177
static L9779 chips[BOARD_L9779_COUNT]
Definition l9779.cpp:175
@ OBD_PCM_Processor_Fault

Referenced by board_init_ext_gpios(), and initSmartGpio().

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

◆ THD_FUNCTION()

static THD_FUNCTION ( l9779_driver_thread  ,
 
)
static

Definition at line 468 of file l9779.cpp.

468 {
469 L9779 *chip = reinterpret_cast<L9779*>(p);
470 sysinterval_t poll_interval = 0;
471
472 chRegSetThreadName(DRIVER_NAME);
473
474 while (1) {
475 int ret;
476 msg_t msg = chSemWaitTimeout(&chip->wake, poll_interval);
477
478 /* should we care about msg == MSG_TIMEOUT? */
479 (void)msg;
480
481 /* default polling interval */
482 poll_interval = TIME_MS2I(DIAG_PERIOD_MS);
483
484 if ((chip->cfg == NULL) ||
485 (chip->drv_state == L9779_DISABLED) ||
486 (chip->drv_state == L9779_FAILED))
487 continue;
488
489#if 0
490 bool wd_happy = chip->wd_happy;
491
492 /* update outputs only if WD is happy */
493 if ((wd_happy) || (1)) {
494 ret = chip->update_output();
495 if (ret) {
496 /* set state to L9779_FAILED? */
497 }
498 }
499
500 ret = chip->wd_feed();
501 if (ret < 0) {
502 /* WD is not happy */
503 continue;
504 }
505 /* happiness state has changed! */
506 if ((chip->wd_happy != wd_happy) && (chip->wd_happy)) {
507 chip->need_init = true;
508 }
509#endif
510
511 if (chip->need_init) {
512 /* clear first, as flag can be raised again during init */
513 chip->need_init = false;
514 /* re-init chip! */
515 chip->chip_init();
516 /* sync pins state */
517 chip->update_output();
518 }
519
520 /* Chip is ready to rock? */
521 if (chip->need_init == false) {
522 /* Just update outputs state */
523 ret = chip->update_output();
524 if (ret) {
525 /* set state to L9779_FAILED? */
526 }
527 }
528#if 0
529 if (chip->diag_ts <= chVTGetSystemTimeX()) {
530 /* this is expensive call, will do a lot of spi transfers... */
531 ret = chip->update_status_and_diag();
532 if (ret) {
533 /* set state to L9779_FAILED or force reinit? */
534 } else {
535 diagResponse.reset();
536 }
537 /* TODO:
538 * Procedure to switch on after failure condition occurred:
539 * - Read out of diagnosis bits
540 * - Second read out to verify that the failure conditions are not
541 * remaining
542 * - Set of the dedicated output enable bit of the affected channel
543 * if the diagnosis bit is not active anymore
544 * - Switch on of the channel */
545
546 chip->diag_ts = chTimeAddX(chVTGetSystemTimeX(), TIME_MS2I(DIAG_PERIOD_MS));
547 }
548 poll_interval = chip->calc_sleep_interval();
549#endif
550 /* default poll_interval */
551 }
552}
static Timer diagResponse
Definition tle8888.cpp:42

Variable Documentation

◆ chips

L9779 chips[BOARD_L9779_COUNT]
static

Definition at line 175 of file l9779.cpp.

Referenced by l9779_add().

◆ l9779_pin_names

const char* l9779_pin_names[L9779_SIGNALS]
static
Initial value:
= {
"L9779.IGN1", "L9779.IGN2", "L9779.IGN3", "L9779.IGN4",
"L9779.OUT1", "L9779.OUT2", "L9779.OUT3", "L9779.OUT4",
"L9779.OUT5", "L9779.OUT6", "L9779.OUT7", "L9779.OUT8",
"L9779.OUT9", "L9779.OUT10", "L9779.OUT11", "L9779.OUT12",
"L9779.OUT13", "L9779.OUT14", "L9779.OUT15", "L9779.OUT16",
"L9779.OUT17", "L9779.OUT18", "L9779.OUT19", "L9779.OUT20",
"L9779.OUTA", "L9779.OUTB", "L9779.OUTC", "L9779.OUTD",
"L9779.OUT25", "L9779.OUT26", "L9779.OUT27", "L9779.OUT28",
"L9779.MRD", "L9779.KEY"
}

Definition at line 177 of file l9779.cpp.

177 {
178 "L9779.IGN1", "L9779.IGN2", "L9779.IGN3", "L9779.IGN4",
179 "L9779.OUT1", "L9779.OUT2", "L9779.OUT3", "L9779.OUT4",
180 "L9779.OUT5", "L9779.OUT6", "L9779.OUT7", "L9779.OUT8",
181 "L9779.OUT9", "L9779.OUT10", "L9779.OUT11", "L9779.OUT12",
182 "L9779.OUT13", "L9779.OUT14", "L9779.OUT15", "L9779.OUT16",
183 "L9779.OUT17", "L9779.OUT18", "L9779.OUT19", "L9779.OUT20",
184 "L9779.OUTA", "L9779.OUTB", "L9779.OUTC", "L9779.OUTD",
185 "L9779.OUT25", "L9779.OUT26", "L9779.OUT27", "L9779.OUT28",
186 "L9779.MRD", "L9779.KEY"
187};

Referenced by l9779_add().

Go to the source code of this file.