2019-03-25 12:08:32 -07:00
|
|
|
/*
|
2019-09-03 21:27:19 -07:00
|
|
|
* @file tle8888.h
|
2019-03-25 12:08:32 -07:00
|
|
|
*
|
2019-09-03 21:27:19 -07:00
|
|
|
* Mar 25, 2019
|
2020-01-07 21:02:40 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
2019-03-25 12:08:32 -07:00
|
|
|
*/
|
|
|
|
|
2020-02-10 06:29:11 -08:00
|
|
|
#pragma once
|
2019-03-25 12:08:32 -07:00
|
|
|
|
|
|
|
#include "global.h"
|
|
|
|
|
2019-04-04 06:55:18 -07:00
|
|
|
#include <hal.h>
|
2019-04-13 07:58:52 -07:00
|
|
|
#include "efifeatures.h"
|
|
|
|
|
2020-11-01 19:19:55 -08:00
|
|
|
#define TLE8888_OUTPUTS_REGULAR 28
|
|
|
|
|
|
|
|
#define TLE8888_OUTPUT_MR (TLE8888_OUTPUTS_REGULAR + 0)
|
|
|
|
|
|
|
|
/* regular outputs + MR output */
|
|
|
|
#define TLE8888_OUTPUTS (TLE8888_OUTPUTS_REGULAR + 1)
|
2019-04-04 06:55:18 -07:00
|
|
|
/* 4 misc channels */
|
|
|
|
#define TLE8888_DIRECT_MISC 4
|
|
|
|
/* 4 IGN channels - INJ1..4 - IN1..4
|
|
|
|
* 4 INJ channels - OUT1..4 - IN5..8 */
|
|
|
|
#define TLE8888_DIRECT_OUTPUTS (4 + 4 + TLE8888_DIRECT_MISC)
|
|
|
|
|
2020-11-01 19:19:55 -08:00
|
|
|
/* Inputs */
|
|
|
|
#define TLE8888_INPUT_KEY (TLE8888_OUTPUTS + 0)
|
|
|
|
#define TLE8888_INPUT_WAKE (TLE8888_OUTPUTS + 1)
|
|
|
|
|
|
|
|
/* KEY and WAKE */
|
|
|
|
#define TLE8888_INPUTS 2
|
|
|
|
|
|
|
|
#define TLE8888_SIGNALS (TLE8888_OUTPUTS + TLE8888_INPUTS)
|
|
|
|
|
2020-02-12 14:23:22 -08:00
|
|
|
#define getRegisterFromResponse(x) (((x) >> 1) & 0x7f)
|
2020-05-06 16:20:12 -07:00
|
|
|
#define getDataFromResponse(x) (((x) >> 8) & 0xff)
|
2020-02-12 14:19:58 -08:00
|
|
|
|
2019-04-04 06:55:18 -07:00
|
|
|
|
|
|
|
/* note that spi transfer should be LSB first */
|
|
|
|
struct tle8888_config {
|
2021-02-05 18:37:33 -08:00
|
|
|
#if HAL_USE_SPI
|
2019-04-04 06:55:18 -07:00
|
|
|
SPIDriver *spi_bus;
|
2019-04-04 16:56:03 -07:00
|
|
|
SPIConfig spi_config;
|
2021-02-05 18:37:33 -08:00
|
|
|
#endif
|
2019-04-04 06:55:18 -07:00
|
|
|
/* bidirectional, check DS */
|
|
|
|
struct {
|
|
|
|
ioportid_t port;
|
|
|
|
uint_fast8_t pad;
|
|
|
|
} reset;
|
|
|
|
struct {
|
2020-10-23 09:25:30 -07:00
|
|
|
/* MCU port-pin routed to IN1..12 */
|
2019-04-04 06:55:18 -07:00
|
|
|
ioportid_t port;
|
|
|
|
uint_fast8_t pad;
|
2020-10-23 09:25:30 -07:00
|
|
|
} direct_gpio[TLE8888_DIRECT_OUTPUTS];
|
|
|
|
/* IN9..IN12 to output mapping */
|
|
|
|
struct {
|
2019-04-12 16:22:16 -07:00
|
|
|
/* ...used to drive output (starts from 1, as in DS, coders gonna hate) */
|
2021-06-10 01:11:01 -07:00
|
|
|
uint8_t output;
|
2020-10-23 09:25:30 -07:00
|
|
|
} direct_maps[TLE8888_DIRECT_MISC];
|
2020-05-08 14:47:41 -07:00
|
|
|
struct {
|
|
|
|
ioportid_t port;
|
|
|
|
uint_fast8_t pad;
|
|
|
|
} ign_en;
|
|
|
|
struct {
|
|
|
|
ioportid_t port;
|
|
|
|
uint_fast8_t pad;
|
|
|
|
} inj_en;
|
2020-04-23 13:57:37 -07:00
|
|
|
tle8888_mode_e mode;
|
2020-11-10 11:16:46 -08:00
|
|
|
/* this is workaround to enable PP mode for OUT21..OUT24
|
|
|
|
* until users won't call setPinMode */
|
|
|
|
bool stepper;
|
2019-04-04 06:55:18 -07:00
|
|
|
};
|
|
|
|
|
2019-04-13 07:58:52 -07:00
|
|
|
/**
|
|
|
|
* @return return gpio chip base
|
|
|
|
*/
|
2021-01-06 15:29:47 -08:00
|
|
|
int tle8888_add(brain_pin_e base, unsigned int index, const struct tle8888_config *cfg);
|
2020-10-23 09:25:30 -07:00
|
|
|
|
|
|
|
/* debug */
|
2021-06-10 01:11:01 -07:00
|
|
|
void tle8888_req_init();
|
|
|
|
void tle8888_dump_regs();
|
2019-04-04 06:55:18 -07:00
|
|
|
|
2019-10-31 13:06:34 -07:00
|
|
|
#if EFI_TUNER_STUDIO
|
2022-01-27 16:21:05 -08:00
|
|
|
void tle8888PostState();
|
2019-10-31 13:06:34 -07:00
|
|
|
#endif /* EFI_TUNER_STUDIO */
|