Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of RapidMP3_check by
Revision 2:8c6ca0906114, committed 2014-11-21
- Comitter:
- vasanth
- Date:
- Fri Nov 21 11:26:25 2014 +0000
- Parent:
- 1:dbb63bd6c828
- Commit message:
- RAPIDMP3 check first revision
Changed in this revision
--- a/RAPIDMP3.cpp Fri Nov 21 10:44:09 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,351 +0,0 @@
-/****************************************************************************
- * file RAPIDMP3.cpp
- * author Vasanth Kumar.D (www.chipthinglabs.com)
- * date July 2014
- * brief Rapid MP3 module driver code
- *
- * Project:
- * Rapid MP3 v1.0 driver code
- * The driver code is compatible with any mbed enabled microcontroller platform
- *
- * Description:
- * This is a sample code that shows how to control a Rapid MP3 module
- * using the UART peripheral of MBED micro. The code provides a set of API functions
- * to access and control the module using UART peripheral.
- *
- * Copyright (C) 2014, Chipthing Labs, all right reserved.
- * The Rapid MP3 code is a free software and there is NO WARRANTY.
- * No restriction on use. You can use, modify and redistribute it for
- * personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
- * Redistributions of source code must retain the above copyright notice.
- ****************************************************************************/
-
-#include "mbed.h"
-#include "RAPIDMP3.h"
-
-/**************************************************************************/
-
-RAPIDMP3::RAPIDMP3(PinName Tx, PinName Rx) : serialRMP3(Tx, Rx) {
- serialRMP3.baud(9600);
-}
-/**************************************************************************/
-
-void RAPIDMP3::transmitEndOfFrame() {
- serialRMP3.puts("\r\n");
-}
-/**************************************************************************/
-
-void RAPIDMP3::getResponseStr() {
- uint8_t i, temp;
- i = 0;
- do{
- temp = serialRMP3.getc();
- responseStr[i] = temp;
- i++;
- }while (temp != '\n');
- responseStr[i] = '\0';
-}
-/**************************************************************************/
-
-uint8_t RAPIDMP3::getResponse() {
- uint8_t response = RMP3_ER;
-
- getResponseStr();
-
- if (strcmp((const char *) responseStr, "OK\r\n") == 0) {
- response = RMP3_OK;
- }
- return response;
-}
-
-/**************************************************************************/
-/*
- @brief Checks whether the module is responding
- to serial communication requests
-
- @param[in] none
-
- @param[out] RMP3_OK or RMP3_ER
-
- */
-/**************************************************************************/
-
-uint8_t RAPIDMP3::checkDevice() {
- uint8_t response = RMP3_ER;
-
- serialRMP3.puts("AT\r\n");
- getResponseStr();
-
- if (strcmp((const char *) responseStr, "OK\r\n") == 0) {
- response = RMP3_OK;
- }
- return response;
-}
-/**************************************************************************/
-/*!
- @brief Plays a MP3 or WAV file from an SD card
-
- @param[in] fileName
- Pointer to the filename of stored MP3 or WAV file
- only 8.3 file name format is supported
-
- @param[out] RMP3_OK or RMP3_ER
-
- @section Example
-
- @code
-
- uint8_t response;
- response = rmp3.playFile("my_file.mp3");
- if (response == RMP3_OK) {
- rmp3.waitEndOfPlay();
- }
-
- @endcode
- */
-/**************************************************************************/
-
-uint8_t RAPIDMP3::playFile(const char *fileName) {
- serialRMP3.puts("AT+PLAY=");
- serialRMP3.putc('"');
- serialRMP3.puts(fileName);
- serialRMP3.putc('"');
- transmitEndOfFrame();
-
- return getResponse();
-}
-
-/**************************************************************************/
-/*
- @brief Waits until the current playback
- gets completely finished
-
- @param[in] none
-
- @param[out] RMP3_OK or RMP3_ER
-
- */
-/**************************************************************************/
-
-uint8_t RAPIDMP3::waitEndOfPlay() {
- uint8_t response = RMP3_ER;
- getResponseStr();
-
- if (strcmp((const char *) responseStr, "FREE\r\n") == 0) {
- response = RMP3_OK;
- }
- return response;
-}
-
-/**************************************************************************/
-/*
- @brief Waits for the device to indicate
- the initialization is complete
-
- @param[in] none
-
- @param[out] RMP3_OK or RMP3_ER
-
- */
-/**************************************************************************/
-
-uint8_t RAPIDMP3::waitDeviceFree() {
- return waitEndOfPlay();
-}
-
-/**************************************************************************/
-/*
- @brief Stops the current playback
-
- @param[in] none
-
- @param[out] RMP3_OK or RMP3_ER
-
- */
-/**************************************************************************/
-
-uint8_t RAPIDMP3::stop() {
- serialRMP3.puts("AT+STOP\r\n");
-
- uint8_t response;
- response = getResponse();
- if (response == RMP3_OK) {
- return waitEndOfPlay();
- }
- return RMP3_ER;
-}
-/**************************************************************************/
-/*
- @brief Pause the current playback
-
- @param[in] none
-
- @param[out] RMP3_OK or RMP3_ER
-
- */
-/**************************************************************************/
-
-uint8_t RAPIDMP3::playPause() {
- serialRMP3.puts("AT+PAUSE\r\n");
- return getResponse();
-}
-/**************************************************************************/
-/*
- @brief Resume the current playback
-
- @param[in] none
-
- @param[out] RMP3_OK or RMP3_ER
-
- */
-/**************************************************************************/
-
-uint8_t RAPIDMP3::playResume() {
- serialRMP3.puts("AT+RESUME\r\n");
- return getResponse();
-}
-/**************************************************************************/
-/*
- @brief Sets the volume level
-
- @param[in] vol
- volume level to be set
- values it can take: 0 to 9
- where 0 is maximum volume and 9 is mute
-
- @param[out] RMP3_OK or RMP3_ER
- */
-/**************************************************************************/
-
-uint8_t RAPIDMP3::volumeSet(uint8_t vol) {
- if (vol > 9) {
- return RMP3_ER;
- }
- serialRMP3.puts("AT+VOL=");
- serialRMP3.putc(vol + '0');
- transmitEndOfFrame();
-
- return getResponse();
-}
-/**************************************************************************/
-/*
- @brief Gets the volume level
-
- @param[in] none
-
- @param[out] current volume level
- */
-/**************************************************************************/
-
-uint8_t RAPIDMP3::volumeGet() {
- uint8_t volumeLevel = 0;
-
- serialRMP3.puts("AT+VOL=?\r\n");
- getResponseStr();
-
- volumeLevel = responseStr[4];
- volumeLevel -= '0'; // ASCII to decimal
-
- return volumeLevel;
-}
-/**************************************************************************/
-/*
- @brief Increases the volume level
-
- @param[in] none
-
- @param[out] RMP3_OK or RMP3_ER
- */
-/**************************************************************************/
-
-uint8_t RAPIDMP3::volumeInc() {
- serialRMP3.puts("AT+INC\r\n");
- return getResponse();
-}
-/**************************************************************************/
-/*
- @brief Decreases the volume level
-
- @param[in] none
-
- @param[out] RMP3_OK or RMP3_ER
- */
-/**************************************************************************/
-
-uint8_t RAPIDMP3::volumeDec() {
- serialRMP3.puts("AT+DEC\r\n");
- return getResponse();
-}
-/**************************************************************************/
-/*
- @brief Gets the system state, either BUSY or FREE
-
- @param[in] none
-
- @param[out] RMP3_FREE or RMP3_BUSY
-
- Description When either playback or recording is going on
- system state is BUSY
- When the module is not doing any of the two process,
- system state is FREE
- */
-/**************************************************************************/
-
-uint8_t RAPIDMP3::getPlaybackStatus() {
- uint8_t systemState = RMP3_NONE;
-
- serialRMP3.puts("AT+STATUS=?\r\n");
- getResponseStr();
-
- if (strcmp((const char *) responseStr, "BUSY\r\n") == 0) {
- systemState = RMP3_BUSY;
- } else if (strcmp((const char *) responseStr, "FREE\r\n") == 0) {
- systemState = RMP3_FREE;
- }
- return systemState;
-}
-/**************************************************************************/
-/*!
- @brief Records audio as WAV file and saves it in an SD card
-
- @param[in] fileName
- Pointer to the filename of the WAV file where the recording should be stored
- Only 8.3 file name format is supported
-
- @param[out] RMP3_OK or RMP3_ER
-
- Note Calling this function creates a new .wav file in the specified name
- within the microSD memory card
-
- @section Example
-
- @code
-
- uint8_t response;
- response = rmp3.recordFile("rec_1.wav");
-
- if (response == RMP3_OK) {
- wait(10.0);
- rmp3.stop();
-
- rmp3.playFile("rec_1.wav");
- rmp3.waitEndOfPlay();
- }
-
- @endcode
- */
-/**************************************************************************/
-
-uint8_t RAPIDMP3::recordFile(const char *fileName) {
- serialRMP3.puts("AT+RECD=");
- serialRMP3.putc('"');
- serialRMP3.puts(fileName);
- serialRMP3.putc('"');
- transmitEndOfFrame();
-
- return getResponse();
-}
-
-/**************************************************************************/
- /* END */
-/**************************************************************************/
--- a/RAPIDMP3.h Fri Nov 21 10:44:09 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/****************************************************************************
- * file RAPIDMP3.h
- * author Vasanth Kumar.D (www.chipthinglabs.com)
- * date July 2014
- * brief Rapid MP3 module code example
- *
- * Project:
- * Rapid MP3 v1.0 driver code
- * The driver code is compatible with any mbed enabled microcontroller platform
- *
- * Copyright (C) 2014, Chipthing Labs, all right reserved.
- * The Rapid MP3 code is a free software and there is NO WARRANTY.
- * No restriction on use. You can use, modify and redistribute it for
- * personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
- * Redistributions of source code must retain the above copyright notice.
-****************************************************************************/
-
-#ifndef RAPIDMP3_H
-#define RAPIDMP3_H
-
-/*-----------------------------------*/
-
-#define RMP3_NONE 2
-#define RMP3_BUSY 1
-#define RMP3_FREE 0
-
-#define RMP3_OK 1
-#define RMP3_ER 0
-
-/*-----------------------------------*/
-
-class RAPIDMP3 {
-
-private:
- // Private object
- Serial serialRMP3;
-
- // Private variable
- uint8_t responseStr[16];
-
- // Private functions
- void transmitEndOfFrame();
- void getResponseStr();
- uint8_t getResponse();
-
-public:
- // Public constructor
- RAPIDMP3(PinName Tx, PinName Rx);
-
- // Public functions
- uint8_t waitDeviceFree ();
- uint8_t checkDevice ();
- uint8_t playFile (const char *fileName); // .mp3 or .wav
- uint8_t waitEndOfPlay ();
- uint8_t stop ();
- uint8_t playPause ();
- uint8_t playResume ();
- uint8_t volumeSet (uint8_t vol);
- uint8_t volumeInc ();
- uint8_t volumeDec ();
- uint8_t volumeGet ();
- uint8_t getPlaybackStatus ();
- uint8_t recordFile (const char *fileName); // .wav
-};
-/*-----------------------------------*/
-
-#endif /* RAPIDMP3_H */
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RAPIDMP3.lib Fri Nov 21 11:26:25 2014 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/vasanth/code/RAPIDMP3/#3f15219e6084
