Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
mbed_sleep_blinky.cpp@0:ab9939da6645, 2016-11-17 (annotated)
- Committer:
- pateshian
- Date:
- Thu Nov 17 15:52:54 2016 +0000
- Revision:
- 0:ab9939da6645
- Child:
- 1:e508448feb1c
Test_Sleepy_blinky_WFI
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pateshian | 0:ab9939da6645 | 1 | #include "mbed.h" |
pateshian | 0:ab9939da6645 | 2 | #define IRQ4 (36) |
pateshian | 0:ab9939da6645 | 3 | gpio_irq_t irqHandler; |
pateshian | 0:ab9939da6645 | 4 | |
pateshian | 0:ab9939da6645 | 5 | DigitalOut led1(LED1); |
pateshian | 0:ab9939da6645 | 6 | int gFlag = 0; |
pateshian | 0:ab9939da6645 | 7 | |
pateshian | 0:ab9939da6645 | 8 | void interrupt_irq4_user (uint32_t id, gpio_irq_event event) { |
pateshian | 0:ab9939da6645 | 9 | if (!gFlag){ |
pateshian | 0:ab9939da6645 | 10 | gFlag = 1; |
pateshian | 0:ab9939da6645 | 11 | } |
pateshian | 0:ab9939da6645 | 12 | } |
pateshian | 0:ab9939da6645 | 13 | |
pateshian | 0:ab9939da6645 | 14 | // main() runs in its own thread in the OS |
pateshian | 0:ab9939da6645 | 15 | // (note the calls to Thread::wait below for delays) |
pateshian | 0:ab9939da6645 | 16 | int main() { |
pateshian | 0:ab9939da6645 | 17 | |
pateshian | 0:ab9939da6645 | 18 | gpio_irq_init (&irqHandler, USER_BUTTON0, interrupt_irq4_user, IRQ4); |
pateshian | 0:ab9939da6645 | 19 | |
pateshian | 0:ab9939da6645 | 20 | while (true) { |
pateshian | 0:ab9939da6645 | 21 | if ( gFlag == 1 ) { |
pateshian | 0:ab9939da6645 | 22 | gFlag = 0; |
pateshian | 0:ab9939da6645 | 23 | led1 = led1; |
pateshian | 0:ab9939da6645 | 24 | __WFI(); |
pateshian | 0:ab9939da6645 | 25 | led1 = !led1; |
pateshian | 0:ab9939da6645 | 26 | } |
pateshian | 0:ab9939da6645 | 27 | //led1 = !led1; |
pateshian | 0:ab9939da6645 | 28 | //Thread::wait(500); |
pateshian | 0:ab9939da6645 | 29 | } |
pateshian | 0:ab9939da6645 | 30 | } |