nothing changed
Fork of mbed by
wait_api.h@1:27d81db81dd7, 2015-03-03 (annotated)
- Committer:
- Jing_Qiu
- Date:
- Tue Mar 03 00:55:57 2015 +0000
- Revision:
- 1:27d81db81dd7
- Parent:
- 0:a8fa94490a0a
revise
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gokmenascioglu | 0:a8fa94490a0a | 1 | /* Title: wait |
gokmenascioglu | 0:a8fa94490a0a | 2 | * Generic wait functions. |
gokmenascioglu | 0:a8fa94490a0a | 3 | * |
gokmenascioglu | 0:a8fa94490a0a | 4 | * These provide simple NOP type wait capabilities. |
gokmenascioglu | 0:a8fa94490a0a | 5 | * |
gokmenascioglu | 0:a8fa94490a0a | 6 | * Example: |
gokmenascioglu | 0:a8fa94490a0a | 7 | * > #include "mbed.h" |
gokmenascioglu | 0:a8fa94490a0a | 8 | * > |
gokmenascioglu | 0:a8fa94490a0a | 9 | * > DigitalOut heartbeat(LED1); |
gokmenascioglu | 0:a8fa94490a0a | 10 | * > |
gokmenascioglu | 0:a8fa94490a0a | 11 | * > int main() { |
gokmenascioglu | 0:a8fa94490a0a | 12 | * > while (1) { |
gokmenascioglu | 0:a8fa94490a0a | 13 | * > heartbeat = 1; |
gokmenascioglu | 0:a8fa94490a0a | 14 | * > wait(0.5); |
gokmenascioglu | 0:a8fa94490a0a | 15 | * > heartbeat = 0; |
gokmenascioglu | 0:a8fa94490a0a | 16 | * > wait(0.5); |
gokmenascioglu | 0:a8fa94490a0a | 17 | * > } |
gokmenascioglu | 0:a8fa94490a0a | 18 | * > } |
gokmenascioglu | 0:a8fa94490a0a | 19 | */ |
gokmenascioglu | 0:a8fa94490a0a | 20 | |
gokmenascioglu | 0:a8fa94490a0a | 21 | /* mbed Microcontroller Library - wait_api |
gokmenascioglu | 0:a8fa94490a0a | 22 | * Copyright (c) 2009 ARM Limited. All rights reserved. |
gokmenascioglu | 0:a8fa94490a0a | 23 | */ |
gokmenascioglu | 0:a8fa94490a0a | 24 | |
gokmenascioglu | 0:a8fa94490a0a | 25 | #ifndef MBED_WAIT_API_H |
gokmenascioglu | 0:a8fa94490a0a | 26 | #define MBED_WAIT_API_H |
gokmenascioglu | 0:a8fa94490a0a | 27 | |
gokmenascioglu | 0:a8fa94490a0a | 28 | #ifdef __cplusplus |
gokmenascioglu | 0:a8fa94490a0a | 29 | extern "C" { |
gokmenascioglu | 0:a8fa94490a0a | 30 | #endif |
gokmenascioglu | 0:a8fa94490a0a | 31 | |
gokmenascioglu | 0:a8fa94490a0a | 32 | /* Function: wait |
gokmenascioglu | 0:a8fa94490a0a | 33 | * Waits for a number of seconds, with microsecond resolution (within |
gokmenascioglu | 0:a8fa94490a0a | 34 | * the accuracy of single precision floating point). |
gokmenascioglu | 0:a8fa94490a0a | 35 | * |
gokmenascioglu | 0:a8fa94490a0a | 36 | * Variables: |
gokmenascioglu | 0:a8fa94490a0a | 37 | * s - number of seconds to wait |
gokmenascioglu | 0:a8fa94490a0a | 38 | */ |
gokmenascioglu | 0:a8fa94490a0a | 39 | void wait(float s); |
gokmenascioglu | 0:a8fa94490a0a | 40 | |
gokmenascioglu | 0:a8fa94490a0a | 41 | /* Function: wait_ms |
gokmenascioglu | 0:a8fa94490a0a | 42 | * Waits a number of milliseconds. |
gokmenascioglu | 0:a8fa94490a0a | 43 | * |
gokmenascioglu | 0:a8fa94490a0a | 44 | * Variables: |
gokmenascioglu | 0:a8fa94490a0a | 45 | * ms - the whole number of milliseconds to wait |
gokmenascioglu | 0:a8fa94490a0a | 46 | */ |
gokmenascioglu | 0:a8fa94490a0a | 47 | void wait_ms(int ms); |
gokmenascioglu | 0:a8fa94490a0a | 48 | |
gokmenascioglu | 0:a8fa94490a0a | 49 | /* Function: wait_us |
gokmenascioglu | 0:a8fa94490a0a | 50 | * Waits a number of microseconds. |
gokmenascioglu | 0:a8fa94490a0a | 51 | * |
gokmenascioglu | 0:a8fa94490a0a | 52 | * Variables: |
gokmenascioglu | 0:a8fa94490a0a | 53 | * us - the whole number of microseconds to wait |
gokmenascioglu | 0:a8fa94490a0a | 54 | */ |
gokmenascioglu | 0:a8fa94490a0a | 55 | void wait_us(int us); |
gokmenascioglu | 0:a8fa94490a0a | 56 | |
gokmenascioglu | 0:a8fa94490a0a | 57 | #ifdef TARGET_LPC11U24 |
gokmenascioglu | 0:a8fa94490a0a | 58 | /* Function: sleep |
gokmenascioglu | 0:a8fa94490a0a | 59 | * Send the microcontroller to sleep |
gokmenascioglu | 0:a8fa94490a0a | 60 | * |
gokmenascioglu | 0:a8fa94490a0a | 61 | * The processor is setup ready for sleep, and sent to sleep using __WFI(). In this mode, the |
gokmenascioglu | 0:a8fa94490a0a | 62 | * system clock to the core is stopped until a reset or an interrupt occurs. This eliminates |
gokmenascioglu | 0:a8fa94490a0a | 63 | * dynamic power used by the processor, memory systems and buses. The processor, peripheral and |
gokmenascioglu | 0:a8fa94490a0a | 64 | * memory state are maintained, and the peripherals continue to work and can generate interrupts. |
gokmenascioglu | 0:a8fa94490a0a | 65 | * |
gokmenascioglu | 0:a8fa94490a0a | 66 | * The processor can be woken up by any internal peripheral interrupt or external pin interrupt. |
gokmenascioglu | 0:a8fa94490a0a | 67 | * |
gokmenascioglu | 0:a8fa94490a0a | 68 | * Note: The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored. |
gokmenascioglu | 0:a8fa94490a0a | 69 | * Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be |
gokmenascioglu | 0:a8fa94490a0a | 70 | * able to access the LocalFileSystem |
gokmenascioglu | 0:a8fa94490a0a | 71 | */ |
gokmenascioglu | 0:a8fa94490a0a | 72 | void sleep(void); |
gokmenascioglu | 0:a8fa94490a0a | 73 | |
gokmenascioglu | 0:a8fa94490a0a | 74 | /* Function: deepsleep |
gokmenascioglu | 0:a8fa94490a0a | 75 | * Send the microcontroller to deep sleep |
gokmenascioglu | 0:a8fa94490a0a | 76 | * |
gokmenascioglu | 0:a8fa94490a0a | 77 | * This processor is setup ready for deep sleep, and sent to sleep using __WFI(). This mode |
gokmenascioglu | 0:a8fa94490a0a | 78 | * has the same sleep features as sleep plus it powers down peripherals and clocks. All state |
gokmenascioglu | 0:a8fa94490a0a | 79 | * is still maintained. |
gokmenascioglu | 0:a8fa94490a0a | 80 | * |
gokmenascioglu | 0:a8fa94490a0a | 81 | * The processor can only be woken up by an external interrupt on a pin or a watchdog timer. |
gokmenascioglu | 0:a8fa94490a0a | 82 | * |
gokmenascioglu | 0:a8fa94490a0a | 83 | * Note: The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored. |
gokmenascioglu | 0:a8fa94490a0a | 84 | * Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be |
gokmenascioglu | 0:a8fa94490a0a | 85 | * able to access the LocalFileSystem |
gokmenascioglu | 0:a8fa94490a0a | 86 | */ |
gokmenascioglu | 0:a8fa94490a0a | 87 | void deepsleep(void); |
gokmenascioglu | 0:a8fa94490a0a | 88 | #endif |
gokmenascioglu | 0:a8fa94490a0a | 89 | |
gokmenascioglu | 0:a8fa94490a0a | 90 | #ifdef __cplusplus |
gokmenascioglu | 0:a8fa94490a0a | 91 | } |
gokmenascioglu | 0:a8fa94490a0a | 92 | #endif |
gokmenascioglu | 0:a8fa94490a0a | 93 | |
gokmenascioglu | 0:a8fa94490a0a | 94 | #endif |