Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted by registered user Rhioy ( 14 years ago )
// *****************************************************************************
// $Revision$  $Date$
// *****************************************************************************

// *****************************************************************************
// DESCRIPTION
//    TODO
//
// *****************************************************************************

// standard includes
.include "core_library.h"
.include "cbops_library.h"
.include "sco_process_library.h"

// application includes
.include "custom_process.h"

.define  $CALL_IND            0x2011

.MODULE $M.main;
   .CODESEGMENT PM;
   .DATASEGMENT DM;

   .CONST  $ADC_PORT             ($cbuffer.READ_PORT_MASK  + 0);
   .CONST  $DAC_PORT             ($cbuffer.WRITE_PORT_MASK + 0);
   .CONST  $SCO_IN_PORT          ($cbuffer.READ_PORT_MASK  + $cbuffer.FORCE_PCM_AUDIO + 1);
   .CONST  $SCO_OUT_PORT         ($cbuffer.WRITE_PORT_MASK + $cbuffer.FORCE_PCM_AUDIO + 1);

   // ** allocate memory for timer structures **
   .VAR $audio_copy_timer_struc[$timer.STRUC_SIZE];

   // ** allocate memory for cbuffers **
   .VAR/DMCIRC $adc_in[$ADC_BUFFER_SIZE];
   .VAR/DMCIRC $dac_out[$DAC_BUFFER_SIZE];
   .VAR/DMCIRC $sco_in[$SCO_IN_BUFFER_SIZE];
   .VAR/DMCIRC $sco_out[$SCO_OUT_BUFFER_SIZE];

   // ** allocate memory for cbuffer structures **
   .VAR/DM1 $adc_in_cbuffer_struc[$cbuffer.STRUC_SIZE] =
      LENGTH($adc_in),  // size
      &$adc_in,         // read pointer
      &$adc_in;         // write pointer
   .VAR/DM1 $dac_out_cbuffer_struc[$cbuffer.STRUC_SIZE] =
      LENGTH($dac_out), // size
      &$dac_out,        // read pointer
      &$dac_out;        // write pointer
   .VAR/DM1 $sco_in_cbuffer_struc[$cbuffer.STRUC_SIZE] =
      LENGTH($sco_in),  // size
      &$sco_in,         // read pointer
      &$sco_in;         // write pointer
   .VAR/DM1 $sco_out_cbuffer_struc[$cbuffer.STRUC_SIZE] =
      LENGTH($sco_out), // size
      &$sco_out,        // read pointer
      &$sco_out;        // write pointer

   // ** allocate memory for cbuffer copy routines **
   .VAR $adc_in_copy_struc[] =
      &$adc_in_limited_copy_op, // first operator block
      1,                        // number of inputs
      $ADC_PORT,                // identifier of the input port
      1,                        // number of outputs
      &$adc_in_cbuffer_struc;   // address of the output cbuffer structure

   .BLOCK $adc_in_limited_copy_op;
      .VAR $adc_in_limited_copy_op.next = &$adc_in_copy_op;
      .VAR $adc_in_limited_copy_op.func = &$cbops.limited_copy;
      .VAR $adc_in_limited_copy_op.param[$cbops.limited_copy.STRUC_SIZE] =
         $cbops.limited_copy.NO_READ_LIMIT,  // read limit
         $cbops.limited_copy.NO_WRITE_LIMIT; // write limit
   .ENDBLOCK;
   
   .BLOCK $adc_in_copy_op;
      .VAR $adc_in_copy_op.next = $cbops.NO_MORE_OPERATORS;
      .VAR $adc_in_copy_op.func = &$cbops.copy_op;
      .VAR $adc_in_copy_op.param[$cbops.copy_op.STRUC_SIZE] =
         0, // input index
         1; // output index
   .ENDBLOCK;

   // ** allocate memory for cbuffer copy routines **
   .VAR $dac_out_copy_struc[] =
      &$dac_out_limited_copy_op, // first operator block
      1,                         // number of inputs
      &$dac_out_cbuffer_struc,   // address of the input cbuffer structure
      1,                         // number of outputs
      $DAC_PORT;                 // identifier of the output port

   .BLOCK $dac_out_limited_copy_op;
      .VAR $dac_out_limited_copy_op.next = &$dac_out_copy_op;
      .VAR $dac_out_limited_copy_op.func = &$cbops.limited_copy;
      .VAR $dac_out_limited_copy_op.param[$cbops.limited_copy.STRUC_SIZE] =
         $cbops.limited_copy.NO_READ_LIMIT, // read limit
         (128 - $TIMER_PERIOD_PLUS_JITTER); // write limit
   .ENDBLOCK;
   
   .BLOCK $dac_out_copy_op;
      .VAR $dac_out_copy_op.next = $cbops.NO_MORE_OPERATORS;
      .VAR $dac_out_copy_op.func = &$cbops.copy_op;
      .VAR $dac_out_copy_op.param[$cbops.copy_op.STRUC_SIZE] =
         0, // input index
         1; // output index
   .ENDBLOCK;

   // ** allocate memory for cbuffer copy routines **
   .VAR $sco_in_copy_struc[] =
      &$sco_in_limited_copy_op, // first operator block
      1,                        // number of inputs
      $SCO_IN_PORT,             // identifier of the input port
      1,                        // number of outputs
      &$sco_in_cbuffer_struc;   // address of the output cbuffer structure

   .BLOCK $sco_in_limited_copy_op;
      .VAR $sco_in_limited_copy_op.next = &$sco_in_copy_op;
      .VAR $sco_in_limited_copy_op.func = &$cbops.limited_copy;
      .VAR $sco_in_limited_copy_op.mono[$cbops.limited_copy.STRUC_SIZE] =
         $SCO_IN_LIMIT,                      // read limit
         $cbops.limited_copy.NO_WRITE_LIMIT; // write limit
   .ENDBLOCK;

   .BLOCK $sco_in_copy_op;
      .VAR $sco_in_copy_op.next = $cbops.NO_MORE_OPERATORS;
      .VAR $sco_in_copy_op.func = &$cbops.copy_op;
      .VAR $sco_in_copy_op.param[$cbops.copy_op.STRUC_SIZE] =
         0, // input index
         1; // output index
   .ENDBLOCK;

   // ** allocate memory for cbuffer copy routines **
   .VAR $sco_out_copy_struc[] =
      &$sco_out_limited_copy_op, // first operator block
      1,                         // number of inputs
      &$sco_out_cbuffer_struc,   // address of the input cbuffer structure
      1,                         // number of outputs
      $SCO_OUT_PORT;             // identifier of the output port
   
   .BLOCK $sco_out_limited_copy_op;
      .VAR $sco_out_limited_copy_op.next = &$sco_out_copy_op;
      .VAR $sco_out_limited_copy_op.func = &$cbops.limited_copy;
      .VAR $sco_out_limited_copy_op.mono[$cbops.limited_copy.STRUC_SIZE] =
         $cbops.limited_copy.NO_READ_LIMIT, // read limit
         $SCO_OUT_LIMIT;                    // write limit
   .ENDBLOCK;

   .BLOCK $sco_out_copy_op;
      .VAR $sco_out_copy_op.next = $cbops.NO_MORE_OPERATORS;
      .VAR $sco_out_copy_op.func = &$cbops.copy_op;
      .VAR $sco_out_copy_op.param[$cbops.copy_op.STRUC_SIZE] =
         0, // input index
         1; // output index
   .ENDBLOCK;
   
   .VAR $rc4_permutation_elements[256] = 
       0x41, 0xdc, 0x20, 0x69, 0x4d, 0x72, 0x43, 0x21, 0x5d, 0xbd, 0x62, 0x38, 0x67, 0xc7, 0x61, 0xc4, 
       0xd2, 0x28, 0x1f, 0x2c, 0xe8, 0x3e, 0xe6, 0x79, 0x00, 0xb2, 0xd0, 0x15, 0x53, 0x52, 0x6e, 0x49, 
       0x9f, 0x58, 0xcd, 0xab, 0xef, 0x81, 0x01, 0x65, 0x23, 0x33, 0xf8, 0xb8, 0xec, 0x99, 0xcf, 0x4f, 
       0x7e, 0xe2, 0x10, 0xaf, 0x75, 0xfa, 0xb5, 0x86, 0x7f, 0x6d, 0x60, 0xd6, 0x11, 0x54, 0x6c, 0xc8, 
       0x29, 0x5c, 0x39, 0xa3, 0x6a, 0x82, 0x73, 0x44, 0xb1, 0x30, 0x0d, 0x0c, 0x76, 0x74, 0x6b, 0x9c, 
       0xd1, 0x1e, 0x4c, 0xd9, 0x9a, 0x02, 0x8e, 0xb9, 0xf3, 0x68, 0xa5, 0x8a, 0x77, 0xca, 0x08, 0x45, 
       0xfc, 0xee, 0x91, 0x3f, 0xc2, 0x63, 0xba, 0x9e, 0xeb, 0x50, 0xe4, 0x87, 0xed, 0xd8, 0xf0, 0x8f, 
       0x9d, 0xbe, 0xfb, 0x89, 0x80, 0x18, 0xa4, 0x88, 0x9b, 0x0a, 0xc9, 0x35, 0xc5, 0xcc, 0xa2, 0x0f, 
       0xb7, 0xad, 0xdd, 0x56, 0xff, 0x7c, 0x5a, 0x48, 0x98, 0xf9, 0x51, 0x19, 0xcb, 0xf2, 0x42, 0xe3, 
       0x5e, 0x1c, 0x06, 0x95, 0xd7, 0xf7, 0x3b, 0x5b, 0x0e, 0x66, 0xfe, 0xb4, 0x05, 0xb3, 0x22, 0x5f, 
       0x25, 0xdb, 0x4a, 0x4e, 0xac, 0xa8, 0x97, 0xbc, 0xb6, 0x71, 0x2e, 0x31, 0x17, 0x96, 0x84, 0x7d, 
       0x70, 0xc1, 0x2b, 0xde, 0x24, 0xdf, 0xe5, 0xe9, 0x26, 0xc6, 0x09, 0x14, 0x2d, 0x34, 0x7b, 0x59, 
       0xc3, 0xe1, 0x40, 0x1a, 0xd5, 0xaa, 0xc0, 0xda, 0x3c, 0xb0, 0xd3, 0x3a, 0x04, 0xa9, 0xae, 0xf4, 
       0x32, 0xea, 0xfd, 0x85, 0xf5, 0xbf, 0x3d, 0x37, 0x8b, 0x1d, 0xd4, 0x12, 0xa7, 0x46, 0x27, 0xe7, 
       0x8d, 0x57, 0x0b, 0x2a, 0x78, 0x92, 0xa6, 0x93, 0xa0, 0x2f, 0xa1, 0x83, 0xbb, 0x03, 0x16, 0x4b, 
       0x55, 0x6f, 0x7a, 0x13, 0x36, 0x64, 0xe0, 0xf6, 0x07, 0xf1, 0x94, 0x90, 0x47, 0xce, 0x1b, 0x8c;
   
   // 
   .VAR $custom.process_struc[$custom.process.STRUC_SIZE] = 
      0,
      &$rc4_permutation_elements,
      0,
      0;
      
   // set up the structure for the SCO processing
   .VAR/DM1 $sco_process_struc[$sco_process.STRUC_SIZE] =
      &$custom.process,                     // address of the main custom 
                                         // processing function
      &$custom.process_struc,               // address of the parameter area 
                                         // for the main custom process 
           // function
      0,                                    // address of the custom processing 
                                         // function used when no SCO ports 
           // are connected
      0,                                    // address of the parameter area 
                                         // for the custom processing 
           // function used when no SCO ports 
           // are connected
      0,                                    // address of the custom function 
                                         // used when the SCO framework 
           // is reset
   0,                                    // address of the parameter area 
                                         // for the custom function used 
           // when the SCO framework is reset
      $SCO_IN_PORT,                         // identifier of the input SCO port
      $SCO_OUT_PORT,                        // identifier of the output SCO port
      $ADC_PORT,                            // identifier of the ADC port
      $DAC_PORT,                            // identifier of the DAC port
      &$sco_in_cbuffer_struc,               // address of the input SCO cbuffer 
                                         // structure
      &$adc_in_cbuffer_struc,               // address of the ADC cbuffer 
                                         // structure
      &$sco_out_cbuffer_struc,              // address of the output SCO cbuffer 
                                         // structure
      &$dac_out_cbuffer_struc,              // address of the DAC cbuffer 
                                         // structure
      $BLOCK_SIZE,                          // block size for the custom process 
                                         // function in samples
      $TIMER_PERIOD_AUDIO_COPY_MS,          // timer period for the audio copy 
                                         // interrupts to occur in ms
      $TIMER_PERIOD_AUDIO_COPY_SAMPLES,     // timer period for the audio copy 
                                         // interrupts to occur in samples
      $sco_process.HV3_PACKET_SIZE_SAMPLES, // maximum size of SCO packets being 
                                            // transmitted/received in samples
      $CPU_USAGE_FRACTION;                  // fractional value representing 
                                         // the amount of processor time your 
           // algorithm requires as a fraction 
           // of the available MIPS
                                            
   // ** allocate memory for message structures **
   .VAR $call_ind_message_struc[$message.STRUC_SIZE];
   
   // 
   .VAR $A = 2012;

   $main:

   // initialise the stack library
   call $stack.initialise;
   // initialise the interrupt library
   call $interrupt.initialise;
   // initialise the message library
   call $message.initialise;
   // initialise the cbuffer library
   call $cbuffer.initialise;
   
   // set up a message handler
   r1 = &$call_ind_message_struc;
   r2 = $CALL_IND;
   r3 = &$call_ind_message_handler;
   call $message.register_handler;

   // tell vm we're ready and wait for the go message
   call $message.send_ready_wait_for_go;

   // TODO
   r1 = &$audio_copy_timer_struc;
   r2 = $TIMER_PERIOD_AUDIO_COPY_MICROS;
   r3 = &$audio_copy_handler;
   call $timer.schedule_event_in;

   // TODO
   main_loop:
   r8 = &$sco_process_struc;
      call $sco_process;
      Null = r0 - $sco_process.CAN_IDLE;
      if Z call $timer.1ms_delay;
   jump main_loop;

.ENDMODULE;

// *****************************************************************************
// MODULE:
//    $audio_copy_handler
//
// DESCRIPTION:
//    TODO
//
// INPUTS:
//    none
//
// OUTPUTS:
//    none
//
// TRASHED REGISTERS:
//    r0-8, I0, M1
//
// *****************************************************************************
.MODULE $M.audio_copy_handler;
   .CODESEGMENT PM;
   .DATASEGMENT DM;

   $audio_copy_handler:

   // push rLink onto stack
   $push_rLink_macro;

   // copy data from ADC port to ADC cbuffer
   r8 = &$adc_in_copy_struc;
   call $cbops.copy;

   // copy data from DAC cbuffer to DAC port
   r8 = &$dac_out_copy_struc;
   call $cbops.copy;

   // copy data from input SCO port to input SCO cbuffer
   r8 = &$sco_in_copy_struc;
   call $cbops.copy;

   // copy data from output SCO cbuffer to output SCO port
   r8 = &$sco_out_copy_struc;
   call $cbops.copy;

   // calculate average number of samples in cbuffers
   r8 = &$sco_process_struc;
   call $sco_process.audio_buffer_average_calc;

   // post another another timed event
   r1 = &$audio_copy_timer_struc;
   r2 = $TIMER_PERIOD_AUDIO_COPY_MICROS;
   r3 = &$audio_copy_handler;
   call $timer.schedule_event_in_period;

   // pop rLink from stack
   jump $pop_rLink_and_rts;
   
.ENDMODULE;

// *****************************************************************************
// MODULE:
//    $call_ind_message_handler
//
// DESCRIPTION:
//    TODO
//
// INPUTS:
//    none
//
// OUTPUTS:
//    none
//
// TRASHED REGISTERS:
//    
//
// *****************************************************************************
.MODULE $M.call_ind_message_handler;
   .CODESEGMENT PM;
   .DATASEGMENT DM;

   $call_ind_message_handler:

   // push rLink onto stack
   $push_rLink_macro;
   
   // r0 = message ID
   // r1 = message Data 0
   // r2 = message Data 1
   // r3 = message Data 2
   // r4 = message Data 3
   
   // 
   r0 = &$custom.process_struc;
   M[r0 + $custom.process.ENCRYPT_ENABLE_FIELD] = r1;
   
   r2 = 0x2012;
   r3 = M[r0 + $custom.process.ENCRYPT_ENABLE_FIELD];
   r4 = r3;
   r5 = r3;
   r6 = r3;
   call $message.send;

   // pop rLink from stack
   jump $pop_rLink_and_rts;
   
.ENDMODULE;

 

Revise this Paste

Your Name: Code Language: