First Publish. Works fine.

Dependents:   unzen_sample_lpcxpresso_4337_callbacks

Revision:
12:5e73a102d809
Parent:
11:5f91f55065c1
Child:
13:845ba6aa3449
--- a/unzen.h	Sun May 08 09:56:29 2016 +0000
+++ b/unzen.h	Thu May 12 22:13:04 2016 +0000
@@ -22,11 +22,11 @@
         };
     
     /**
-      \brief singleton style audio frame work. Create a object and execute the \ref framework::start() method.
+      \brief adio frame work. Create a object and execute the \ref framework::start() method.
     */
     class Framework 
     {
-    private:
+    public:
             /**
                 \constructor
                 \details
@@ -40,14 +40,6 @@
                 as 1. If it is needed to use other value, call \ref set_brock_size() method. 
             */
         Framework(void);
-    public:
-            /**
-                \brief getting the singleton object for processing.
-                \returns a framework type object.
-                \details
-                TO call the object method, use this method to retrieve the singleton object.
-            */
-        static Framework * get() { static Framework singleton; return &singleton ; }
         
             /**
                 \brief set the interval interrupt count for each time call back is called. 
@@ -61,38 +53,34 @@
         
             /**
                 \brief  the real audio signal transfer. Trigger the I2S interrupt and call the call back.
-                */
-        void start(void);
-
-            /**
-                \brief Set the user call back for audio processing.
-                \param cb The call back function
+                \param init_cb initializer call back for signal processing. This is invoked only once before processing. Can be NUL
+                \param process_cb The call back function
                 \details
-                Set the call back function. This function is called for each time the rx buffer is filled. The call back has 5 parameters.
+                Set the call back function, then start the transer on I2S
+                
+                Before the real data transaction on I2S, this method call init_cb(int) call back. The 
+                parameter is block size (>0) which is set by set_block_size() method. If the init_cb is NUL,
+                this part is skipped. 
+                
+                This process_cb function is called for each time the rx buffer is filled. The call back has 5 parameters.
                 \li left_rx  Received data from I2S rx port. Left data only. 
                 \li right_rx Received data from I2S rx port. Right data only.
                 \li left_tx  Buffer to fill the transmission data. This buffer mus be filled by call back. Left data only
                 \li right_tx Buffer to fill the transmission data. This buffer mus be filled by call back. Right data only
                 \li length   length of above buffers.
                 
-                The call back is called for each time interrupt comes n times. Where n is the value which is specified by \ref set_block_size() 
+                The process call back is called for each time interrupt comes n times. Where n is the value which is specified by \ref set_block_size() 
                 function. This n is also passed to call back as above length parameter. By default, n is 1.
                 
                 Note that the call back is called at interrupt context. Not the thread level context.
                 That mean, it is better to avoid to call mbed API except the mbed-RTOS API for interrupt handler.
-                 
-            */
-        void set_process_callback( void (* cb ) (float[], float[], float[], float[], unsigned int));
-        
-            /**
-                \brief Debug hook for interrupt handler. 
-                \param cb A call back which is called at the beggining of I2S interrupt.
-                \details
-                Parameter cb is call at the beggining of the I2S interrupt. This call back can be 
-                used to mesure the timing of interrupt by toggling the GPIO pin.
-                
-                Passing 0 to cb parameter let the framwork ignore the callback.
-            */
+                */
+        void start(
+                void (* init_cb ) (unsigned int),
+                void (* process_cb ) (float[], float[], float[], float[], unsigned int)
+                );
+
+
         void set_pre_interrupt_callback( void (* cb ) (void));
         
             /**
@@ -159,7 +147,9 @@
 
             */
         void set_process_irq_priority( unsigned int pri );
-        
+
+    private:        
+        static Framework * _fw;
     private:
         void (* _pre_interrupt_callback )(void);
         void (* _post_interrupt_callback )(void);