Exemplo n.º 1
0
/**
 * DSP command loop
 * @return MCAPI_SUCCESS/ error code
 */
mcapi_status_t dsp_command_loop(void) {
FILE *fp1;
uint32_t FrameNumber = 0;

  mcapi_status_t status = MCAPI_ERR_GENERAL;
  mcapi_uint32_t command = DSP_READY,nCurrContourCount=0;
  mcapi_uint32_t rx_size = 0;
  MT9M114_VIDEO_BUF *pVideoBuff;
  uint32_t *pTemp = (uint32_t *)&buffer[0];

  while (command != DSP_TERMINATE) {
    status = receive_dsp_cmd(&command);
#ifdef DEBUG_INFO
    if (MCAPI_SUCCESS != status) {
      fprintf(stdout, "[%s] %d status: %d receive_dsp_cmd failure\n", __FILE__,
          __LINE__, status);
      exit(1);
    }
#endif
    switch (command) {
    case DSP_DATA:
#ifdef DEBUG_INFO
      printf("[CORE B]: Received command (DSP_DATA)\n");
#endif
      status = receive_dsp_data(buffer, &rx_size);
#ifdef DEBUG_INFO
      if (MCAPI_SUCCESS != status) {
        fprintf(stdout, "[%s] %d status: %d receive_dsp_data failure\n",
            __FILE__, __LINE__, status);
        exit(1);
      }
#endif
#ifdef DEBUG_INFO
      printf("[CORE B]: Received data\n");
#endif
      break;

    case DSP_CODE:
#ifdef DEBUG_INFO
      printf("[CORE B]: Received command (DSP_CODE)\n");
#endif
      break;

    case DSP_INIT:
      /* Tell DSP to Execute – Assume code writes to result_buffer */
#ifdef DEBUG_INFO
      printf("[CORE B]: Received command (DSP_INIT)\n");
#endif
      InitTitle((void*)(*pTemp));
#ifdef DEBUG_INFO
      printf("[CORE B]: Processing complete\n");
      printf("[CORE B]: Sending data\n");
#endif
      status = send_dsp_data(buffer, rx_size);
#ifdef DEBUG_INFO
      if (MCAPI_SUCCESS != status) {
        fprintf(stdout, "[%s] %d status: %d send_dsp_data failure\n", __FILE__,
            __LINE__, status);
        exit(1);
      }
#endif
#ifdef DEBUG_INFO
      printf("[CORE B]: Sending data complete\n");
#endif
      break;

    case DSP_GFXCONTOUR:
      /* Tell CORE B to find contour & update dot count */
#ifdef DEBUG_INFO
      printf("[CORE B]: Received command (DSP_GFXCONTOUR)\n");
#endif
      pGFxBuff =(VIDEO_BUF *) pInfo->pBuf2;
      if(pInfo->pBuf1 != NULL)
      {
        if((nCurrContourCount = ADI_FindContours(pInfo->pBuf1, pInfo->nWidth,pInfo->nHeight))!= 0XFFFFFFFF)
        {
        	CONTOURCount =nCurrContourCount;
#if 0
// EMG start
   if( (FrameNumber++ > 20) && (CONTOURCount != 72) )
   {
	   // Moved here for dropbox indication
       fp1=fopen( "FindContours.dat","wb");
       printf( "Capturing data - \n" );
       fwrite( pInfo->pBuf1, 1, (720*480), fp1);
       fclose(fp1);
       printf( "Data Captured\n" );
       while(1);
   }
// EMGend
#endif
        }

      }
#if defined(BF609_VSK_SHOW_LIGHTING_ON_MONITOR)
      Illumination = pInfo->nIllumination;
#endif	  
      update_contour_count();
      /* Mark the buffer valid for submitting to display.*/
  	  pVideoBuff =  (MT9M114_VIDEO_BUF *)pInfo->pBuf2;
	  pVideoBuff->eStatus = CONTOUR_COUNT_BUFFER_READY;
      pInfo->nCompletionFlag = 1; /* to indicate that core B has completed processing */
#ifdef DEBUG_INFO
      printf("[CORE B]: Processing complete\n");
      printf("[CORE B]: Sending data\n");
#endif
      status = send_dsp_data(buffer, rx_size);
#ifdef DEBUG_INFO
      if (MCAPI_SUCCESS != status) {
        fprintf(stdout, "[%s] %d status: %d send_dsp_data failure\n", __FILE__,
            __LINE__, status);
        exit(1);
      }
#endif
#ifdef DEBUG_INFO
      printf("[CORE B]: Sending data complete\n");
#endif
      break;

    case DSP_TERMINATE:
#ifdef DEBUG_INFO
      printf("[CORE B]: Received command (DSP_TERMINATE)\n");
#endif
      status = dsp_shutdown();
#ifdef DEBUG_INFO
      if (MCAPI_SUCCESS != status) {
        fprintf(stdout, "[%s] %d status: %d dsp_shutdown failure\n", __FILE__,
            __LINE__, status);
        exit(1);
      }
#endif
      break;
    default:
      break;
    }
  }

  return status;
}
Exemplo n.º 2
0
static void _shutdown() {
    printf("Shutting down...\n");
    shutdown_requested = 1;     /* Stop listening to the network */
    dsp_shutdown();             /* Terminate the event dispatcher thread */
    bnd_destroy();              /* Destroy the binding table */
}