MP3 Player without external hardware MP3 Player without external hardware. A software based MP3 player based on a modified version of libmad. Mono output (at the moment) via AnalogOut. Files are read from an USB drive. This is a demo program, it plays only one file at the moment. Documentation is in "main.cpp" and "config.h"

Dependencies:   mbed

Committer:
Gruenfrosch
Date:
Sat Nov 27 17:27:33 2010 +0000
Revision:
2:f28cf0afd021
Parent:
0:7627c79db971
Version 3:
* moved another memory block into AHB RAM, giving more room for
* stereo buffer.
* moved content of decode() to main()
* decoding is now safe to be called multiple times (bug in older versions)
* Output routine now fills stereo buffer, DAC output sums channels,
* just for demonstration that stereo output could go here

Who changed what in which revision?

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