Lab 1 Program C

Dependents:   Lab1C

Fork of mbed by -deleted-

Committer:
emilmont
Date:
Tue Nov 29 14:59:27 2011 +0000
Revision:
27:7110ebee3484
Parent:
20:029aa53d7323
Child:
43:aff670d0d510
New Libraries 11.11

Who changed what in which revision?

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