Simple test application for the STMicroelectronics X-NUCLEO-CCA01M1 Sound Terminal Expansion Board, built against mbed classic.

Dependencies:   X_NUCLEO_CCA01M1 ST_Events-old mbed

Fork of HelloWorld_CCA01M1_mbedOS by ST

Playing audio with the X-NUCLEO-CCA01M1 Expansion Board

This application provides a simple example of usage of the X-NUCLEO-CCA01M1 Sound Terminal Expansion Board, built against mbed classic.

It shows how to play a 2-channel stereo signal stored in an array of PCM samples directly on the speakers connected to the expansion board.

It also allows to stop/play the audio by pressing the user button on the Nucleo board.


Platform compatibility

  • This board can be currently used with a Nucleo-F401RE board only and has been tested with the default configuration provided by this example.
  • Please note that the main application makes use of the "events" library, which is not included into the "mbed" library.
  • The application built against mbed OS 5.x can be found here.
Revision:
5:ac729170df5f
Parent:
4:6bb9e11d322b
Child:
7:94e3191477c5
--- a/main.cpp	Mon Apr 10 13:16:41 2017 +0000
+++ b/main.cpp	Fri Apr 21 10:09:14 2017 +0200
@@ -50,7 +50,7 @@
 #include "DevI2C.h"
 
 /* Component specific header files. */
-#include "sta350bw_class.h"
+#include "STA350BW.h"
 
 /* My song header file. */
 #include "my_song.h"
@@ -102,7 +102,7 @@
  * @param  None.
  * @retval None.
  */
-void PlayStopHandler(void)
+void play_stop_handler(void)
 {
     while (true)
     {
@@ -112,9 +112,9 @@
         play_stop_thread->signal_wait(PLAY_STOP_EVENT);
 
         if (stop)
-            sound_terminal->Stop();
+            sound_terminal->stop();
         else
-            sound_terminal->Play((int16_t *) my_song, (uint16_t) sizeof(my_song), true);
+            sound_terminal->play((int16_t *) my_song, (uint16_t) sizeof(my_song), true);
         printf("--> %s\r\n", stop ? "Stop." : "Playing...");
 
         stop = !stop;
@@ -139,7 +139,7 @@
 #else
     sound_terminal = new STA350BW(PA_10, STA350BW_ADDRESS_2, *dev_i2c, PC_12, PC_10, PA_4, NC, PC_7);
 #endif
-    if (sound_terminal->Init(&init) != COMPONENT_OK)
+    if (sound_terminal->init(&init) != COMPONENT_OK)
     {
         error("Initialization of the Sound Terminal Expansion Board failed.\r\n");
         exit(EXIT_FAILURE);
@@ -151,14 +151,14 @@
 
     /* Scheduling the play/stop function. */
     play_stop_thread = new Thread();
-    osStatus status = play_stop_thread->start(PlayStopHandler);
+    osStatus status = play_stop_thread->start(play_stop_handler);
     if (status != osOK)
         printf("Could not start the play/stop handler thread.\r\n");
     event.fall(&pressed);
 
     /* Setting Sound Terminal Component's parameters. */
-    sound_terminal->SetFrequency(MY_SONG_AUDIO_FREQUENCY);
-    sound_terminal->SetVolume(STA350BW_CHANNEL_MASTER, 60);
+    sound_terminal->set_frequency(MY_SONG_AUDIO_FREQUENCY);
+    sound_terminal->set_volume(STA350BW_CHANNEL_MASTER, 60);
 
     /* Printing to the console. */
     printf("Sound Terminal Application Example\r\n\n");
@@ -168,7 +168,7 @@
 
     /* Printing to the console. */
     printf("--> Playing...\r\n");
-    sound_terminal->Play((int16_t *) my_song, (uint16_t) sizeof(my_song), true);
+    sound_terminal->play((int16_t *) my_song, (uint16_t) sizeof(my_song), true);
 }
 
 #else // DEVICE_I2S