Ejemplo n.º 1
0
int main( void )
{
	// Init the semi-hosting.
	printf( "\n" );

	// DAC/DMA Setup
	NVIC_DisableIRQ( DMA_IRQn);
	InitializeDAC();
	InitializeDMA();

	/* Instantiate queue and semaphores */
	xQueueToneInput = xQueueCreate( DTMF_REQ_QUEUE_SIZE, sizeof( char ) );
	xQueueDMARequest = xQueueCreate( DMA_REQ_QUEUE_SIZE, sizeof( DAC_Setup_Message ));
	xIoQueue = xQueueCreate(16,sizeof(char));
	dacResponseHandle = xQueueCreate( DMA_COMP_QUEUE_SIZE, sizeof( DAC_Complete_Message ) );
	sampQ = xQueueCreate( 1, sizeof(DTMFSampleType *) );
	resultQ = xQueueCreate( 1, sizeof(struct DTMFResult_t) );
	lQueues.xIoInputQueue = xQueueCreate( 2, sizeof(xData) );
	lQueues.xDACQueue =     xQueueToneInput;


	if( sampQ != NULL &&
		resultQ != NULL &&
		xQueueToneInput != NULL &&
		xQueueDMARequest != NULL &&
		dacResponseHandle != NULL &&
		lQueues.xIoInputQueue != NULL &&
		lQueues.xDACQueue != NULL) {

	  xTaskCreate(  vTaskToneGenerator, /* Pointer to the function that implements the task. */
					  "ToneGenerator",          /* Text name for the task.  This is to facilitate debugging only. */
					  240,                      /* Stack depth in words. */
					  NULL,                     /* No input data */
					  configMAX_PRIORITIES-2,                        /* This task will run at priority 1. */
					  NULL );                   /* We are not using the task handle. */

	  #ifdef TONEGEN_INPUT_UNIT_TEST
	    xTaskCreate( vTaskToneRequestTest, "ToneRequestTest", 240, NULL, configMAX_PRIORITIES-2/*4*/, NULL );
	  #endif

	  #ifdef  TONEGEN_DMA_UNIT_TEST
	    xTaskCreate( vTaskDMAHandlerTest, "DMAHandlerTest", 240, NULL, 2, NULL );
	  #else
	    //============================================================================
	    // Create DAC and DMA Tasks
	    //============================================================================
	    xTaskCreate(  DAC_Handler,/* Pointer to the function that implements the task. */
						"DAC",            /* Text name for the task.  This is to facilitate debugging only. */
						240,              /* Stack depth in words. */
						(void*)xQueueDMARequest, /* Pass the text to be printed in as the task parameter. */
						configMAX_PRIORITIES-1,           /* This task will run at highest priority. */
						NULL );           /* We are not using the task handle. */

	    #endif

		xTaskCreate(	vAdcTask,
						"tADC",
						240,
						(void *)sampQ,
						2,
						NULL );

#ifdef __DTMF_PERF__
		TestBenchTaskParam.sampQ = sampQ;
		TestBenchTaskParam.resultQ = resultQ;
		xTaskCreate(	vTestBenchTask,
						"tTB",
						500,
						(void *)&TestBenchTaskParam,
						3,
						NULL );
#endif

		DTMFDetectTaskParam.sampQ = sampQ;
		DTMFDetectTaskParam.resultQ = resultQ;
		xTaskCreate(	vDTMFDetectTask,
						"tDetect",
						500,
						(void *)&DTMFDetectTaskParam,
						configMAX_PRIORITIES-3,
						NULL );

		xTaskCreate( uart_tx_handler, "Tx Task", 500, NULL, 2, NULL );
		xTaskCreate( uart_rx_handler, "Rx Task", 500, NULL, 2, NULL );
		uart_configure();



		/* Create four instances of the task that will write to the queue */
		xTaskCreate( gpioInterfaceTask, "Keypad_Task", 240, &xIoQueue, configMAX_PRIORITIES-1, NULL);
		xTaskCreate( vIoRxTask, "IO_Receiver", 240, NULL, configMAX_PRIORITIES-1, NULL );

		/* Start the scheduler so our tasks start executing. */
		vTaskStartScheduler();
	}

	/* If all is well we will never reach here as the scheduler will now be
	running.  If we do reach here then it is likely that there was insufficient
	heap available for the idle task to be created. */
	for( ;; );
	return 0;
}
Ejemplo n.º 2
0
BOOL CPdd6410Uart::Init()
{
    BOOL bRet = TRUE;

    if ( CSerialPDD::Init() && IsKeyOpened() && m_XmitFlushDone!=NULL)
    { 
        // IST Setup .
        DDKISRINFO ddi;
        if (GetIsrInfo(&ddi)!=ERROR_SUCCESS)
        {
            bRet = FALSE;
            goto CleanUp;
        }
        m_dwSysIntr = ddi.dwSysintr;
        if (m_dwSysIntr !=  MAXDWORD && m_dwSysIntr!=0 )
        {
            m_hISTEvent= CreateEvent(0,FALSE,FALSE,NULL);
        }

        if (m_hISTEvent!=NULL)
        {
            InterruptInitialize(m_dwSysIntr,m_hISTEvent,0,0);
        }
        else
        {
            bRet = FALSE;
            goto CleanUp;
        }

        // Get Device Index.
        if (!GetRegValue(PC_REG_DEVINDEX_VAL_NAME, (PBYTE)&m_dwDevIndex, PC_REG_DEVINDEX_VAL_LEN))
        {
            m_dwDevIndex = 0;
        }
        if (!GetRegValue(PC_REG_SERIALWATERMARK_VAL_NAME,(PBYTE)&m_dwWaterMark,PC_REG_SERIALWATERMARKER_VAL_LEN))
        {
            m_dwWaterMark = DEFAULT_VALUE_WATER_MARK;
        }
        if (!GetRegValue(PC_REG_6410UART_IST_TIMEOUTS_VAL_NAME,(PBYTE)&m_dwISTTimeout, PC_REG_6410UART_IST_TIMEOUTS_VAL_LEN))
        {
            m_dwISTTimeout = INFINITE;
        }
        if (!GetRegValue(PC_REG_6410UART_MEM_LENGTH_VAL_NAME, (PBYTE)&m_dwMemLen, PC_REG_6410UART_MEM_LENGTH_VAL_LEN))
        {
            m_dwMemLen = DEFAULT_VALUE_MEM_LENGH;
        }
        if (!MapHardware()  || !CreateHardwareAccess())
        {
            bRet = FALSE;
            goto CleanUp;
        }
#ifdef USE_DMA
        if (!GetRegValue(PC_REG_TX_DMA_EN_NAME,(PBYTE)&m_dwTXDMAEnable, sizeof(DWORD)))
        {
            m_dwTXDMAEnable = FALSE;
        }  
        if(m_dwTXDMAEnable)
        {
            RETAILMSG(1, (L"[UART] DMA init CH:%d \r\n", m_dwDevIndex));
            InitializeDMA(m_dwDevIndex);
        }    
#endif 
        bRet = TRUE;
        goto CleanUp;
    }
    bRet = FALSE;
CleanUp:
    return bRet;
}