constify efi_gpio, use size_t (#4695)
This commit is contained in:
parent
d8591a1bd4
commit
0838fd5dc4
|
@ -64,27 +64,28 @@ static const char* const auxValveShortNames[] = { "a1", "a2"};
|
||||||
|
|
||||||
static RegisteredOutputPin * registeredOutputHead = nullptr;
|
static RegisteredOutputPin * registeredOutputHead = nullptr;
|
||||||
|
|
||||||
RegisteredNamedOutputPin::RegisteredNamedOutputPin(const char *name, short pinOffset,
|
RegisteredNamedOutputPin::RegisteredNamedOutputPin(const char *name, size_t pinOffset,
|
||||||
short pinModeOffset) : RegisteredOutputPin(name, pinOffset, pinModeOffset) {
|
size_t pinModeOffset) : RegisteredOutputPin(name, pinOffset, pinModeOffset) {
|
||||||
}
|
}
|
||||||
|
|
||||||
RegisteredOutputPin::RegisteredOutputPin(const char *registrationName, short pinOffset,
|
RegisteredOutputPin::RegisteredOutputPin(const char *registrationName, size_t pinOffset,
|
||||||
short pinModeOffset) {
|
size_t pinModeOffset)
|
||||||
this->registrationName = registrationName;
|
: next(registeredOutputHead)
|
||||||
this->pinOffset = pinOffset;
|
, registrationName(registrationName)
|
||||||
this->pinModeOffset = pinModeOffset;
|
, m_pinOffset(static_cast<uint16_t>(pinOffset))
|
||||||
|
, m_pinModeOffset(static_cast<uint16_t>(pinModeOffset))
|
||||||
|
{
|
||||||
// adding into head of the list is so easy and since we do not care about order that's what we shall do
|
// adding into head of the list is so easy and since we do not care about order that's what we shall do
|
||||||
this->next = registeredOutputHead;
|
|
||||||
registeredOutputHead = this;
|
registeredOutputHead = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RegisteredOutputPin::isPinConfigurationChanged() {
|
bool RegisteredOutputPin::isPinConfigurationChanged() {
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE
|
||||||
brain_pin_e curPin = *(brain_pin_e *) ((void *) (&((char*)&activeConfiguration)[pinOffset]));
|
brain_pin_e curPin = *(brain_pin_e *) ((void *) (&((char*)&activeConfiguration)[m_pinOffset]));
|
||||||
brain_pin_e newPin = *(brain_pin_e *) ((void *) (&((char*) engineConfiguration)[pinOffset]));
|
brain_pin_e newPin = *(brain_pin_e *) ((void *) (&((char*) engineConfiguration)[m_pinOffset]));
|
||||||
|
|
||||||
pin_output_mode_e curMode = *(pin_output_mode_e *) ((void *) (&((char*)&activeConfiguration)[pinModeOffset]));
|
pin_output_mode_e curMode = *(pin_output_mode_e *) ((void *) (&((char*)&activeConfiguration)[m_pinModeOffset]));
|
||||||
pin_output_mode_e newMode = *(pin_output_mode_e *) ((void *) (&((char*) engineConfiguration)[pinModeOffset]));
|
pin_output_mode_e newMode = *(pin_output_mode_e *) ((void *) (&((char*) engineConfiguration)[m_pinModeOffset]));
|
||||||
return curPin != newPin || curMode != newMode;
|
return curPin != newPin || curMode != newMode;
|
||||||
#else
|
#else
|
||||||
return true;
|
return true;
|
||||||
|
@ -92,8 +93,8 @@ bool RegisteredOutputPin::isPinConfigurationChanged() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisteredOutputPin::init() {
|
void RegisteredOutputPin::init() {
|
||||||
brain_pin_e newPin = *(brain_pin_e *) ((void *) (&((char*) engineConfiguration)[pinOffset]));
|
brain_pin_e newPin = *(brain_pin_e *) ((void *) (&((char*) engineConfiguration)[m_pinOffset]));
|
||||||
pin_output_mode_e *newMode = (pin_output_mode_e *) ((void *) (&((char*) engineConfiguration)[pinModeOffset]));
|
pin_output_mode_e *newMode = (pin_output_mode_e *) ((void *) (&((char*) engineConfiguration)[m_pinModeOffset]));
|
||||||
|
|
||||||
if (isPinConfigurationChanged()) {
|
if (isPinConfigurationChanged()) {
|
||||||
this->initPin(registrationName, newPin, newMode);
|
this->initPin(registrationName, newPin, newMode);
|
||||||
|
|
|
@ -43,20 +43,20 @@ public:
|
||||||
*/
|
*/
|
||||||
class RegisteredOutputPin : public virtual OutputPin {
|
class RegisteredOutputPin : public virtual OutputPin {
|
||||||
public:
|
public:
|
||||||
RegisteredOutputPin(const char *registrationName, short pinOffset, short pinModeOffset);
|
RegisteredOutputPin(const char *registrationName, size_t pinOffset, size_t pinModeOffset);
|
||||||
void init();
|
void init();
|
||||||
void unregister();
|
void unregister();
|
||||||
RegisteredOutputPin *next;
|
RegisteredOutputPin* const next;
|
||||||
const char *registrationName;
|
const char *registrationName;
|
||||||
private:
|
private:
|
||||||
short pinOffset;
|
const uint16_t m_pinOffset;
|
||||||
short pinModeOffset;
|
const uint16_t m_pinModeOffset;
|
||||||
bool isPinConfigurationChanged();
|
bool isPinConfigurationChanged();
|
||||||
};
|
};
|
||||||
|
|
||||||
class RegisteredNamedOutputPin : public RegisteredOutputPin, public NamedOutputPin {
|
class RegisteredNamedOutputPin : public RegisteredOutputPin, public NamedOutputPin {
|
||||||
public:
|
public:
|
||||||
RegisteredNamedOutputPin(const char *name, short pinOffset, short pinModeOffset);
|
RegisteredNamedOutputPin(const char *name, size_t pinOffset, size_t pinModeOffset);
|
||||||
};
|
};
|
||||||
|
|
||||||
class EnginePins {
|
class EnginePins {
|
||||||
|
|
Loading…
Reference in New Issue