SD card interface

Committer:
lharoon
Date:
Mon Oct 08 11:14:07 2012 +0000
Revision:
0:22612ae617a0
1st edition

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lharoon 0:22612ae617a0 1 /* mbed Microcontroller Library - Timer
lharoon 0:22612ae617a0 2 * Copyright (c) 2007-2009 ARM Limited. All rights reserved.
lharoon 0:22612ae617a0 3 */
lharoon 0:22612ae617a0 4
lharoon 0:22612ae617a0 5 #ifndef MBED_TIMER_H
lharoon 0:22612ae617a0 6 #define MBED_TIMER_H
lharoon 0:22612ae617a0 7
lharoon 0:22612ae617a0 8 #include "platform.h"
lharoon 0:22612ae617a0 9 #include "PinNames.h"
lharoon 0:22612ae617a0 10 #include "PeripheralNames.h"
lharoon 0:22612ae617a0 11 #include "Base.h"
lharoon 0:22612ae617a0 12
lharoon 0:22612ae617a0 13 namespace mbed {
lharoon 0:22612ae617a0 14
lharoon 0:22612ae617a0 15 /* Class: Timer
lharoon 0:22612ae617a0 16 * A general purpose timer
lharoon 0:22612ae617a0 17 *
lharoon 0:22612ae617a0 18 * Example:
lharoon 0:22612ae617a0 19 * > // Count the time to toggle a LED
lharoon 0:22612ae617a0 20 * >
lharoon 0:22612ae617a0 21 * > #include "mbed.h"
lharoon 0:22612ae617a0 22 * >
lharoon 0:22612ae617a0 23 * > Timer timer;
lharoon 0:22612ae617a0 24 * > DigitalOut led(LED1);
lharoon 0:22612ae617a0 25 * > int begin, end;
lharoon 0:22612ae617a0 26 * >
lharoon 0:22612ae617a0 27 * > int main() {
lharoon 0:22612ae617a0 28 * > timer.start();
lharoon 0:22612ae617a0 29 * > begin = timer.read_us();
lharoon 0:22612ae617a0 30 * > led = !led;
lharoon 0:22612ae617a0 31 * > end = timer.read_us();
lharoon 0:22612ae617a0 32 * > printf("Toggle the led takes %d us", end - begin);
lharoon 0:22612ae617a0 33 * > }
lharoon 0:22612ae617a0 34 */
lharoon 0:22612ae617a0 35 class Timer : public Base {
lharoon 0:22612ae617a0 36
lharoon 0:22612ae617a0 37 public:
lharoon 0:22612ae617a0 38
lharoon 0:22612ae617a0 39 Timer(const char *name = NULL);
lharoon 0:22612ae617a0 40
lharoon 0:22612ae617a0 41 /* Function: start
lharoon 0:22612ae617a0 42 * Start the timer
lharoon 0:22612ae617a0 43 */
lharoon 0:22612ae617a0 44 void start();
lharoon 0:22612ae617a0 45
lharoon 0:22612ae617a0 46 /* Function: stop
lharoon 0:22612ae617a0 47 * Stop the timer
lharoon 0:22612ae617a0 48 */
lharoon 0:22612ae617a0 49 void stop();
lharoon 0:22612ae617a0 50
lharoon 0:22612ae617a0 51 /* Function: reset
lharoon 0:22612ae617a0 52 * Reset the timer to 0.
lharoon 0:22612ae617a0 53 *
lharoon 0:22612ae617a0 54 * If it was already counting, it will continue
lharoon 0:22612ae617a0 55 */
lharoon 0:22612ae617a0 56 void reset();
lharoon 0:22612ae617a0 57
lharoon 0:22612ae617a0 58 /* Function: read
lharoon 0:22612ae617a0 59 * Get the time passed in seconds
lharoon 0:22612ae617a0 60 */
lharoon 0:22612ae617a0 61 float read();
lharoon 0:22612ae617a0 62
lharoon 0:22612ae617a0 63 /* Function: read_ms
lharoon 0:22612ae617a0 64 * Get the time passed in mili-seconds
lharoon 0:22612ae617a0 65 */
lharoon 0:22612ae617a0 66 int read_ms();
lharoon 0:22612ae617a0 67
lharoon 0:22612ae617a0 68 /* Function: read_us
lharoon 0:22612ae617a0 69 * Get the time passed in micro-seconds
lharoon 0:22612ae617a0 70 */
lharoon 0:22612ae617a0 71 int read_us();
lharoon 0:22612ae617a0 72
lharoon 0:22612ae617a0 73 #ifdef MBED_OPERATORS
lharoon 0:22612ae617a0 74 operator float();
lharoon 0:22612ae617a0 75 #endif
lharoon 0:22612ae617a0 76
lharoon 0:22612ae617a0 77 #ifdef MBED_RPC
lharoon 0:22612ae617a0 78 virtual const struct rpc_method *get_rpc_methods();
lharoon 0:22612ae617a0 79 static struct rpc_class *get_rpc_class();
lharoon 0:22612ae617a0 80 #endif
lharoon 0:22612ae617a0 81
lharoon 0:22612ae617a0 82 protected:
lharoon 0:22612ae617a0 83
lharoon 0:22612ae617a0 84 int slicetime();
lharoon 0:22612ae617a0 85 int _running; // whether the timer is running
lharoon 0:22612ae617a0 86 unsigned int _start; // the start time of the latest slice
lharoon 0:22612ae617a0 87 int _time; // any accumulated time from previous slices
lharoon 0:22612ae617a0 88
lharoon 0:22612ae617a0 89 };
lharoon 0:22612ae617a0 90
lharoon 0:22612ae617a0 91 } // namespace mbed
lharoon 0:22612ae617a0 92
lharoon 0:22612ae617a0 93 #endif
lharoon 0:22612ae617a0 94