GCC Code Coverage Report


Directory: ./
File: firmware/hw_layer/drivers/gpio/gpio_ext.h
Date: 2025-10-03 00:57:22
Coverage Exec Excl Total
Lines: 0.0% 0 0 7
Functions: 0.0% 0 0 7
Branches: -% 0 0 0
Decisions: -% 0 - 0

Line Branch Decision Exec Source
1 /*
2 * @file gpio_ext.h
3 *
4 * Abstraction layer definitions for extrenal gpios
5 *
6 * @date Mar 8, 2019
7 * @author Andrey Gusakov, (c) 2019
8 */
9
10 #pragma once
11
12 #if EFI_PROD_CODE
13 #include "board.h"
14 #endif /* EFI_PROD_CODE */
15
16 #include "rusefi_enums.h"
17
18 /*==========================================================================*/
19 /* Checks */
20 /*==========================================================================*/
21
22 struct GpioChip {
23 virtual int init() = 0;
24
25 // These functions need not be implemented if not supported by the particular chip.
26 /* pin argument is pin number within gpio chip, not a global number */
27 virtual int setPadMode(size_t /*pin*/, iomode_t /*mode*/) { return -1; }
28 virtual int writePad(size_t /*pin*/, int /*value*/) { return -1; }
29 virtual int readPad(size_t /*pin*/) { return -1; }
30 virtual int setPadPWM(size_t /*pin*/, float /*frequency*/, float /*duty*/) { return -1; }
31 virtual brain_pin_diag_e getDiag(size_t /*pin*/) { return PIN_OK; }
32 virtual int deinit() { return 0; }
33 virtual void debug() { }
34
35 /* chip needs reinitialization due to some critical issue */
36 bool need_init = 0;
37 int init_cnt = 0;
38 int alive_cnt = 0;
39
40 int statusCode;
41 };
42
43 int gpiochips_getPinOffset(brain_pin_e pin);
44 const char *gpiochips_getChipName(brain_pin_e pin);
45 const char *gpiochips_getPinName(brain_pin_e pin);
46
47 /* register/unregister GPIO chip */
48 int gpiochip_register(brain_pin_e base, const char *name, GpioChip& chip, size_t size);
49
50 /* Set individual names for pins */
51 int gpiochips_setPinNames(brain_pin_e base, const char **names);
52
53 /* gpio extenders subsystem init */
54 int gpiochips_init(void);
55
56 int gpiochips_setPadMode(brain_pin_e pin, iomode_t mode);
57 int gpiochips_writePad(brain_pin_e pin, int value);
58 int gpiochips_readPad(brain_pin_e pin);
59 brain_pin_diag_e gpiochips_getDiag(brain_pin_e pin);
60
61 void gpiochips_debug();
62
63 #if EFI_PROD_CODE
64 hardware_pwm* gpiochip_tryInitPwm(const char* msg, brain_pin_e pin, float frequency, float duty);
65 #endif
66
67 /* return total number of external gpios */
68 int gpiochips_get_total_pins(void);
69