2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* @file io_pins.h
|
2021-07-13 16:28:03 -07:00
|
|
|
* @brief this file is about general input/output utility methods, not much EFI-specifics
|
2015-07-10 06:01:56 -07:00
|
|
|
*
|
|
|
|
* @date Jan 24, 2013
|
2020-01-13 18:57:43 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
|
|
|
|
2020-02-18 05:16:19 -08:00
|
|
|
#pragma once
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2018-09-16 19:26:57 -07:00
|
|
|
#include "global.h"
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2020-11-26 21:24:41 -08:00
|
|
|
#define INITIAL_PIN_STATE -1
|
2015-07-10 06:01:56 -07:00
|
|
|
#define GPIO_NULL NULL
|
|
|
|
|
2017-04-21 10:36:51 -07:00
|
|
|
// mode >= 0 is always true since that's an unsigned
|
|
|
|
#define assertOMode(mode) { \
|
2023-04-11 17:01:34 -07:00
|
|
|
efiAssertVoid(ObdCode::CUSTOM_INVALID_MODE_SETTING, mode <= OM_OPENDRAIN_INVERTED, "invalid pin_output_mode_e"); \
|
2017-04-21 10:36:51 -07:00
|
|
|
}
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-08-14 01:58:10 -07:00
|
|
|
#define efiSetPadModeIfConfigurationChanged(msg, pin, mode) \
|
|
|
|
if (isConfigurationChanged(pin)) { \
|
2021-11-17 00:54:21 -08:00
|
|
|
efiSetPadMode(msg, engineConfiguration->pin, mode); \
|
2021-08-14 01:58:10 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#define efiSetPadUnusedIfConfigurationChanged(pin) \
|
|
|
|
if (isConfigurationChanged(pin)) { \
|
2021-11-16 01:15:29 -08:00
|
|
|
efiSetPadUnused(activeConfiguration.pin); \
|
2021-08-14 01:58:10 -07:00
|
|
|
}
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2023-08-30 20:59:40 -07:00
|
|
|
void efiSetPadMode(const char *msg, brain_pin_e pin, iomode_t mode);
|
|
|
|
void efiSetPadModeWithoutOwnershipAcquisition(const char *msg, brain_pin_e brainPin, iomode_t mode);
|
|
|
|
void efiSetPadUnused(brain_pin_e brainPin);
|
2017-04-21 13:20:06 -07:00
|
|
|
|
2021-07-14 19:37:05 -07:00
|
|
|
#if EFI_GPIO_HARDWARE
|
2023-08-30 20:59:40 -07:00
|
|
|
bool efiReadPin(brain_pin_e pin);
|
2017-05-15 02:03:40 -07:00
|
|
|
|
2023-08-30 20:59:40 -07:00
|
|
|
iomode_t getInputMode(pin_input_mode_e mode);
|
2020-12-09 21:10:58 -08:00
|
|
|
|
2017-04-21 13:20:06 -07:00
|
|
|
#endif /* EFI_GPIO_HARDWARE */
|
|
|
|
|
2021-07-13 16:28:03 -07:00
|
|
|
void writePad(const char *msg, brain_pin_e pin, int bit);
|
|
|
|
|
2020-12-09 21:10:58 -08:00
|
|
|
#if ! EFI_PROD_CODE
|
|
|
|
#define BRAIN_PIN_COUNT (1 << 8 * sizeof(brain_pin_e))
|
|
|
|
extern bool mockPinStates[BRAIN_PIN_COUNT];
|
2020-12-18 14:19:02 -08:00
|
|
|
|
|
|
|
void setMockState(brain_pin_e pin, bool state);
|
2020-12-09 21:10:58 -08:00
|
|
|
#endif
|