rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Data Structures | Functions
mc33810.h File Reference

Data Structures

struct  mc33810_config
 

Functions

int mc33810_add (brain_pin_e base, unsigned int index, const mc33810_config *cfg)
 MC33810 driver add.
 
const mc33810_state_smc33810getLiveData (size_t idx)
 
void mc33810_req_init ()
 
int getMc33810maxDwellTimer (mc33810maxDwellTimer_e value)
 

Function Documentation

◆ getMc33810maxDwellTimer()

int getMc33810maxDwellTimer ( mc33810maxDwellTimer_e  value)

Definition at line 1003 of file mc33810.cpp.

1003 {
1004switch(value) {
1005case DWELL_16MS:
1006 return 16;
1007case DWELL_2MS:
1008 return 2;
1009case DWELL_32MS:
1010 return 32;
1011case DWELL_4MS:
1012 return 4;
1013case DWELL_64MS:
1014 return 64;
1015case DWELL_8MS:
1016 return 8;
1017 }
1018 return 0;
1019}

Referenced by validateConfigOnStartUpOrBurn().

Here is the caller graph for this function:

◆ mc33810_add()

int mc33810_add ( brain_pin_e  base,
unsigned int  index,
const mc33810_config cfg 
)

MC33810 driver add.

Checks for valid config

Definition at line 946 of file mc33810.cpp.

946 {
947
948 /* no config or no such chip */
949 if ((!cfg) || (!cfg->spi_bus) || (index >= BOARD_MC33810_COUNT))
950 return -16;
951
952 /* check for valid cs.
953 * TODO: remove this check? CS can be driven by SPI */
954 //if (cfg->spi_config.ssport == NULL)
955 // return -1;
956
957 Mc33810& chip = chips[index];
958
959 /* already initted? */
960 if (chip.cfg != NULL)
961 return -13;
962
963 chip.cfg = cfg;
964 chip.o_state = 0;
965 chip.o_state_cached = 0;
966 chip.o_direct_mask = 0;
967 for (int i = 0; i < MC33810_DIRECT_OUTPUTS; i++) {
968 if (cfg->direct_io[i].port != 0)
969 chip.o_direct_mask |= BIT(i);
970 }
971
972 /* GPGD mode is not supported yet, ignition mode does not support spi on/off commands
973 * so ignition signals should be directly driven */
974 if ((chip.o_direct_mask & 0xf0) != 0xf0)
975 return -4;
976
977 /* register, return gpio chip base */
978 int ret = gpiochip_register(base, DRIVER_NAME, chip, MC33810_OUTPUTS);
979 if (ret < 0)
980 return ret;
981
982 /* set default pin names, board init code can rewrite */
984
985 chip.drv_state = MC33810_WAIT_INIT;
986
987 return ret;
988}
int gpiochip_register(brain_pin_e base, const char *name, GpioChip &gpioChip, size_t size)
Register gpiochip.
Definition core.cpp:186
int gpiochips_setPinNames(brain_pin_e base, const char **names)
Set pins names for registered gpiochip.
Definition core.cpp:266
static Mc33810 chips[BOARD_MC33810_COUNT]
Definition mc33810.cpp:203
static const char * mc33810_pin_names[MC33810_OUTPUTS]
Definition mc33810.cpp:205
@ MC33810_WAIT_INIT
Definition mc33810.cpp:46
ioportid_t port
Definition mc33810.h:35
struct mc33810_config::@36 direct_io[MC33810_DIRECT_OUTPUTS]
SPIDriver * spi_bus
Definition mc33810.h:30

Referenced by board_init_ext_gpios(), f407_discovery_boardInitHardware(), and hellen154hyundai_f7_boardInitHardware().

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

◆ mc33810_req_init()

void mc33810_req_init ( )

Definition at line 993 of file mc33810.cpp.

993 {
994 size_t i;
995
996 for (i = 0; i < BOARD_MC33810_COUNT; i++) {
997 auto& chip = chips[i];
998
999 chip.need_init = true;
1000 }
1001}

Referenced by handleCommandX14().

Here is the caller graph for this function:

◆ mc33810getLiveData()

const mc33810_state_s * mc33810getLiveData ( size_t  idx)

Definition at line 1021 of file mc33810.cpp.

1021 {
1022 if (idx >= BOARD_MC33810_COUNT)
1023 return nullptr;
1024 return &chips[idx];
1025}

Referenced by getLiveData().

Here is the caller graph for this function:

Go to the source code of this file.