Edit digitalWrite()

good day everyone,
I'm using minicore to program ATmega8a, and I want to edit digitalWrite() source code,

which file should I edit ?

The obvious question is why do you want to edit it ?

I want to remove some checking codes for PWM and if pin is really existed, and remove the cli(); command which disable interrupts

you would be better off writing your own function than messing around with the library...

it's here I think

void digitalWrite(uint8_t pin, uint8_t val)
{
  uint8_t timer = digitalPinToTimer(pin);
  uint8_t bit = digitalPinToBitMask(pin);
  uint8_t port = digitalPinToPort(pin);
  volatile uint8_t *out;

  if (port == NOT_A_PIN) return;

  // If the pin that support PWM output, we need to turn it off
  // before doing a digital write.
  if (timer != NOT_ON_TIMER) turnOffPWM(timer);

  out = portOutputRegister(port);

  uint8_t oldSREG = SREG;
  cli();

  if (val == LOW) {
    *out &= ~bit;
  } else {
    *out |= bit;
  }

  SREG = oldSREG;
}

As @J-M-L says, just do not use digitalWrite(), do a direct port address.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.