Takahiro Tanaka / Mbed 2 deprecated mbed_effector

Dependencies:   C12832 mbed

Files at this revision

API Documentation at this revision

Comitter:
vaifreak
Date:
Sat Aug 15 05:24:39 2015 +0000
Child:
1:bfbfd6fede05
Commit message:
08/15

Changed in this revision

C12832.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/C12832.lib	Sat Aug 15 05:24:39 2015 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/chris/code/C12832/#7de323fa46fe
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Aug 15 05:24:39 2015 +0000
@@ -0,0 +1,79 @@
+#include "mbed.h"
+#include "C12832.h"
+
+C12832 lcd(p5, p7, p6, p8, p11);
+
+//    lcd.cls();
+//    lcd.locate(0,3);
+//    lcd.printf("Analog In Out test.");
+
+Ticker sampling;
+AnalogIn Ain(p17);
+AnalogOut Aout(p18);
+
+/*******************************/
+/* For Test Signal */
+/*******************************/
+#define TEST_SIGNAL_ENABLE (0) // 1 : InternalSinWave for Debug
+#define TEST_SIGNAL_FREQ (1000.0) // Frequency [Hz]
+#define TEST_SIGNAL_AMP (30000.0) // Amplitude
+#define PAI (3.14159)
+
+/*******************************/
+/* For ADC & DAC Setting */
+/*******************************/
+#define SAMPLING_TIME (25.0) // ADC Sampling Rate [us]
+
+volatile unsigned int *g_usiAd0cr, *g_usiAd0dr2; // ADC Reg
+unsigned int *g_usiDacr; // DAC Reg
+unsigned int g_usiFinalOut;
+short g_ssBuff;
+float g_fTestWaveT;
+
+/*******************************/
+/* Effect Process */
+/*******************************/
+void effectProcess() 
+{
+    // Line Out & In
+    *g_usiDacr = g_usiFinalOut;
+    // ADC Start
+    *g_usiAd0cr = 0x01200204;
+    
+#if (TEST_SIGNAL_ENABLE == 1) // Test Signal Sin Wave
+    g_ssBuff = TEST_SIGNAL_AMP * sin(g_fTtestWaveT) - 32768;
+    g_fTestWaveT = g_fTestWaveT + 2.0 * PAI * SAMPLING_TIME * TEST_SIGNAL_FREQ / 1e6;
+    if(g_fTestWaveT >= (2.0 * PAI))g_fTestWaveT = 0;
+#endif
+
+    //
+    // Effect Func();
+    //
+
+#if (TEST_SIGNAL_ENABLE == 0)
+    while(1){
+        if((*g_usiAd0dr2 & 0x80000000) != 0)break; // ADC Finish ?
+    }
+    g_ssBuff = (short)((int)(*g_usiAd0dr2 & 0x0000FFF0) - 32768);
+#endif
+
+    g_usiFinalOut = 0x00010000 | (unsigned int)((int)g_ssBuff + 32768);
+}
+
+
+/*******************************/
+/* MAIN */
+/*******************************/
+int main() {
+
+    g_usiAd0cr = (unsigned int*)0x40034000;
+    g_usiAd0dr2 = (unsigned int*)0x40034018;
+    g_usiDacr = (unsigned int*)0x4008C000;
+    sampling.attach_us(&effectProcess, SAMPLING_TIME);
+
+    while(1){
+    //
+    // Parameter Setting Func()
+    //
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Aug 15 05:24:39 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/cd19af002ccc
\ No newline at end of file