The best way to do this is with a PID controller - take the difference between desired and actual speeds as the error value, let the PID control the PWM output.
Failing that a simple approach is to increase the PWM by 1 each time you sense the speed is too low, and decrease by 1 each time it is too slow, clunky but might be OK.
BTW that float rpm computation can be done faster like this:
// incercare
if (trigger != 0)
{
rpm = 60000000UL / (t1 - t0) ;
trigger = 0;
}
Floats aren't needed at all.