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.
Dependencies: USBMSD_BD SDFileSystem max32630fthr USBDevice
Revision 0:ad5ce0aff429, committed 2019-07-16
- Comitter:
- Lugs
- Date:
- Tue Jul 16 02:02:52 2019 +0000
- Child:
- 1:78ca0566c062
- Commit message:
- ver 26, changeable tone.
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDFileSystem.lib Tue Jul 16 02:02:52 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/SomeRandomBloke/code/SDFileSystem/#9c5f0c655284
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/USBDevice.lib Tue Jul 16 02:02:52 2019 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/#dad310740b28
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Jul 16 02:02:52 2019 +0000
@@ -0,0 +1,101 @@
+#include "mbed.h"
+#include "max32630fthr.h"
+#include "USBSerial.h"
+#include "stdio.h"
+#include "SDFileSystem.h"
+
+//still needs BITS PER SAMPLE PARSING.
+//do this like so: PWM.write(WavValue/2^BPS)
+
+#define BUFFER_SIZE 128
+#define HALF_BUFFER 64
+
+DigitalOut rLED(LED1);
+DigitalOut gLED(LED2);
+DigitalOut bLED(LED3);
+
+DigitalIn Button(P2_3);
+
+MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
+PwmOut PWM(P5_6);
+AnalogIn POT(AIN_0);
+volatile int bufferPOS = 0;
+volatile unsigned int g=0;
+
+Serial daplink(P2_1,P2_0);
+USBSerial microUSB;
+SDFileSystem sd(P0_5, P0_6, P0_4, P0_7, "sd");
+
+float audioDataBuffer[BUFFER_SIZE];
+
+struct WavFile
+{
+ long int size;
+ int channels;
+ int sampleRate;
+ int bitsPerSample;
+};
+
+float potval,reading;
+
+void placeNewSample(void)
+{
+ PWM.write(audioDataBuffer[bufferPOS++]*!Button); //multiply by POT value for volume.
+ bufferPOS = (bufferPOS+1) & 0x07F;
+}
+
+int main()
+{
+ WavFile Track;
+ Ticker SampleTime;
+
+ daplink.printf("\f---DAPLINK SERIAL PORT---\r\n\r\nPLAY TONE VER 26 \r\n (CHANGEABLE TONE)\r\n\r\n");
+ microUSB.printf("micro USB serial port\r\n");
+ rLED = LED_ON;
+ wait_ms(500);
+ rLED = LED_OFF;
+ gLED = LED_ON;
+ wait_ms(500);
+ bLED = LED_ON;
+ gLED = LED_OFF;
+
+ printf("Generating sine...\r\n");
+ int i;
+ for(i=0; i<128;i++)
+ {
+ audioDataBuffer[i] =((1.0 + sin((double(i)/16.0*6.28318530717959)))/2.0); //formula copied from mbed example
+ }
+
+ printf("Playing tone...\r\n");
+
+ int PlayingFreq = 500;
+
+ while(1)
+ {
+
+ Track.sampleRate = PlayingFreq * 16; //TONE FREQ = SAMPLE RATE / SAMPLES PER CYCLE
+
+ PWM.period_us(1); //1MHz
+
+ float ticker_period = (float) 1/(Track.sampleRate);
+
+ printf("\r\nTicker Period: %f\tTicker Freq: %f\r\nTarget Freq: %i\r\n\r\n",ticker_period, 1/ticker_period, PlayingFreq);
+
+ SampleTime.attach(&placeNewSample,ticker_period);
+ bLED = LED_OFF;
+
+ char c;
+ char number[10];
+ for(i=0;i<10 && c != '\r' && c != '\n'; i++)
+ {
+ c = daplink.getc();
+ number[i] = c;
+ }
+ gLED = LED_ON;
+ PlayingFreq = strtol(number,NULL,0);
+ gLED = LED_OFF;
+ rLED = !rLED;
+ SampleTime.detach();
+ }
+};
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/max32630fthr.lib Tue Jul 16 02:02:52 2019 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/teams/MaximIntegrated/code/max32630fthr/#8f6e6a800f2f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Tue Jul 16 02:02:52 2019 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#78474a5129e18e136cc7e872adbaa5b74fbb8f6a