Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
faker
Date:
Sun May 01 12:34:33 2011 +0000
Commit message:

Changed in this revision

Distotion_Unit.cpp Show annotated file Show diff for this revision Revisions of this file
Distotion_Unit.h 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/Distotion_Unit.cpp	Sun May 01 12:34:33 2011 +0000
@@ -0,0 +1,34 @@
+/*****************************************************/
+/*  Distotion_Unit.cpp                               */
+/*                                                   */
+/*****************************************************/
+
+#define     DIST_MAIN
+#include    "Distotion_Unit.h"
+
+#define  inputGain      (1.0)
+#define  clipLevel      (15000)
+#define  outputGain     (1.0)
+
+#define  LIMIT_P        (32767)
+#define  LIMIT_N        (-32768)
+
+int distotion(int iEffectIn) {
+
+    int iSignal;
+
+    // Input Gain
+    iSignal = iEffectIn * inputGain;
+
+    // Clip
+    if (iSignal >= clipLevel)iSignal = clipLevel;
+    if (iSignal <= -clipLevel)iSignal = -clipLevel;
+    
+    // Output Gain
+    iSignal *= outputGain;
+    if (iSignal >= LIMIT_P)iSignal = LIMIT_P;
+    if (iSignal <= LIMIT_N)iSignal = LIMIT_N;
+
+    return iSignal;
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Distotion_Unit.h	Sun May 01 12:34:33 2011 +0000
@@ -0,0 +1,25 @@
+/*****************************************************/
+/*  Distotion_Unit.h                                 */
+/*                                                   */
+/*****************************************************/
+
+#ifndef     _DISTOTIN_UNIT_INCLUDE
+#define     _DISTOTIN_UNIT_INCLUDE
+
+#undef      EXTERN
+#ifdef      DIST_MAIN
+#define     EXTERN
+#else
+#define     EXTERN  extern
+#endif
+
+// Gloval Valinat
+
+
+
+// Function
+
+EXTERN int distotion(int);
+
+#undef     EXTERN
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun May 01 12:34:33 2011 +0000
@@ -0,0 +1,85 @@
+/*****************************************************/
+/* MBED MULTI EFFECTOR                               */
+/*                                                   */
+/*                                                   */
+/*****************************************************/
+
+#include "mbed.h"
+#include "Distotion_Unit.h"
+
+Ticker      sampling;
+AnalogIn    Ain(p17);
+AnalogOut   Aout(p18);
+
+/*******************************/
+/* For Test Signal             */
+/*******************************/
+#define     TEST_SIGNAL_ENABLE      (0)                 // 1 : Internal SinWave 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;
+int                     g_ssBuff[10];
+float                   g_fTestWaveT;
+
+/*******************************/
+/* Effect Process              */
+/*******************************/
+void effectProcess() {
+    // Line Out
+    *g_usiDacr = g_usiFinalOut;
+    // ADC Start
+    *g_usiAd0cr = 0x01200204;
+
+#if (TEST_SIGNAL_ENABLE == 1)           // Test Signal Sin Wave
+    g_ssBuff[0] = TEST_SIGNAL_AMP * sin(g_fTestWaveT);
+    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();
+    //
+    g_ssBuff[1] = distotion(g_ssBuff[0]);
+    //
+    // Effect Func();
+    //
+
+#if (TEST_SIGNAL_ENABLE == 0)
+    while (1) {
+        if ((*g_usiAd0dr2 & 0x80000000) != 0)break; // ADC Done ?
+    }
+    g_ssBuff[0] = (int)(*g_usiAd0dr2 & 0x0000FFF0) - 32768;
+#endif
+
+    g_usiFinalOut = 0x00010000 | (g_ssBuff[1] + 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()
+        //
+
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun May 01 12:34:33 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e