rusefi/firmware/hw_layer/io_pins.h

50 lines
1.5 KiB
C
Raw Permalink Normal View History

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
#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) { \
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
#define efiSetPadModeIfConfigurationChanged(msg, pin, mode) \
if (isConfigurationChanged(pin)) { \
efiSetPadMode(msg, engineConfiguration->pin, mode); \
}
#define efiSetPadUnusedIfConfigurationChanged(pin) \
if (isConfigurationChanged(pin)) { \
efiSetPadUnused(activeConfiguration.pin); \
}
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);
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);
#if ! EFI_PROD_CODE
#define BRAIN_PIN_COUNT (1 << 8 * sizeof(brain_pin_e))
extern bool mockPinStates[BRAIN_PIN_COUNT];
void setMockState(brain_pin_e pin, bool state);
#endif