fome-fw/firmware/hw_layer/drivers/gpio/tle8888.h

85 lines
1.8 KiB
C
Raw Normal View History

2019-03-25 12:08:32 -07:00
/*
* @file tle8888.h
2019-03-25 12:08:32 -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"
#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
#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-05-06 16:20:12 -07:00
#define getDataFromResponse(x) (((x) >> 8) & 0xff)
2020-02-10 08:11:00 -08:00
// unchangeable value for TLE8888QK
// 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 */
#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 {
/* MCU port-pin routed to IN9..12 */
2019-04-04 06:55:18 -07:00
ioportid_t port;
uint_fast8_t pad;
/* ...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];
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;
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
#if EFI_TUNER_STUDIO
#include "tunerstudio_debug_struct.h"
void tle8888PostState(TsDebugChannels *tsDebugChannels);
#endif /* EFI_TUNER_STUDIO */
2019-04-04 06:55:18 -07:00
#ifdef __cplusplus
}
#endif /* __cplusplus */