Chris Taylor / Mbed 2 deprecated RETRO-CityRally

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Beeper.h Source File

Beeper.h

00001 #include "mbed.h"
00002 
00003 #ifndef __BEEPER_H__
00004 #define __BEEPER_H__
00005 class Beeper
00006 {
00007 public:    
00008     static void beep(int freq, int duration);
00009     static void noise(int freq, int duration);
00010     
00011 private:
00012     static uint16_t lfsr_rand()
00013     {
00014         static uint16_t lfsr = 0xACE1u;
00015         lfsr = (lfsr >> 1) ^ (-(lfsr & 1u) & 0xB400u);
00016         return lfsr;
00017     }
00018     
00019 private:
00020     static DigitalOut _speaker;
00021 };
00022 #endif //__BEEPER_H__