Dialog DA7212 evaluating project DEVELOP branch

Dependencies:   FXAS21002 TLV320 mbed sinelookup C12832 FXOS8700

Files at this revision

API Documentation at this revision

Comitter:
k4zuki
Date:
Mon Jun 05 16:25:29 2017 +0000
Parent:
13:b9e27895f98a
Child:
15:f9f642239cb6
Commit message:
add new libs, confirmed MCLK/TX-BCLK/TX-WCLK generated on pins

Changed in this revision

FXAS21002.lib Show annotated file Show diff for this revision Revisions of this file
FXOS8700.lib Show annotated file Show diff for this revision Revisions of this file
I2S.lib Show diff for this revision Revisions of this file
da7212dev.lib Show annotated file Show diff for this revision Revisions of this file
frdm_i2s.lib Show annotated file Show diff for this revision Revisions of this file
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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FXAS21002.lib	Mon Jun 05 16:25:29 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/AswinSivakumar/code/FXAS21002/#c9ebfc81e8b6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FXOS8700.lib	Mon Jun 05 16:25:29 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/AswinSivakumar/code/FXOS8700/#df2167370234
--- a/I2S.lib	Mon Apr 24 17:47:00 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://developer.mbed.org/users/k4zuki/code/I2S/#94430ea76fc4
--- a/da7212dev.lib	Mon Apr 24 17:47:00 2017 +0000
+++ b/da7212dev.lib	Mon Jun 05 16:25:29 2017 +0000
@@ -1,1 +1,1 @@
-https://github.com/K4zuki/da7212dev/#551c4c1edbfe443775532544af67d525dba703e0
+https://github.com/K4zuki/da7212dev/#9a1d42a3fbf74f7688a27161e914474e333188a5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/frdm_i2s.lib	Mon Jun 05 16:25:29 2017 +0000
@@ -0,0 +1,1 @@
+https://github.com/K4zuki/frdm_i2s/#e8ad61e86c0ea6d513e41e1c6e5808e9b381011e
--- a/main.cpp	Mon Apr 24 17:47:00 2017 +0000
+++ b/main.cpp	Mon Jun 05 16:25:29 2017 +0000
@@ -1,115 +1,161 @@
 /** original: p07gbar/code/TLV320_Write_test/
  * modify by k4zuki
- * to control Dialog DA7212 codec
+ * to control Dialog DA7212 codec from FRDM-K64F/K66F
+ * - FRDM
+ *      - https://developer.mbed.org/platforms/FRDM-K64F/
+ *          - I2S
+ *              - I2S_TXD: PTC1
+ *              - I2S_TX_FS: PTB19
+ *              - I2S_TX_BCLK: PTB18
+ *          - FXOS8700CQ - Accelerometer and Magnetometer
+ *              - SCL:SCL
+ *              - SDA:SDA
+ *                  - 8-bit Address: 0x3A
+ *      - https://developer.mbed.org/platforms/FRDM-K66F/
+ *          - I2S
+ *              - I2S_TXD: PTC1
+ *              - I2S_TX_FS: PTE11
+ *              - I2S_TX_BCLK: PTE12
+ *          - FXOS8700CQ - Accelerometer and Magnetometer
+ *              - SCL:SCL
+ *              - SDA:SDA
+ *                  - 8-bit Address: 0x3A
+ *          - FXAS21002 - Gyroscope
+ *              - SCL:SCL
+ *              - SDA:SDA
+ *                  - 8-bit Address: 0x42
+ *          - 2 user push-buttons
+ *          - RGB LED
+ * - DA7212 (on-board(K66F) or off-board(K64F+ARD-AUDIO-7212))
+ *      - https://developer.mbed.org/components/ARD-AUDIO-DA7212/
+ *      - SCL:SCL
+ *      - SDA:SDA
+ *          - 8-bit address: 0x34
+ * - Application Shield
+ *      - https://developer.mbed.org/components/mbed-Application-Shield/
+ *      - 3 Axis +/1 1.5g Accelerometer,I2C Interface  Freescale MMA7660
+ *          - SCL: SCL
+ *          - SDA: SDA
+ *              - 8-bit Address: 0x98
+ *      - Temperature sensor  LM75B
+ *          - SCL: SCL
+ *          - SDA: SDA
+ *              - 8-bit Address: 0x90
+ *      - 2 x Potentiometers  Iskra PNZ10ZA, 10k
+ *          - Pot 1 (left) : A0
+ *          - Pot 2 (right): A1
+ *      - 5 way Joystick  ALPS SKRHADE010
+ *          - Up: A2
+ *          - Down: A3
+ *          - Left: A4
+ *          - Right: A5
+ *          - Centre: D4
+ *      - 128x32 Graphics LCD, SPI Interface  Newhaven C12332A1Z
+ *          - A0: D7
+ *          - nCS: D10
+ *          - MOSI: D11
+ *          - nRESET: D12
+ *          - SCK: D13
+ *      - RGB LED, PWM connected  Cree Inc CLV1A-FKB
+ *          - Red: D5
+ *          - Blue: D8
+ *          - Green: D9
+ *      - Speaker, PWM Connected  MULTICOMP  MCSMT-8030B-3717
+ *          - D6
+ *      - Xbee socket
+ *          - Tx: D0
+ *          - Rx: D1
+ *          - Status: D2
+ *          - nReset: D3
  */
+
 #include "mbed.h"
+
+AnalogIn pot1 (A0);
+AnalogIn pot2 (A1);
+
+InterruptIn left(PTA4);
+InterruptIn right(PTC6);
+
+#include "FXOS8700.h"
+FXOS8700 acc(I2C_SDA, I2C_SCL, 0x3A);
+FXOS8700 mag(I2C_SDA, I2C_SCL, 0x3A);
+
+#include "C12832.h"
+C12832 lcd(D11, D13, D12, D7, D10);
+
+
+#include "DA7212.h"
+#include "FrdmI2s.h"
+#define SAMPLERATE 32000
 #include "sinelookup.h"
-// #include "TLV320.h"
-// #include "DA7212.h"
-#include "I2S.h"
-// #include "C12832.h"
-
-// C12832 lcd(PTD2, PTD1, PTD3, PTC3, PTD0);
-// AnalogIn pot1 (PTB2);
-// AnalogIn pot2 (PTB3);
-
-#define SAMPLERATE 32000
-
 //DA7212 codec(I2C_SDA, I2C_SCL);
 //TLV320 codec(I2C_SDA, I2C_SCL);
-I2S i2s(I2S_TRANSMIT, PTC1, PTB19, PTB18);
+FrdmI2s i2s(I2S_TRANSMIT, PTC1, PTE11, PTE12);
 
-//AnalogIn aIn(p19);
-//AnalogIn vol(p20);
-//
-//float phase_l;
-//float phase_r;
-//int minibuf[16];
-//float skipper;
-//float volume;
+uint16_t phase_l;
+uint16_t phase_r;
+int minibuf[16];
+unsigned short skipper;
+unsigned short volume;
+
 //float phase_kill;
-//
-//
 //extern "C" void HardFault_Handler()
 //{
 //    error("Hard Fault!\n");
 //}
-//
-//
-//void play(void)
-//{
-//    int to_write = i2s.max_fifo_points() - (i2s.fifo_points());
-//    for(int i = 0; i < to_write; i+=2) {
-//        minibuf[i] = int(float(sine16lookup[int(phase_l)])*volume);
-//        //minibuf[i] = int(sine16lookup[int(phase_l)]);
-//        minibuf[i+1] = int(float(sine16lookup[int(phase_r)])*volume);
-//        phase_l+=skipper;
-//        phase_r = phase_l + phase_kill;
-//        while(phase_l >= SINE16LENGTH) {
-//            phase_l -= SINE16LENGTH;
-//        }
-//
-//        while(phase_r >= SINE16LENGTH) {
-//            phase_r -= SINE16LENGTH;
-//        }
-//        while(phase_r< 0) phase_r += SINE16LENGTH;
-//    }
-//    i2s.write(minibuf, to_write);
-//}
+
+void play(void)
+{
+    int to_write = i2s.max_fifo_points() - (i2s.fifo_points());
+    for(int i = 0; i < to_write; i+=2) {
+        minibuf[i] = (int)sine16lookup[(SINE16LENGTH - 1) &( phase_l+skipper)];
+        minibuf[i+1] = (int)sine16lookup[(SINE16LENGTH - 1) & (phase_r+skipper)];
+    }
+    i2s.write(minibuf, to_write);
+}
+
 Serial pc(USBTX,USBRX);
+
 /* main */
 int main()
 {
     pc.baud(115200);
-    pc.printf("printf\n\r");
-    // skipper = (aIn*49)+1;
+    skipper = pot1.read_u16() >> 8;
+    volume = pot2.read_u16() >> 10;
+    phase_l = 0;
+    phase_r = 512;
 
-    // codec.power(true);
+//     codec.power(true);
     // codec.frequency(SAMPLERATE);
     // codec.wordsize(16);
     // codec.master(false);
     // codec.headphone_volume(0.5);
-    // codec.start();
+//     codec.start();
 
-    // i2s.frequency(SAMPLERATE);
-    // i2s.wordsize(16);
-    // i2s.stereomono(I2S_STEREO);
-    // i2s.masterslave(I2S_MASTER);
-    // i2s.attach(&play);
-    // i2s.start();
-    while(1)
-    {
+    i2s.frequency(SAMPLERATE);
+    i2s.wordsize(16);
+    i2s.stereomono(I2S_STEREO);
+    i2s.masterslave(I2S_MASTER);
+    i2s.attach(&play);
+    i2s.start();
+
+    while(1){
+        wait_ms(500);
+        pc.printf(".");
+    }
+    while(1) {
         pc.printf(".");
         wait_ms(500);
-        // skipper = (aIn*30)+1;
-
-        // volume = 1;
-        // phase_kill = (vol - 0.5) * 400;
+        skipper = pot1.read_u16() >> 8;
+        volume = pot2.read_u16() >> 10; // 6-bit unsigned int
+//        codec.headphone_volume((int)(volume));
 
-        // printf("Skipper:%f, %i, %i\n\r",skipper, to_write,i2s.fifo_level());
-        /*if(flag)
-        {
-        printf(".");
-        flag = false;
-        }*/
+        lcd.locate(0,3);
+        lcd.printf("Volume: %+03d", (volume - 57));
+        lcd.locate(0,15);
+        lcd.printf("Skipper: %04d", skipper);
+
     }
 
 }
-// #include "C12832.h"
-//
-// C12832 lcd(D11, D13, D12, D7, D10);
-//
-// AnalogIn pot1 (A0);
-// AnalogIn pot2 (A1);
-//
-// int main()
-// {
-//     while(1) {
-//         lcd.cls();
-//         lcd.locate(0,3);
-//         lcd.printf("Pot 1 = %.2f", (float)pot1);
-//         lcd.locate(0,14);
-//         lcd.printf("Pot 2 = %.2f", (float)pot2);
-//         wait(0.1);
-//     }
-// }
--- a/mbed.bld	Mon Apr 24 17:47:00 2017 +0000
+++ b/mbed.bld	Mon Jun 05 16:25:29 2017 +0000
@@ -1,1 +1,1 @@
-https://mbed.org/users/mbed_official/code/mbed/builds/97feb9bacc10
\ No newline at end of file
+https://mbed.org/users/mbed_official/code/mbed/builds/794e51388b66
\ No newline at end of file