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: BSP_DISCO_F746NG_patch_fixed mbed
Revision 0:1d5b62d757e2, committed 2015-12-25
- Comitter:
- nanase
- Date:
- Fri Dec 25 17:55:24 2015 +0000
- Commit message:
- First commit
Changed in this revision
diff -r 000000000000 -r 1d5b62d757e2 BSP_DISCO_F746NG_patch_fixed.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP_DISCO_F746NG_patch_fixed.lib Fri Dec 25 17:55:24 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/the_sz/code/BSP_DISCO_F746NG_patch_fixed/#3c0a51826ecc
diff -r 000000000000 -r 1d5b62d757e2 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Dec 25 17:55:24 2015 +0000
@@ -0,0 +1,56 @@
+#include "mbed.h"
+#include "stm32746g_discovery_audio.h"
+
+#define PI ((double)3.1415926535897932384626433832795028)
+#define SamplingFreq I2S_AUDIOFREQ_16K
+#define BufferSize (SamplingFreq * DEFAULT_AUDIO_IN_CHANNEL_NBR)
+
+#define AudioVolume ((uint8_t)8)
+#define Amplifier ((double)0.25)
+#define SineFreq ((double)440.0)
+
+/* 注意:
+ * AudioVolume で AudioOut のボリュームが設定できるはずだが、
+ * 現時点のライブラリだと、たとえば 0 だと大音量で再生される。
+ */
+
+DigitalOut led1(LED1);
+int16_t buffer[BufferSize];
+
+void error_trap()
+{
+ while(1) {
+ led1 = !led1;
+ wait_ms(250);
+ }
+}
+
+void init_audio()
+{
+ if (BSP_AUDIO_OUT_Init(OUTPUT_DEVICE_BOTH, AudioVolume, SamplingFreq) == AUDIO_ERROR)
+ error_trap();
+
+ BSP_AUDIO_OUT_SetAudioFrameSlot(CODEC_AUDIOFRAME_SLOT_02);
+}
+
+void play_audio()
+{
+ /* Generate sine wave */
+ for (int i = 0; i < SamplingFreq; i++) {
+ buffer[i * 2 + 1] =
+ buffer[i * 2 + 0] =
+ (int16_t)(Amplifier * sin(2.0 * PI * SineFreq * i / SamplingFreq) * 32767.5);
+ }
+
+ if (BSP_AUDIO_OUT_Play((uint16_t*)&buffer, BufferSize * AUDIODATA_SIZE) == AUDIO_ERROR)
+ error_trap();
+}
+
+int main()
+{
+ init_audio();
+ play_audio();
+
+ while(1)
+ wait(1);
+}
\ No newline at end of file
diff -r 000000000000 -r 1d5b62d757e2 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Dec 25 17:55:24 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/4336505e4b1c \ No newline at end of file