Very simple test for SOMO-14D Embedded Audio-Sound Module

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
lnadal
Date:
Sun Oct 10 07:40:59 2010 +0000
Commit message:

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 78e5168d3809 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Oct 10 07:40:59 2010 +0000
@@ -0,0 +1,72 @@
+#include "mbed.h"
+
+/* Simple test for SOMO-14D module.
+ Plays a selected file. See www.4dsystems .com.au for details.
+ 
+ Author: Lluis Nadal.
+ Date: October 10th 2010.
+
+ File names must match file number in decimal:  0000.ad4 ... to 0511.ad4
+ Commands:
+    File addres (fileNumber): 0x0000 - 0x01FF
+    Play/Pause: 0xFFFE
+    Volume (8 levels): 0xFFF0 - 0xFFF7
+    Stop: 0xFFFF
+
+*/
+
+DigitalOut reset(p16); // connected to SOMO p10
+DigitalIn busy(p15);   // connected to SOMO p5
+
+// SOMO p9 connected to ground
+// SOMO p8 connected to Vcc = +3.3V
+// SOMO p11, p12 connected to speaker
+DigitalOut data(p5);     // connected to SOMO p4
+DigitalOut clk(p7);      // connected to SOMO p3
+unsigned short fileNumber;
+unsigned short command;
+
+
+void init() {
+
+    clk = 1;
+    reset = 1;
+    reset = 0;
+    wait(0.005);
+    reset = 1;
+    wait(0.3);
+}
+
+
+
+void writeData(unsigned short value) {
+
+    clk = 0;
+    wait(0.002);
+    for (int i = 0; i<16; i++) {
+        wait(0.000100f);
+        data = value & 0x8000; // selects most significant bit
+        wait(0.000001f);
+        clk = 1;
+        wait(0.000050f);
+        clk=0;
+        value = value <<1;     // shifts one bit left
+    }
+    clk =1;
+    wait(0.002);
+}
+
+
+int main() {
+    wait(0.5);
+    while (busy == 1); // checks if SOMO is busy
+
+    fileNumber = 0x0001; //selects 2nd file
+    command = 0xFFFE;    // play file command
+
+    init();
+
+    writeData(fileNumber);
+    writeData(command);
+
+}
diff -r 000000000000 -r 78e5168d3809 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Oct 10 07:40:59 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e