Direct frequency measurement with two hw timers
EDIT: Because of the low precision of the HSI - 0.1%, the clock needs to be switched to HSE. 

I'm doing all of this in cubeMX so I won't be writing out the bits, you can find them in the reference manual -http://www.st.com/web/en/resource/technical/document/reference_manual/DM00043574.pdf

After some experimenting I figured it out. For simplicity, i'll write out the whole process of setting up 2 counters to measure frequency directly.

First the main counter, lets take TIM1:


Set the clock to ETR2
Set the trigger to ITRx, you can find the correct one by consulting the TIMx internal trigger connection e.g. if you want to TIM1 to be the main counter, you can gate it with TIM15 by selecting ITR0.
Enable an input capture channel triggered by TRC, this will record the pulse count after each gate
Now the classic timer stuff - Set the Counter Period (autoreload) to max 0xffff for TIM1


And thats the main counter set up. Now for the gating timer, lets take TIM15:


Set the clock source to internal
Set an output compare no output on channel 1 (any channel will do)
Parameter settings:
In the trigger output select Compare Pulse (OC1) as trigger event
And set the appropriate prescaler, counter period and (pulse? not sure if its needed). E.g. for 1s, with 72MHz clock  I chose 7199 for the prescaler and 9999 for the counter period
The output compare mode should be in Frozen mode


Thats all the setup done. After generating the project, don't forget to start all timers, e.g.

HAL_TIM_Base_Start(&amp;htim1);
HAL_TIM_IC_Start(&amp;htim1, TIM_CHANNEL_1);
HAL_TIM_Base_Start(&amp;htim15);
HAL_TIM_OC_Start(&amp;htim15, TIM_CHANNEL_1);


And the frequency can be read out from the capture compare unit, 

frequency= __HAL_TIM_GET_COMPARE(&amp;htim1, TIM_CHANNEL_1);


This is of course assuming the gate time is 1s.