Can an arduino perform this task (pulse counter) ?

This is my proposed interrupt handling routine.

// was - rising edge interrupt calculate period uSec
// now - rising edge interrupt will increment pulsecount if pulsecount < 41
// the first time this interrupt happens, pulsecount will be 0, so reset hw_timer 
//
void IRAM_ATTR rising() {
//static uint64_t runningData[RUNNING_SIZE] = { 0 }; 
// Array to store frequency data
//uint64_t rise = timerReadMillis(Timer1_Cfg); // Read current time in microseconds
//period = rise - riseTime; // Calculate the period between rising edges
//riseTime = rise; // Update the last rising time
//frequency = 100000 / period; // Calculate frequency in Hz
  if (pulsecount = 0) {
    void timerRestart(hw_timer_t * Timer1_Cfg);
  }
  if (pulsecount < 41) {
    pulsecount += 1;
  }
  if (pulsecount = 41) {
    period = timerReadMillis(Timer1_Cfg);
    pulsecount = 0;
  }
}

I expect pulsecount and period variables to be accessible in other parts of the sketch and not local to the IHR, not sure how to do that.

I expect that this IHR is reliably executed when the hardware detects a rising edge on the appropriate GPIO, and only executed once per rising edge. I expect that the first time the IHR is called (and periodically after that) the condition (pulsecount = 0) will be satisfied and the timer Timer1_Cfg will be set to 0.

I expect pulsecount to increment unless it’s current value is 41. I expect that if pulsecount is 40, that it will be incremented to 41, and then this will satisfy the next condition (pulsecount = 41) at which point the variable “period” will be read from the timer (Timer1_Cfg) AND THEN pulsecount will be set to 0.

Will this work as written?