/*                                                                          */
/* Function    : define utilities to cyclic buffers                         */
/*                                                                          */
/*  Available routines:                                                     */
/*                                                                          */

#include  "windef.h"
#include  "mbdr_dsp_numbers.h"
#include  "mbdr_dsp_utils.h"

void mbdr_dsp_utils_poll_dw_with_wait(
                     volatile LONG *pi_poll_dw_p,
                     LONG           pi_poll_dw_value,
                     LONG           pi_wait_cycles_between_read_access)
{/* mbdr_dsp_utils_poll_dw_with_wait */

  while(*pi_poll_dw_p != pi_poll_dw_value)
       mbdr_dsp_utils_nop_wait(pi_wait_cycles_between_read_access);

}/* mbdr_dsp_utils_poll_dw_with_wait */

void mbdr_dsp_utils_nop_wait(LONG pi_wait_cycles)
{/* mbdr_dsp_utils_nop_wait */
  register LONG done_loop_cycles, cycles_per_loop;
  cycles_per_loop = MBDR_DSP_32;
  done_loop_cycles = 0;

  do
  {

      /* since loop overhead is 8 cycles, 8 nops are being deleted */
      /*asm(" nop "); asm(" nop "); asm(" nop "); asm(" nop "); */
      /*asm(" nop "); asm(" nop "); asm(" nop "); asm(" nop "); */
	  done_loop_cycles += cycles_per_loop;
      asm(" nop 8");
      asm(" nop 8");
      asm(" nop 7");
  }while(done_loop_cycles<pi_wait_cycles);

}/* mbdr_dsp_utils_nop_wait */
