First Publish. Works fine.

Dependents:   unzen_sample_lpcxpresso_4337_callbacks

Revision:
12:5e73a102d809
Parent:
11:5f91f55065c1
--- a/unzen.cpp	Sun May 08 09:56:29 2016 +0000
+++ b/unzen.cpp	Thu May 12 22:13:04 2016 +0000
@@ -8,6 +8,8 @@
 {
     Framework::Framework()
     {
+            // setup handle for the interrupt handler
+        Framework::_fw = this;
 
             // Clear all buffers        
         _tx_int_buffer[0] = NULL;
@@ -31,6 +33,7 @@
         _post_process_callback = NULL;
         
         _process_callback = NULL;
+
         
             // Initialy block(buffer) size is 1.
         set_block_size( 1 );
@@ -132,8 +135,18 @@
         return no_error;
     }
 
-    void Framework::start()
+    void Framework::start(
+                    void (* init_cb ) (unsigned int),
+                    void (* process_cb ) (float[], float[], float[], float[], unsigned int)
+                    )
     {
+            // if needed, call the initializer
+        if ( init_cb )
+            init_cb( _block_size );
+            
+            // register the signal processing callback
+        _process_callback = process_cb;
+        
             // synchronize with Word select signal, to process RX/TX as atomic timing.
         hal_i2s_pin_config_and_wait_ws();
         hal_i2s_start();
@@ -142,18 +155,11 @@
     void Framework::set_i2s_irq_priority( unsigned int pri )
     {
         NVIC_SetPriority(hal_get_process_irq_id(), pri);  // must be higher than PendSV of mbed-RTOS
-        
     }
     
     void Framework::set_process_irq_priority( unsigned int pri )
     {
         NVIC_SetPriority(hal_get_i2s_irq_id(), pri);      // must be higher than process IRQ
-
-    }
-
-    void Framework::set_process_callback( void (* cb ) (float[], float[], float[], float[], unsigned int))
-    { 
-        _process_callback = cb;
     }
 
     void Framework::set_pre_interrupt_callback( void (* cb ) (void))
@@ -279,16 +285,16 @@
     
     void Framework::_process_irq_handler()
     {
-        Framework::get()->_do_process_irq();
+        Framework::_fw->_do_process_irq();
     }
     
     void Framework::_i2s_irq_handler()
     {
-        Framework::get()->_do_i2s_irq();
+        Framework::_fw->_do_i2s_irq();
     }
      
      
-     
+    Framework * Framework::_fw; 
  
 }
     
\ No newline at end of file