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.
main.cpp
00001 #include "mbed.h" 00002 00003 /* Simple test for SOMO-14D module. 00004 Plays a selected file. See www.4dsystems .com.au for details. 00005 00006 Author: Lluis Nadal. 00007 Date: October 10th 2010. 00008 00009 File names must match file number in decimal: 0000.ad4 ... to 0511.ad4 00010 Commands: 00011 File addres (fileNumber): 0x0000 - 0x01FF 00012 Play/Pause: 0xFFFE 00013 Volume (8 levels): 0xFFF0 - 0xFFF7 00014 Stop: 0xFFFF 00015 00016 */ 00017 00018 DigitalOut reset(p16); // connected to SOMO p10 00019 DigitalIn busy(p15); // connected to SOMO p5 00020 00021 // SOMO p9 connected to ground 00022 // SOMO p8 connected to Vcc = +3.3V 00023 // SOMO p11, p12 connected to speaker 00024 DigitalOut data(p5); // connected to SOMO p4 00025 DigitalOut clk(p7); // connected to SOMO p3 00026 unsigned short fileNumber; 00027 unsigned short command; 00028 00029 00030 void init() { 00031 00032 clk = 1; 00033 reset = 1; 00034 reset = 0; 00035 wait(0.005); 00036 reset = 1; 00037 wait(0.3); 00038 } 00039 00040 00041 00042 void writeData(unsigned short value) { 00043 00044 clk = 0; 00045 wait(0.002); 00046 for (int i = 0; i<16; i++) { 00047 wait(0.000100f); 00048 data = value & 0x8000; // selects most significant bit 00049 wait(0.000001f); 00050 clk = 1; 00051 wait(0.000050f); 00052 clk=0; 00053 value = value <<1; // shifts one bit left 00054 } 00055 clk =1; 00056 wait(0.002); 00057 } 00058 00059 00060 int main() { 00061 wait(0.5); 00062 while (busy == 1); // checks if SOMO is busy 00063 00064 fileNumber = 0x0001; //selects 2nd file 00065 command = 0xFFFE; // play file command 00066 00067 init(); 00068 00069 writeData(fileNumber); 00070 writeData(command); 00071 00072 }
Generated on Thu Jul 21 2022 16:19:04 by
1.7.2