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"
|
|
|
|
|
2019-04-16 06:23:24 -07:00
|
|
|
#define TLE8888_OUTPUTS 28
|
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-02-10 11:37:52 -08:00
|
|
|
// Looks like reset value is 113.6ms? 1.6ms * 0x47
|
2020-02-10 21:54:15 -08:00
|
|
|
#define Functional_Watchdog_PERIOD_MS 20
|
2020-02-10 11:37:52 -08:00
|
|
|
|
2020-02-10 08:11:00 -08:00
|
|
|
// we can change this value on TLE8888QK but we probably do not have a reason to change
|
|
|
|
#define Window_watchdog_close_window_time_ms 100.8
|
|
|
|
|
2020-02-12 14:23:22 -08:00
|
|
|
#define getRegisterFromResponse(x) (((x) >> 1) & 0x7f)
|
2020-02-12 14:19:58 -08:00
|
|
|
|
2020-02-10 08:11:00 -08:00
|
|
|
// unchangeable value for TLE8888QK
|
2020-02-10 10:24:09 -08:00
|
|
|
// unused for now
|
|
|
|
//#define Window_watchdog_open_window_time_ms 12.8
|
2020-02-10 08:11:00 -08:00
|
|
|
|
2019-04-04 06:55:18 -07:00
|
|
|
/* DOTO: add irq support */
|
2020-02-10 10:24:09 -08:00
|
|
|
#define TLE8888_POLL_INTERVAL_MS 7
|
2019-04-04 06:55:18 -07:00
|
|
|
|
|
|
|
/* note that spi transfer should be LSB first */
|
|
|
|
struct tle8888_config {
|
|
|
|
SPIDriver *spi_bus;
|
2019-04-04 16:56:03 -07:00
|
|
|
SPIConfig spi_config;
|
2019-04-04 06:55:18 -07:00
|
|
|
/* bidirectional, check DS */
|
|
|
|
struct {
|
|
|
|
ioportid_t port;
|
|
|
|
uint_fast8_t pad;
|
|
|
|
} reset;
|
|
|
|
struct {
|
2019-04-12 16:22:16 -07:00
|
|
|
/* MCU port-pin routed to IN9..12 */
|
2019-04-04 06:55:18 -07:00
|
|
|
ioportid_t port;
|
|
|
|
uint_fast8_t pad;
|
2019-04-12 16:22:16 -07:00
|
|
|
/* ...used to drive output (starts from 1, as in DS, coders gonna hate) */
|
|
|
|
int output;
|
2019-04-04 06:55:18 -07:00
|
|
|
} direct_io[TLE8888_DIRECT_MISC];
|
2019-09-03 21:27:19 -07:00
|
|
|
bool hallMode;
|
2019-04-04 06:55:18 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
2019-04-13 07:58:52 -07:00
|
|
|
/**
|
|
|
|
* @return return gpio chip base
|
|
|
|
*/
|
2019-04-04 06:55:18 -07:00
|
|
|
int tle8888_add(unsigned int index, const struct tle8888_config *cfg);
|
2019-09-05 07:30:27 -07:00
|
|
|
void requestTLE8888initialization(void);
|
2019-04-04 06:55:18 -07:00
|
|
|
|
2019-10-31 13:06:34 -07:00
|
|
|
#if EFI_TUNER_STUDIO
|
2019-12-22 05:12:45 -08:00
|
|
|
#include "tunerstudio_debug_struct.h"
|
|
|
|
void tle8888PostState(TsDebugChannels *tsDebugChannels);
|
2019-10-31 13:06:34 -07:00
|
|
|
#endif /* EFI_TUNER_STUDIO */
|
|
|
|
|
2019-04-04 06:55:18 -07:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|