It pretty much walks you through all the code you need to use the hardware to count the amount of times the pin changes state - then you could just sample and reset that register every second using setInterval and you've got yourself a frequency measurement in Hz.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
If you want to measure the frequency of a signal that fast then you're probably best off using the hardware that's built into the STM32F4.
There's a page on how to do that here: http://www.espruino.com/STM32+Peripherals
It pretty much walks you through all the code you need to use the hardware to count the amount of times the pin changes state - then you could just sample and reset that register every second using
setInterval
and you've got yourself a frequency measurement in Hz.