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

Enumerations

enum  tle6240_drv_state { TLE6240_DISABLED = 0 , TLE6240_WAIT_INIT , TLE6240_READY , TLE6240_FAILED }
 

Functions

 SEMAPHORE_DECL (tle6240_wake, 10)
 
static THD_WORKING_AREA (tle6240_thread_1_wa, 256)
 
static int tle6240_wake_driver ()
 TLE6240 chip driver wakeup.
 
static THD_FUNCTION (tle6240_driver_thread, p)
 
int tle6240_add (brain_pin_e base, unsigned int index, const tle6240_config *cfg)
 TLE6240 driver add.
 

Variables

static bool drv_task_ready = false
 
static Tle6240 chips [BOARD_TLE6240_COUNT]
 
static const chartle6240_pin_names [TLE6240_OUTPUTS]
 

Enumeration Type Documentation

◆ tle6240_drv_state

Enumerator
TLE6240_DISABLED 
TLE6240_WAIT_INIT 
TLE6240_READY 
TLE6240_FAILED 

Definition at line 51 of file tle6240.cpp.

51 {
tle6240_drv_state
Definition tle6240.cpp:51
@ TLE6240_WAIT_INIT
Definition tle6240.cpp:53
@ TLE6240_DISABLED
Definition tle6240.cpp:52
@ TLE6240_FAILED
Definition tle6240.cpp:55
@ TLE6240_READY
Definition tle6240.cpp:54

Function Documentation

◆ SEMAPHORE_DECL()

SEMAPHORE_DECL ( tle6240_wake  ,
10   
)

◆ THD_FUNCTION()

static THD_FUNCTION ( tle6240_driver_thread  ,
 
)
static

Definition at line 332 of file tle6240.cpp.

333{
334 int i;
335 msg_t msg;
336
337 (void)p;
338
339 chRegSetThreadName(DRIVER_NAME);
340
341 while(1) {
342 msg = chSemWaitTimeout(&tle6240_wake, TIME_MS2I(TLE6240_POLL_INTERVAL_MS));
343
344 /* should we care about msg == MSG_TIMEOUT? */
345 (void)msg;
346
347 for (i = 0; i < BOARD_TLE6240_COUNT; i++) {
348 int ret;
349 Tle6240& chip = chips[i];
350
351 if (!chip.cfg ||
352 (chip.drv_state == TLE6240_DISABLED) ||
353 (chip.drv_state == TLE6240_FAILED))
354 continue;
355
356 ret = chip.update_output_and_diag();
357 if (ret) {
358 /* set state to TLE6240_FAILED? */
359 }
360 }
361 }
362}
static Tle6240 chips[BOARD_TLE6240_COUNT]
Definition tle6240.cpp:113

◆ THD_WORKING_AREA()

static THD_WORKING_AREA ( tle6240_thread_1_wa  ,
256   
)
static

◆ tle6240_add()

int tle6240_add ( brain_pin_e  base,
unsigned int  index,
const tle6240_config cfg 
)

TLE6240 driver add.

Checks for valid config

Definition at line 450 of file tle6240.cpp.

451{
452 int i;
453 int ret;
454 Tle6240 *chip;
455
456 /* no config or no such chip */
457 if ((!cfg) || (!cfg->spi_bus) || (index >= BOARD_TLE6240_COUNT))
458 return -1;
459
460 /* check for valid cs.
461 * TODO: remove this check? CS can be driven by SPI */
462 //if (cfg->spi_config.ssport == NULL)
463 // return -1;
464
465 chip = &chips[index];
466
467 /* already initted? */
468 if (chip->cfg != NULL)
469 return -1;
470
471 chip->cfg = cfg;
472 chip->o_state = 0;
473 chip->o_state_cached = 0;
474 chip->o_direct_mask = 0;
475 chip->drv_state = TLE6240_WAIT_INIT;
476 for (i = 0; i < TLE6240_DIRECT_OUTPUTS; i++) {
477 if (cfg->direct_io[i].port != 0)
478 chip->o_direct_mask |= (1 << ((i < 4) ? i : (i + 4)));
479 }
480
481 /* register, return gpio chip base */
482 ret = gpiochip_register(base, DRIVER_NAME, *chip, TLE6240_OUTPUTS);
483 if (ret < 0)
484 return ret;
485
486 /* set default pin names, board init code can rewrite */
488
489 return ret;
490}
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
SPIDriver * spi_bus
Definition tle6240.h:23
struct tle6240_config::@39 direct_io[TLE6240_DIRECT_OUTPUTS]
ioportid_t port
Definition tle6240.h:27
static const char * tle6240_pin_names[TLE6240_OUTPUTS]
Definition tle6240.cpp:115

Referenced by initSmartGpio().

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

◆ tle6240_wake_driver()

static int tle6240_wake_driver ( )
static

TLE6240 chip driver wakeup.

Wake up driver. Will cause output register and diagnostic update.

chSemSignalI above requires rescheduling interrupt handlers have implicit rescheduling

Definition at line 311 of file tle6240.cpp.

312{
313 /* Entering a reentrant critical zone.*/
314 chibios_rt::CriticalSectionLocker csl;
315
316 chSemSignalI(&tle6240_wake);
317 if (!port_is_isr_context()) {
318 /**
319 * chSemSignalI above requires rescheduling
320 * interrupt handlers have implicit rescheduling
321 */
322 chSchRescheduleS();
323 }
324
325 return 0;
326}

Variable Documentation

◆ chips

Tle6240 chips[BOARD_TLE6240_COUNT]
static

Definition at line 113 of file tle6240.cpp.

Referenced by THD_FUNCTION(), and tle6240_add().

◆ drv_task_ready

bool drv_task_ready = false
static

Definition at line 49 of file tle6240.cpp.

◆ tle6240_pin_names

const char* tle6240_pin_names[TLE6240_OUTPUTS]
static
Initial value:
= {
"tle6240.OUT1", "tle6240.OUT2", "tle6240.OUT3", "tle6240.OUT4",
"tle6240.OUT5", "tle6240.OUT6", "tle6240.OUT7", "tle6240.OUT8",
"tle6240.OUT9", "tle6240.OUT10", "tle6240.OUT11", "tle6240.OUT12",
"tle6240.OUT13", "tle6240.OUT14", "tle6240.OUT15", "tle6240.OUT16",
}

Definition at line 115 of file tle6240.cpp.

115 {
116 "tle6240.OUT1", "tle6240.OUT2", "tle6240.OUT3", "tle6240.OUT4",
117 "tle6240.OUT5", "tle6240.OUT6", "tle6240.OUT7", "tle6240.OUT8",
118 "tle6240.OUT9", "tle6240.OUT10", "tle6240.OUT11", "tle6240.OUT12",
119 "tle6240.OUT13", "tle6240.OUT14", "tle6240.OUT15", "tle6240.OUT16",
120};

Referenced by tle6240_add().

Go to the source code of this file.