Daiki Kato / Mbed OS GR-PEACH_Audio_WAV_PwmOut Featured

Dependencies:   EasyPlayback

Fork of GR-PEACH_Audio_WAV by Renesas

This is a sample that drives a speaker with PWM. This sample will play a ".wav" file of the microSD or USB memory root folder. If the USER_BUTTON0 is pressed, the next song is played.

/media/uploads/dkato/pwm_speaker_img.png

FormatWav file (RIFF format) ".wav"
Channel1ch and 2ch
Frequencies32kHz, 44.1kHz and 48kHz
Quantization bit rate8bits and 16bits


You can adjust the volume by changing the following.

main.cpp

AudioPlayer.outputVolume(0.5);  // Volume control (min:0.0 max:1.0)


The default setting of serial communication (baud rate etc.) in mbed is shown the following link.
Please refer to the link and change the settings of your PC terminal software.
The default value of baud rate in mbed is 9600, and this application uses baud rate 9600.
https://developer.mbed.org/teams/Renesas/wiki/GR-PEACH-Getting-Started#install-the-usb-serial-communication

SD/SDFileSystem_GR_PEACH.h

Committer:
dkato
Date:
2016-12-20
Revision:
9:c7c0a97fdb7f

File content as of revision 9:c7c0a97fdb7f:

#ifndef MBED_SDFILESYSTEM_GR_PEACH_H
#define MBED_SDFILESYSTEM_GR_PEACH_H

#include "SDFileSystem.h"

/**
 * A class to communicate a SD
 */
class SDFileSystem_GR_PEACH : public SDFileSystem {
public:

    /**
    * Constructor
    *
    * @param rootdir mount name
    */
    SDFileSystem_GR_PEACH(const char* name) : SDFileSystem(P8_5, P8_6, P8_3, P8_4, name), _sd_cd(P7_8), _connect(false) {
        // Set SPI clock rate to 20MHz for data transfer
        set_transfer_sck(20000000);
    }

    /**
    * Check if a SD is connected
    *
    * @return true if a SD is connected
    */
    bool connected() {
        if (_sd_cd.read() != 0) {
            _connect = false;
        }
        return _connect;
    }

    /**
     * Try to connect to a SD
     *
     * @return true if connection was successful
     */
    bool connect() {
        if (_sd_cd.read() == 0) {
            _connect = true;
        } else {
            _connect = false;
        }
        return _connect;
    }


private:
    DigitalIn   _sd_cd;
    bool        _connect;
};

#endif