This is my quadcopter prototype software, still in development!

Committer:
Anaesthetix
Date:
Tue Jul 23 14:01:42 2013 +0000
Revision:
1:ac68f0368a77
Parent:
0:978110f7f027
Other accelerometer added

Who changed what in which revision?

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