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

Enumerations

enum  tle9201_drv_state { TLE9201_DISABLED = 0 , TLE9201_READY , TLE9201_FAILED }
 

Functions

 SEMAPHORE_DECL (tle9201_wake, 10)
 
static THD_WORKING_AREA (tle9201_thread_1_wa, 256)
 
static THD_FUNCTION (tle9201_driver_thread, p)
 
int tle9201_add (unsigned int index, const tle9201_config *cfg)
 TLE9201 driver add.
 

Variables

static bool drv_task_ready = false
 
static size_t diagOkCounter = 0
 
constexpr size_t DIAG_OK = 0xF
 
static const chardiagDiaOut [16]
 
static Tle9201 chips [BOARD_TLE9201_COUNT]
 

Enumeration Type Documentation

◆ tle9201_drv_state

Enumerator
TLE9201_DISABLED 
TLE9201_READY 
TLE9201_FAILED 

Definition at line 45 of file tle9201.cpp.

45 {
tle9201_drv_state
Definition tle9201.cpp:45
@ TLE9201_DISABLED
Definition tle9201.cpp:46
@ TLE9201_FAILED
Definition tle9201.cpp:48
@ TLE9201_READY
Definition tle9201.cpp:47

Function Documentation

◆ SEMAPHORE_DECL()

SEMAPHORE_DECL ( tle9201_wake  ,
10   
)

◆ THD_FUNCTION()

static THD_FUNCTION ( tle9201_driver_thread  ,
 
)
static

Definition at line 207 of file tle9201.cpp.

207 {
208 bool wasSpiFailure = false;
209
210 (void)p;
211
212 chRegSetThreadName(DRIVER_NAME);
213
214 while (1) {
215 chThdSleepMilliseconds(TLE9201_POLL_INTERVAL_MS);
216
217static bool isInitialized = false;
218
219 if (!isIgnVoltage()) {
220 if (isInitialized) {
221 efiPrintf("Power loss? Would have to re-init TLE9201?");
222 isInitialized = false;
223 }
224 continue;
225 }
226
227
228 for (int i = 0; i < BOARD_TLE9201_COUNT; i++) {
229 auto chip = &chips[i];
230 if ((chip->cfg == NULL) ||
231 (chip->drv_state == TLE9201_DISABLED) ||
232 (chip->drv_state == TLE9201_FAILED)) {
233 continue;
234 }
235
236 uint8_t diag, rev;
237 // get diagnosis and revision bytes
238 if (!chip->get_diag_and_rev(&diag, &rev)) {
239 if (!wasSpiFailure) {
240 efiPrintf("%s ERROR: SPI failure!", chip->name);
241 wasSpiFailure = true;
242 }
243 } else {
244 wasSpiFailure = false;
245 }
246
247 chip->process_diag_and_rev(diag, rev);
248 }
249 }
250}
bool isIgnVoltage()
static Tle9201 chips[BOARD_TLE9201_COUNT]
Definition tle9201.cpp:102
Here is the call graph for this function:

◆ THD_WORKING_AREA()

static THD_WORKING_AREA ( tle9201_thread_1_wa  ,
256   
)
static

◆ tle9201_add()

int tle9201_add ( unsigned int  index,
const tle9201_config cfg 
)

TLE9201 driver add.

Checks for valid config

Definition at line 279 of file tle9201.cpp.

279 {
280 /* no config or no such chip */
281 if ((!cfg) || (!cfg->spi_bus) || (index >= BOARD_TLE9201_COUNT)) {
282 return -1;
283 }
284
285 if (index == 0) {
286 addConsoleAction("reset_9201", [](){
287 auto chip = &chips[0];
288 chip->spi_rw(TLE9201_REG_RES_DIA, nullptr);
289 efiPrintf(DRIVER_NAME "reset!");
290 });
291 }
292
293 /* check for valid cs.
294 * TODO: remove this check? CS can be driven by SPI */
295 //if (cfg->spi_config.ssport == NULL)
296 // return -1;
297
298 auto& chip = chips[index];
299
300 /* already initted? */
301 if (chip.cfg != NULL)
302 return -1;
303
304 chip.cfg = cfg;
305 chip.init(index);
306
307 return 0;
308}
void addConsoleAction(const char *token, Void callback)
Register console action without parameters.
SPIDriver * spi_bus
Definition tle9201.h:32

Referenced by hellen154hyundai_f7_boardInitHardware().

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

Variable Documentation

◆ chips

Tle9201 chips[BOARD_TLE9201_COUNT]
static

Definition at line 102 of file tle9201.cpp.

Referenced by THD_FUNCTION(), and tle9201_add().

◆ DIAG_OK

constexpr size_t DIAG_OK = 0xF
constexpr

Definition at line 60 of file tle9201.cpp.

◆ diagDiaOut

const char* diagDiaOut[16]
static
Initial value:
= { "?", "?", "?",
"VS Undervoltage",
"?",
"Short to Bat at OUT1 and OUT2",
"Short to GND at OUT1, short to Bat at OUT2",
"Short to Bat at OUT2",
"?",
"Short to Bat at OUT1, short to GND at OUT2",
"Short to GND at OUT1 and OUT2",
"Short to GND at OUT2",
DRIVER_NAME " Open Load",
"Short to Bat at OUT1",
"Short to GND at OUT1",
"No failure"
}

Definition at line 63 of file tle9201.cpp.

63 { "?", "?", "?",
64 "VS Undervoltage", // 0x3
65 "?",
66 "Short to Bat at OUT1 and OUT2", // 0x5
67 "Short to GND at OUT1, short to Bat at OUT2", // 0x6
68 "Short to Bat at OUT2", // 0x7
69 "?",
70 "Short to Bat at OUT1, short to GND at OUT2", // 0x9
71 "Short to GND at OUT1 and OUT2", // 0xA
72 "Short to GND at OUT2", // 0xB
73 DRIVER_NAME " Open Load", // 0xC
74 "Short to Bat at OUT1", // 0xD
75 "Short to GND at OUT1", // 0xE
76 "No failure" // 0xF
77};

◆ diagOkCounter

size_t diagOkCounter = 0
static

Definition at line 59 of file tle9201.cpp.

◆ drv_task_ready

bool drv_task_ready = false
static

Definition at line 43 of file tle9201.cpp.

Go to the source code of this file.