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.
Dependents: STM32F030R8_SOMO-14D
SOMO 14D Function Library Usage
List of SOMO-14D Functions Usage¶
SOMO14DisBusy¶
The function SOMO14DisBusy() checks if the busy pin is high, that means the device is playing audio
int main() {
SOMO14DInit();
while(1) {
.
.
if (!SOMO14DisBusy()) { /* Check if SOMO is doing something */
// Do something
}
.
.
}
}
SOMO14DInit¶
The function SOMO14DInit() initialize the module and set a callback function triggered when the device finish to play a song. SOMO14DInit() must be called before any other SOMO function.
void SOMO14DISR(void);
int main() {
SOMO14DInit(SOMO14DISR); /* Set up the sound module pins */
while(1) {
.
.
.
.
}
}
void SOMO14DISR(void) {
// Do something when the audio finish
}
SOMO14DPause¶
The function SOMO14DPause() makes two actions... holds the current song and if toggled resumes to the current song.
int main() {
SOMO14DInit();
while(1) {
// when received a char do the next thing...
switch (data) {
case 'h':
SOMO14DPause(); /* Hold or resumes the song */
break;
}
}
}
SOMO14DStop¶
The function SOMO14DStop() do as it says, stop the current song and puts the module in low power consumption mode.
int main() {
SOMO14DInit();
while(1) {
// when received a char do the next thing...
switch (data) {
case 's':
SOMO14DStop(); /* Shut down the music and sleep */
break;
}
}
}
SOMO14DVol¶
The function SOMO14DVol() change the volume and ensure that no volume is over or down the limit.
int main() {
char vol = 2;
SOMO14DInit();
while(1) {
// when received a char do the next thing...
switch (data) {
case 'm':
SOMO14DVol(0); /* Shhhh, (mute) */
break;
case '+':
vol++;
SOMO14DVol(&vol); /* Increase the volume*/
break;
case '-'
vol--;
SOMO14DVol(&vol); /* Decrease the volume */
break;
}
}
}
SOMO14DSetAudio¶
The function SOMO14DSetAudio() change the song to another audio and starts to play.
int main() {
char song = 33;
SOMO14DInit();
while(1) {
if (!SOMO14DisBusy()) { /* Check if SOMO is doing something */
SOMOSetAudio(song); /* Play the current song */
song++; /* Increase to the other song */
}
}
}