I see two problems here:
1. The frequency is unsigned int, return is signed int and should return frequency.
2. As the frequency is given in Hz, unsigned int might be a little low on 16 bit platforms.