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