Lab 1 Program C

Dependents:   Lab1C

Fork of mbed by -deleted-

Committer:
mattsims12
Date:
Tue Sep 29 03:04:58 2015 +0000
Revision:
44:1c5f591fce58
Parent:
43:aff670d0d510
Lab 1 Program C

Who changed what in which revision?

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