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

Enumerations

enum  tle8888_drv_state { TLE8888_DISABLED = 0 , TLE8888_WAIT_INIT , TLE8888_READY , TLE8888_FAILED }
 

Functions

void tle8888PostState ()
 
static brain_pin_diag_e tle8888_2b_to_diag_no_temp (unsigned int bits)
 
static brain_pin_diag_e tle8888_2b_to_diag_with_temp (unsigned int bits)
 
static THD_FUNCTION (tle8888_driver_thread, p)
 
int tle8888_add (brain_pin_e base, unsigned int index, const tle8888_config *cfg)
 TLE8888 driver add.
 
void tle8888_req_init ()
 
void tle8888_dump_regs ()
 

Variables

static Timer diagResponse
 
const uint8_t tle8888_fwd_responses [16][4]
 
static Tle8888 chips [BOARD_TLE8888_COUNT]
 
static const chartle8888_pin_names [TLE8888_SIGNALS]
 

Enumeration Type Documentation

◆ tle8888_drv_state

Enumerator
TLE8888_DISABLED 
TLE8888_WAIT_INIT 
TLE8888_READY 
TLE8888_FAILED 

Definition at line 54 of file tle8888.cpp.

54 {
tle8888_drv_state
Definition tle8888.cpp:54
@ TLE8888_WAIT_INIT
Definition tle8888.cpp:56
@ TLE8888_DISABLED
Definition tle8888.cpp:55
@ TLE8888_FAILED
Definition tle8888.cpp:58
@ TLE8888_READY
Definition tle8888.cpp:57

Function Documentation

◆ THD_FUNCTION()

static THD_FUNCTION ( tle8888_driver_thread  ,
 
)
static

Definition at line 815 of file tle8888.cpp.

815 {
816 Tle8888 *chip = reinterpret_cast<Tle8888*>(p);
817 sysinterval_t poll_interval = 0;
818
819 chRegSetThreadName(DRIVER_NAME);
820
821 while (1) {
822 int ret;
823 msg_t msg = chSemWaitTimeout(&chip->wake, poll_interval);
824
825 /* should we care about msg == MSG_TIMEOUT? */
826 (void)msg;
827
828 /* default polling interval */
829 poll_interval = TIME_MS2I(DIAG_PERIOD_MS);
830
831 if ((chip->cfg == NULL) ||
832 (chip->drv_state == TLE8888_DISABLED) ||
833 (chip->drv_state == TLE8888_FAILED))
834 continue;
835
836 bool wd_happy = chip->wd_happy;
837
838 /* update outputs only if WD is happy */
839 if ((wd_happy) || (1)) {
840 ret = chip->update_output();
841 if (ret) {
842 /* set state to TLE8888_FAILED? */
843 }
844 }
845
846 ret = chip->wd_feed();
847 if (ret < 0) {
848 /* WD is not happy */
849 continue;
850 }
851 /* happiness state has changed! */
852 if ((chip->wd_happy != wd_happy) && (chip->wd_happy)) {
853 chip->need_init = true;
854 }
855
856 if (chip->need_init) {
857 /* clear first, as flag can be raised again during init */
858 chip->need_init = false;
859 /* re-init chip! */
860 chip->chip_init();
861 /* sync pins state */
862 chip->update_output();
863 }
864
865 if (chip->diag_ts <= chVTGetSystemTimeX()) {
866 /* this is expensive call, will do a lot of spi transfers... */
867 ret = chip->update_status_and_diag();
868 if (ret) {
869 /* set state to TLE8888_FAILED or force reinit? */
870 } else {
871 diagResponse.reset();
872 }
873 /* TODO:
874 * Procedure to switch on after failure condition occurred:
875 * - Read out of diagnosis bits
876 * - Second read out to verify that the failure conditions are not
877 * remaining
878 * - Set of the dedicated output enable bit of the affected channel
879 * if the diagnosis bit is not active anymore
880 * - Switch on of the channel */
881
882 chip->diag_ts = chTimeAddX(chVTGetSystemTimeX(), TIME_MS2I(DIAG_PERIOD_MS));
883 }
884
885 poll_interval = chip->calc_sleep_interval();
886 }
887}
static Timer diagResponse
Definition tle8888.cpp:42

◆ tle8888_2b_to_diag_no_temp()

static brain_pin_diag_e tle8888_2b_to_diag_no_temp ( unsigned int  bits)
static

Definition at line 596 of file tle8888.cpp.

597{
598 if (bits == 0x01)
599 return PIN_SHORT_TO_BAT;
600 if (bits == 0x02)
601 return PIN_OPEN;
602 if (bits == 0x03)
603 return PIN_SHORT_TO_GND;
604 return PIN_OK;
605}

Referenced by tle8888_2b_to_diag_with_temp().

Here is the caller graph for this function:

◆ tle8888_2b_to_diag_with_temp()

static brain_pin_diag_e tle8888_2b_to_diag_with_temp ( unsigned int  bits)
static

Definition at line 607 of file tle8888.cpp.

608{
609 int diag = tle8888_2b_to_diag_no_temp(bits);
610
611 if (diag == PIN_SHORT_TO_BAT)
612 diag |= PIN_DRIVER_OVERTEMP;
613
614 return static_cast<brain_pin_diag_e>(diag);
615}
brain_pin_diag_e
static brain_pin_diag_e tle8888_2b_to_diag_no_temp(unsigned int bits)
Definition tle8888.cpp:596
Here is the call graph for this function:

◆ tle8888_add()

int tle8888_add ( brain_pin_e  base,
unsigned int  index,
const tle8888_config cfg 
)

TLE8888 driver add.

Checks for valid config

Returns
return gpio chip base

Definition at line 1228 of file tle8888.cpp.

1228 {
1229
1230 efiAssert(ObdCode::OBD_PCM_Processor_Fault, cfg != NULL, "8888CFG", 0)
1231
1232 /* no config or no such chip */
1233 if ((!cfg) || (!cfg->spi_bus) || (index >= BOARD_TLE8888_COUNT))
1234 return -1;
1235
1236 /* check for valid chip select.
1237 * TODO: remove this check? CS can be driven by SPI */
1238 if (cfg->spi_config.ssport == NULL)
1239 return -1;
1240
1241 Tle8888* chip = &chips[index];
1242
1243 /* already initted? */
1244 if (chip->cfg)
1245 return -1;
1246
1247 chip->cfg = cfg;
1248 chip->o_state = 0;
1249 chip->o_direct_mask = 0;
1250 chip->o_data_cached = 0;
1251 chip->drv_state = TLE8888_WAIT_INIT;
1252
1253 /* register */
1254 int ret = gpiochip_register(base, DRIVER_NAME, *chip, TLE8888_OUTPUTS);
1255 if (ret < 0)
1256 return ret;
1257
1258 /* set default pin names, board init code can rewrite */
1260
1261 return ret;
1262}
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
@ OBD_PCM_Processor_Fault
static const char * tle8888_pin_names[TLE8888_SIGNALS]
Definition tle8888.cpp:266
static Tle8888 chips[BOARD_TLE8888_COUNT]
Definition tle8888.cpp:264

Referenced by initSmartGpio().

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

◆ tle8888_dump_regs()

void tle8888_dump_regs ( )

Definition at line 1279 of file tle8888.cpp.

1279 {
1280 auto& chip = chips[0];
1281
1282 // since responses are always in the NEXT transmission we will have this one first
1283 chip.read_reg(0, NULL);
1284
1285 efiPrintf("register: data");
1286 for (int request = 0; request <= 0x7e + 1; request++) {
1287 uint16_t tmp;
1288 chip.read_reg(request < (0x7e + 1) ? request : 0x7e, &tmp);
1289 uint8_t reg = getRegisterFromResponse(tmp);
1290 uint8_t data = getDataFromResponse(tmp);
1291
1292 efiPrintf("%02x: %02x", reg, data);
1293 }
1294}

Referenced by initPinRepository().

Here is the caller graph for this function:

◆ tle8888_req_init()

void tle8888_req_init ( )

Definition at line 1272 of file tle8888.cpp.

1272 {
1273 auto& tle = chips[0];
1274
1275 tle.need_init = true;
1276 tle.init_req_cnt++;
1277}

Referenced by handleCommandX14(), initPinRepository(), and tle8888startup().

Here is the caller graph for this function:

◆ tle8888PostState()

void tle8888PostState ( )

Definition at line 279 of file tle8888.cpp.

279 {
280 Tle8888 *chip = &chips[0];
281
282 engine->outputChannels.debugIntField1 = chip->wwd_err_cnt;
283 engine->outputChannels.debugIntField2 = chip->fwd_err_cnt;
284 engine->outputChannels.debugIntField3 = chip->tot_err_cnt;
285 //engine->outputChannels.debugIntField1 = chip->spi_cnt;
286 //engine->outputChannels.debugIntField2 = chip->tx;
287 //engine->outputChannels.debugIntField3 = chip->rx;
288 engine->outputChannels.debugIntField5 = chip->init_cnt;
289
290 engine->outputChannels.debugFloatField3 = chip->OpStat[1];
291 engine->outputChannels.debugFloatField4 = chip->por_cnt * 1000000 + chip->init_req_cnt * 10000;
294}
TunerStudioOutputChannels outputChannels
Definition engine.h:109
static EngineAccessor engine
Definition engine.h:413

Variable Documentation

◆ chips

Tle8888 chips[BOARD_TLE8888_COUNT]
static

Definition at line 264 of file tle8888.cpp.

Referenced by tle8888_add(), tle8888_dump_regs(), tle8888_req_init(), and tle8888PostState().

◆ diagResponse

Timer diagResponse
static

Definition at line 42 of file tle8888.cpp.

Referenced by THD_FUNCTION(), and THD_FUNCTION().

◆ tle8888_fwd_responses

const uint8_t tle8888_fwd_responses[16][4]
Initial value:
= {
{0xFF, 0x0F, 0xF0, 0x00},
{0xB0, 0x40, 0xBF, 0x4F},
{0xE9, 0x19, 0xE6, 0x16},
{0xA6, 0x56, 0xA9, 0x59},
{0x75, 0x85, 0x7A, 0x8A},
{0x3A, 0xCA, 0x35, 0xC5},
{0x63, 0x93, 0x6C, 0x9C},
{0x2C, 0xDC, 0x23, 0xD3},
{0xD2, 0x22, 0xDD, 0x2D},
{0x9D, 0x6D, 0x92, 0x62},
{0xC4, 0x34, 0xCB, 0x3B},
{0x8B, 0x7B, 0x84, 0x74},
{0x58, 0xA8, 0x57, 0xA7},
{0x17, 0xE7, 0x18, 0xE8},
{0x4E, 0xBE, 0x41, 0xB1},
{0x01, 0xF1, 0x0E, 0xFE}
}

Definition at line 138 of file tle8888.cpp.

138 {
139 /* Reverse order:
140 * RESP3,RESP2,RESP1,RESP0 */
141 {0xFF, 0x0F, 0xF0, 0x00},
142 {0xB0, 0x40, 0xBF, 0x4F},
143 {0xE9, 0x19, 0xE6, 0x16},
144 {0xA6, 0x56, 0xA9, 0x59},
145 {0x75, 0x85, 0x7A, 0x8A},
146 {0x3A, 0xCA, 0x35, 0xC5},
147 {0x63, 0x93, 0x6C, 0x9C},
148 {0x2C, 0xDC, 0x23, 0xD3},
149 {0xD2, 0x22, 0xDD, 0x2D},
150 {0x9D, 0x6D, 0x92, 0x62},
151 {0xC4, 0x34, 0xCB, 0x3B},
152 {0x8B, 0x7B, 0x84, 0x74},
153 {0x58, 0xA8, 0x57, 0xA7},
154 {0x17, 0xE7, 0x18, 0xE8},
155 {0x4E, 0xBE, 0x41, 0xB1},
156 {0x01, 0xF1, 0x0E, 0xFE}
157};

◆ tle8888_pin_names

const char* tle8888_pin_names[TLE8888_SIGNALS]
static
Initial value:
= {
"TLE8888.INJ1", "TLE8888.INJ2", "TLE8888.INJ3", "TLE8888.INJ4",
"TLE8888.OUT5", "TLE8888.OUT6", "TLE8888.OUT7", "TLE8888.OUT8",
"TLE8888.OUT9", "TLE8888.OUT10", "TLE8888.OUT11", "TLE8888.OUT12",
"TLE8888.OUT13", "TLE8888.OUT14", "TLE8888.OUT15", "TLE8888.OUT16",
"TLE8888.OUT17", "TLE8888.OUT18", "TLE8888.OUT19", "TLE8888.OUT20",
"TLE8888.OUT21", "TLE8888.OUT22", "TLE8888.OUT23", "TLE8888.OUT24",
"TLE8888.IGN1", "TLE8888.IGN2", "TLE8888.IGN3", "TLE8888.IGN4",
"TLE8888.MR", "TLE8888.KEY", "TLE8888.WAKE"
}

Definition at line 266 of file tle8888.cpp.

266 {
267 "TLE8888.INJ1", "TLE8888.INJ2", "TLE8888.INJ3", "TLE8888.INJ4",
268 "TLE8888.OUT5", "TLE8888.OUT6", "TLE8888.OUT7", "TLE8888.OUT8",
269 "TLE8888.OUT9", "TLE8888.OUT10", "TLE8888.OUT11", "TLE8888.OUT12",
270 "TLE8888.OUT13", "TLE8888.OUT14", "TLE8888.OUT15", "TLE8888.OUT16",
271 "TLE8888.OUT17", "TLE8888.OUT18", "TLE8888.OUT19", "TLE8888.OUT20",
272 "TLE8888.OUT21", "TLE8888.OUT22", "TLE8888.OUT23", "TLE8888.OUT24",
273 "TLE8888.IGN1", "TLE8888.IGN2", "TLE8888.IGN3", "TLE8888.IGN4",
274 "TLE8888.MR", "TLE8888.KEY", "TLE8888.WAKE"
275};

Referenced by tle8888_add().

Go to the source code of this file.