auto-sync
This commit is contained in:
parent
7d3c651618
commit
bb96c2017a
|
@ -17,15 +17,6 @@ int getOutputPinValue(io_pin_e pin) {
|
|||
return getLogicPinValue(&outputs[pin]);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is used from fatal error handler so it's a macro to be sure that stack is not used
|
||||
*/
|
||||
int getElectricalValue(int logicalValue, pin_output_mode_e mode) {
|
||||
efiAssert(mode <= OM_OPENDRAIN_INVERTED, "invalid pin_output_mode_e", -1);
|
||||
|
||||
return logicalValue ? getElectricalValue1(mode) : getElectricalValue0(mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the value according to current electrical settings
|
||||
*/
|
||||
|
@ -35,10 +26,13 @@ void setOutputPinValue(io_pin_e pin, int logicValue) {
|
|||
return;
|
||||
efiAssertVoid(pinDefaultState[pin]!=NULL, "pin mode not initialized");
|
||||
pin_output_mode_e mode = *pinDefaultState[pin];
|
||||
efiAssert(mode <= OM_OPENDRAIN_INVERTED, "invalid pin_output_mode_e", -1);
|
||||
#else
|
||||
pin_output_mode_e mode = OM_DEFAULT;
|
||||
#endif
|
||||
setPinValue(&outputs[pin], getElectricalValue(logicValue, mode), logicValue);
|
||||
OutputPin *output = &outputs[pin];
|
||||
int eValue = getElectricalValue(logicValue, mode);
|
||||
setPinValue(output, eValue, logicValue);
|
||||
}
|
||||
|
||||
bool isPinAssigned(io_pin_e pin) {
|
||||
|
|
|
@ -66,13 +66,15 @@ typedef struct {
|
|||
#define turnOutputPinOn(pin) setOutputPinValue((pin), true)
|
||||
#define turnOutputPinOff(pin) setOutputPinValue((pin), false)
|
||||
|
||||
#define getElectricalValue(logicalValue, mode) \
|
||||
(logicalValue ? getElectricalValue1(mode) : getElectricalValue0(mode))
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
int getOutputPinValue(io_pin_e pin);
|
||||
int getElectricalValue(int logicalValue, pin_output_mode_e mode);
|
||||
void setOutputPinValue(io_pin_e pin, int logicValue);
|
||||
bool isPinAssigned(io_pin_e pin);
|
||||
|
||||
|
|
|
@ -23,10 +23,10 @@ static Logging logger;
|
|||
* This method controls the actual hardware pins
|
||||
*/
|
||||
void applyPinState(PwmConfig *state, int stateIndex) {
|
||||
efiAssertVoid(stateIndex < PWM_PHASE_MAX_COUNT, "invalid stateIndex");
|
||||
efiAssertVoid(state->multiWave.waveCount <= PWM_PHASE_MAX_WAVE_PER_PWM, "invalid waveCount");
|
||||
for (int waveIndex = 0; waveIndex < state->multiWave.waveCount; waveIndex++) {
|
||||
io_pin_e ioPin = state->outputPins[waveIndex];
|
||||
efiAssertVoid(stateIndex < PWM_PHASE_MAX_COUNT, "invalid stateIndex");
|
||||
int value = state->multiWave.waves[waveIndex].pinStates[stateIndex];
|
||||
setOutputPinValue(ioPin, value);
|
||||
}
|
||||
|
|
|
@ -5,16 +5,8 @@
|
|||
* @author Andrey Belomutskiy, (c) 2012-2014
|
||||
*/
|
||||
|
||||
#include "main.h"
|
||||
#if (EFI_PROD_CODE || EFI_SIMULATOR)
|
||||
#define GET_VALUE() hal_lld_get_counter_value()
|
||||
#else
|
||||
#define GET_VALUE() 0
|
||||
#endif
|
||||
|
||||
#include "efilib2.h"
|
||||
|
||||
|
||||
/**
|
||||
* The main use-case of this class is to keep track of a 64-bit global number of CPU ticks from reset.
|
||||
*
|
||||
|
@ -68,7 +60,7 @@ uint64_t Overflow64Counter::get() {
|
|||
/**
|
||||
* We need to take current counter after making a local 64 bit snapshot
|
||||
*/
|
||||
uint32_t value = GET_VALUE();
|
||||
uint32_t value = GET_TIMESTAMP();
|
||||
|
||||
if (value < localLow) {
|
||||
// new value less than previous value means there was an overflow in that 32 bit counter
|
||||
|
|
|
@ -28,4 +28,11 @@ class Overflow64Counter
|
|||
State64 state;
|
||||
};
|
||||
|
||||
#include "main.h"
|
||||
#if (EFI_PROD_CODE || EFI_SIMULATOR)
|
||||
#define GET_TIMESTAMP() hal_lld_get_counter_value()
|
||||
#else
|
||||
#define GET_TIMESTAMP() 0
|
||||
#endif
|
||||
|
||||
#endif /* EFILIB2_H_ */
|
||||
|
|
Loading…
Reference in New Issue