![](/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
Watchdog.h@3:d48372c1347e, 2017-12-13 (annotated)
- Committer:
- kjones99
- Date:
- Wed Dec 13 17:17:07 2017 +0000
- Revision:
- 3:d48372c1347e
- Parent:
- 2:5366ce17fe55
Final version with comments.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kjones99 | 2:5366ce17fe55 | 1 | #include "mbed.h" |
kjones99 | 2:5366ce17fe55 | 2 | // LEDs used to indicate code activity and reset source |
kjones99 | 2:5366ce17fe55 | 3 | DigitalOut myled1(LED1); //in main loop part 1 |
kjones99 | 2:5366ce17fe55 | 4 | DigitalOut myled2(LED2); //in main loop part 2 (where fault occurs) |
kjones99 | 2:5366ce17fe55 | 5 | DigitalOut myled3(LED3); //The pushbutton or power on caused a reset |
kjones99 | 2:5366ce17fe55 | 6 | DigitalOut myled4(LED4); //The watchdog timer caused a reset |
kjones99 | 2:5366ce17fe55 | 7 | |
kjones99 | 2:5366ce17fe55 | 8 | // Simon's Watchdog code from |
kjones99 | 2:5366ce17fe55 | 9 | // http://mbed.org/forum/mbed/topic/508/ |
kjones99 | 2:5366ce17fe55 | 10 | class Watchdog { |
kjones99 | 2:5366ce17fe55 | 11 | public: |
kjones99 | 2:5366ce17fe55 | 12 | // Load timeout value in watchdog timer and enable |
kjones99 | 2:5366ce17fe55 | 13 | void kick(float s) { |
kjones99 | 2:5366ce17fe55 | 14 | LPC_WDT->WDCLKSEL = 0x1; // Set CLK src to PCLK |
kjones99 | 2:5366ce17fe55 | 15 | uint32_t clk = SystemCoreClock / 16; // WD has a fixed /4 prescaler, PCLK default is /4 |
kjones99 | 2:5366ce17fe55 | 16 | LPC_WDT->WDTC = s * (float)clk; |
kjones99 | 2:5366ce17fe55 | 17 | LPC_WDT->WDMOD = 0x3; // Enabled and Reset |
kjones99 | 2:5366ce17fe55 | 18 | kick(); |
kjones99 | 2:5366ce17fe55 | 19 | } |
kjones99 | 2:5366ce17fe55 | 20 | // "kick" or "feed" the dog - reset the watchdog timer |
kjones99 | 2:5366ce17fe55 | 21 | // by writing this required bit pattern |
kjones99 | 2:5366ce17fe55 | 22 | void kick() { |
kjones99 | 2:5366ce17fe55 | 23 | LPC_WDT->WDFEED = 0xAA; |
kjones99 | 2:5366ce17fe55 | 24 | LPC_WDT->WDFEED = 0x55; |
kjones99 | 2:5366ce17fe55 | 25 | } |
kjones99 | 2:5366ce17fe55 | 26 | }; |