![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
A synthesizer that is controlled by a USB MIDI Keyboard. Also displays corresponding frequencies via a simple spectrum analyzer on a LCD. Uses a watchdog timer to reset Mbed in case it freezes.
Dependencies: 4DGL-uLCD-SE USBHostMIDI mbed
Fork of USBHostMIDI_example by
Diff: Watchdog.h
- Revision:
- 2:5366ce17fe55
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Watchdog.h Wed Dec 13 03:31:09 2017 +0000 @@ -0,0 +1,26 @@ +#include "mbed.h" +// LEDs used to indicate code activity and reset source +DigitalOut myled1(LED1); //in main loop part 1 +DigitalOut myled2(LED2); //in main loop part 2 (where fault occurs) +DigitalOut myled3(LED3); //The pushbutton or power on caused a reset +DigitalOut myled4(LED4); //The watchdog timer caused a reset + +// Simon's Watchdog code from +// http://mbed.org/forum/mbed/topic/508/ +class Watchdog { +public: +// Load timeout value in watchdog timer and enable + void kick(float s) { + LPC_WDT->WDCLKSEL = 0x1; // Set CLK src to PCLK + uint32_t clk = SystemCoreClock / 16; // WD has a fixed /4 prescaler, PCLK default is /4 + LPC_WDT->WDTC = s * (float)clk; + LPC_WDT->WDMOD = 0x3; // Enabled and Reset + kick(); + } +// "kick" or "feed" the dog - reset the watchdog timer +// by writing this required bit pattern + void kick() { + LPC_WDT->WDFEED = 0xAA; + LPC_WDT->WDFEED = 0x55; + } +}; \ No newline at end of file