rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
tle8888.h
Go to the documentation of this file.
1/*
2 * @file tle8888.h
3 *
4 * Mar 25, 2019
5 * @author Andrey Belomutskiy, (c) 2012-2020
6 */
7
8#pragma once
9
10#include "global.h"
11
12#include <hal.h>
13#include "efifeatures.h"
14
15#define TLE8888_OUTPUTS_REGULAR 28
16
17#define TLE8888_OUTPUT_MR (TLE8888_OUTPUTS_REGULAR + 0)
18
19/* regular outputs + MR output */
20#define TLE8888_OUTPUTS (TLE8888_OUTPUTS_REGULAR + 1)
21/* 4 misc channels */
22#define TLE8888_DIRECT_MISC 4
23/* 4 IGN channels - INJ1..4 - IN1..4
24 * 4 INJ channels - OUT1..4 - IN5..8 */
25#define TLE8888_DIRECT_OUTPUTS (4 + 4 + TLE8888_DIRECT_MISC)
26
27/* Inputs */
28#define TLE8888_INPUT_KEY (TLE8888_OUTPUTS + 0)
29#define TLE8888_INPUT_WAKE (TLE8888_OUTPUTS + 1)
30
31/* KEY and WAKE */
32#define TLE8888_INPUTS 2
33
34#define TLE8888_SIGNALS (TLE8888_OUTPUTS + TLE8888_INPUTS)
35
36#define getRegisterFromResponse(x) (((x) >> 1) & 0x7f)
37#define getDataFromResponse(x) (((x) >> 8) & 0xff)
38
39
40/* note that spi transfer should be LSB first */
42#if HAL_USE_SPI
43 SPIDriver *spi_bus;
44 SPIConfig spi_config;
45#endif
46 /* bidirectional, check DS */
47 struct {
49 uint_fast8_t pad;
51 struct {
52 /* MCU port-pin routed to IN1..12 */
54 uint_fast8_t pad;
55 } direct_gpio[TLE8888_DIRECT_OUTPUTS];
56 /* IN9..IN12 to output mapping */
57 struct {
58 /* ...used to drive output (starts from 1, as in DS, coders gonna hate) */
59 uint8_t output;
60 } direct_maps[TLE8888_DIRECT_MISC];
61 struct {
63 uint_fast8_t pad;
65 struct {
67 uint_fast8_t pad;
70 /* this is workaround to enable PP mode for OUT21..OUT24
71 * until users won't call setPinMode */
72 bool stepper;
73};
74
75/**
76 * @return return gpio chip base
77 */
78int tle8888_add(brain_pin_e base, unsigned int index, const struct tle8888_config *cfg);
79
80/* debug */
81void tle8888_req_init();
83
84#if EFI_TUNER_STUDIO
85void tle8888PostState();
86#endif /* EFI_TUNER_STUDIO */
GPIO_TypeDef * ioportid_t
Port Identifier.
tle8888_mode_e
SPIConfig spi_config
Definition tle8888.h:44
uint_fast8_t pad
Definition tle8888.h:49
ioportid_t port
Definition tle8888.h:48
tle8888_mode_e mode
Definition tle8888.h:69
struct tle8888_config::@45 inj_en
struct tle8888_config::@43 direct_maps[TLE8888_DIRECT_MISC]
struct tle8888_config::@44 ign_en
uint8_t output
Definition tle8888.h:59
SPIDriver * spi_bus
Definition tle8888.h:43
struct tle8888_config::@41 reset
struct tle8888_config::@42 direct_gpio[TLE8888_DIRECT_OUTPUTS]
int tle8888_add(brain_pin_e base, unsigned int index, const struct tle8888_config *cfg)
void tle8888_dump_regs()
Definition tle8888.cpp:1279
void tle8888PostState()
Definition tle8888.cpp:279
void tle8888_req_init()
Definition tle8888.cpp:1272