Edge detection as an input, with timeout after no change of state?

Hi All

Is it possible to configure an input as On when it sees activity (rising and falling edges) on a pin, but then turn Off after a set amount of time i.e. 20ms?

I’m hoping to be able to check for the presence of a Square wave signal.

Many thanks