A timer in a function

Of course. I just wanted to simplify the code a little. There is absolutely no reason why xIniti could not be static as well.

#define PinLed  21

bool xBlinkOn;

void Test();

void setup() {
  Serial.begin (115200);
  pinMode(PinLed, OUTPUT | INPUT);
  xBlinkOn = digitalRead(PinLed); // or 0 or 1
}

void loop() {
  Test(millis(), &xBlinkOn);

  digitalWrite(PinLed, xBlinkOn);
}

void Test(unsigned long time , bool* xOutput){
  static unsigned long lastTimeBlink = 0;
  static bool xInit = false; 

  if (xInit == false)
  {
    lastTimeBlink = time;
    xInit = true;
  }  

  if ( time - lastTimeBlink >= 500) 
  {
    *xOutput = !*xOutput; 
    Serial.println (*xOutput);
    lastTimeBlink = time;
  }
} //Test

I'm not quite sure if this is what your question was.