コード例 #1
0
ファイル: DMAT1.c プロジェクト: rpc-fw/usbmidi2
/* ===================================================================*/
LDD_TDeviceData* DMAT1_Init(LDD_TUserData *UserDataPtr)
{
  DMAT1_TDeviceData *DeviceDataPtr;    /* LDD device structure */
  LDD_DMA_TTransferDescriptor *DescriptorPtr; /* Transfer descriptor structure */

  /* Allocate LDD device structure */
  /* {Default RTOS Adapter} Driver memory allocation: Dynamic allocation is simulated by a pointer to the static object */
  DeviceDataPtr = &DeviceDataPtr__DEFAULT_RTOS_ALLOC;
  /* Allocate Transfer descriptor structure */
  /* {Default RTOS Adapter} Driver memory allocation: Dynamic allocation is simulated by a pointer to the static object */
  DescriptorPtr = &DescriptorPtr__DEFAULT_RTOS_ALLOC;
  DeviceDataPtr->DescriptorPtr = DescriptorPtr; /* Store pointer to the descriptor structure */
  /* Transfer descriptor initialization */
  DeviceDataPtr->DescriptorPtr->UserDataPtr = UserDataPtr; /* User device data structure pointer to be returned by the DMA_LDD component's ISR to the dynamic callback of this Descriptor */
  /* Source settings */
  DeviceDataPtr->DescriptorPtr->SourceAddress = (LDD_DMA_TAddress)(uint32_t)&UART0_D; /* Address of a DMA transfer source data */
  DeviceDataPtr->DescriptorPtr->SourceTransferSize = (LDD_DMA_TTransferSize)DMA_PDD_8_BIT; /* 8-bit source data transfer size. */
  DeviceDataPtr->DescriptorPtr->SourceModuloSize = (LDD_DMA_TModuloSize)DMA_PDD_CIRCULAR_BUFFER_DISABLED; /* Circular buffer size. */
  DeviceDataPtr->DescriptorPtr->SourceAddressIncrement = FALSE; /* Address not incremented. */
  /* Destination settings */
  DeviceDataPtr->DescriptorPtr->DestinationAddress = (LDD_DMA_TAddress)(uint32_t)&intercore_dma_data; /* Address of a DMA transfer destination data */
  DeviceDataPtr->DescriptorPtr->DestinationTransferSize = (LDD_DMA_TTransferSize)DMA_PDD_8_BIT; /* 8-bit destination data transfer size. */
  DeviceDataPtr->DescriptorPtr->DestinationModuloSize = (LDD_DMA_TModuloSize)DMA_PDD_CIRCULAR_BUFFER_128_BYTES; /* Circular buffer size. */
  DeviceDataPtr->DescriptorPtr->DestinationAddressIncrement = TRUE; /* Address incremented after each elemental read operation. */
  /* Byte count value */
  DeviceDataPtr->DescriptorPtr->ByteCount = (LDD_DMA_TByteCount)0x7FFFF; /* Size of data to be transferred. */
  /* Trigger settings */
  DeviceDataPtr->DescriptorPtr->TriggerType = LDD_DMA_HW_TRIGGER; /* External peripheral trigger is used */
  DeviceDataPtr->DescriptorPtr->TriggerSource = (LDD_DMA_TTriggerSource)0x02U; /* External peripheral trigger source number */
  DeviceDataPtr->DescriptorPtr->PeriodicTrigger = FALSE; /* Periodic trigger mode is not used */
  DeviceDataPtr->DescriptorPtr->ChannelAutoSelection = FALSE; /* DMA channel fixed value */
  DeviceDataPtr->DescriptorPtr->ChannelNumber = (LDD_DMA_TChannelNumber)0x02U; /* DMA channel number */
  DeviceDataPtr->DescriptorPtr->AsynchronousRequests = FALSE; /* DMA channel asynchronous requests disabled. */
  /* Inner and outer loop linking settings */
  DeviceDataPtr->DescriptorPtr->ChannelLinkingMode = LDD_DMA_LINKING_DISABLED; /* Channel linking disabled. */
  DeviceDataPtr->DescriptorPtr->InnerLoopLinkedChannel = 0x00U; /* Linked DMA channel number not used. */
  DeviceDataPtr->DescriptorPtr->OuterLoopLinkedChannel = 0x00U; /* Linked DMA channel number not used. */
  /* Transfer control settings */
  DeviceDataPtr->DescriptorPtr->TransferMode = LDD_DMA_CYCLE_STEAL_TRANSFERS; /* Cycle-steal transfers - one elementary read-write transfer per request. */
  DeviceDataPtr->DescriptorPtr->DisableAfterRequest = FALSE; /* Leave enabled after request. */
  /* Interrupts and events settings */
  DeviceDataPtr->DescriptorPtr->Interrupts = FALSE; /* Interrupts are not requested. */
  DeviceDataPtr->DescriptorPtr->OnComplete = FALSE; /* Event disabled in initialization code. */
  DeviceDataPtr->DescriptorPtr->OnError = FALSE; /* Event disabled in initialization code. */
  DeviceDataPtr->DescriptorPtr->OnCompleteEventPtr = NULL; /* OnComplete event not enabled */
  DeviceDataPtr->DescriptorPtr->OnErrorEventPtr = NULL; /* OnError event not enabled */
  DeviceDataPtr->DescriptorPtr->ChannelEnabled = FALSE; /* Descriptor is not allocating nor using any channel. */
  if (PE_LDD_DeviceDataList[PE_LDD_COMPONENT_DMA1_ID] == NULL) {
    DeviceDataPtr->DMA_LDD_DeviceDataPtr = DMA1_Init(NULL);
  }
  else {
    DeviceDataPtr->DMA_LDD_DeviceDataPtr = PE_LDD_DeviceDataList[PE_LDD_COMPONENT_DMA1_ID];
  }
  /* Registration of the device structure */
  PE_LDD_RegisterDeviceStructure(PE_LDD_COMPONENT_DMAT1_ID,DeviceDataPtr);
  return ((LDD_TDeviceData *)DeviceDataPtr); /* Return pointer to the data data structure. */
}
コード例 #2
0
void Init_Task(uint32_t task_init_data)
{
		int tester=0;
	//uint_8 sys=0;
	bool bInitOpen=FALSE;
  bool	bInitStill=FALSE;
	bool bInitVLPS=FALSE;
	MQX_TICK_STRUCT ttt;
	 _mqx_uint       mqx_ret;
	  trace_init();
	 show_version_information();
		//////////////zga add
	//Set LPTMR to timeout about 5 seconds
		Lptmr_Init(1000, LPOCLK);	
		ADC_Init();
		Calibrate_ADC();
		ADC_Init();
		DMA1_Init();
	//////////////zga add
		// clear flag  
		APP_TRACE("start 1\n\r");
	 _task_create_at(0, SHELL_TASK, 0, shell_task_stack, SHELL_TASK_STACK_SIZE);
	 _task_create_at(0, MMA8415_TASK, 0, mma8451_task_stack, MMA8451_TASK_STACK_SIZE);
	
		Lptmr_Start();
	

	
for(;;)
	{
		 mqx_ret = _lwsem_wait(&g_lptmr_int_sem);

	
	//	_time_delay_ticks(10);
		tester++;
//_time_delay_ticks(10);
		//APP_TRACE("tester is: %d\r\n",tester);
		_time_get_elapsed_ticks(&ttt);
          APP_TRACE("high ttt %d, low ttt%d\r\n", ttt.TICKS[1],ttt.TICKS[0]);
		if(Measured)
		{	Measured=0;
			APP_TRACE ("light: %d ,%d \r\n", (uint16_t) MeasuredValues[1],tester);
		}
		if((GetTouchON()==TRUE))
			{
				SetSysStatus(ACTIVE_OPEN);
			}
			// for test 
			SetSysStatus(ACTIVE_OPEN);
		switch (sysStatus)
	{
		case ACTIVE_OPEN:
					bInitStill=FALSE;
					bInitVLPS=FALSE;
					APP_TRACE ("ACTIVE_OPEN\r\n");
					if(bInitOpen==FALSE)
					{
						bInitOpen=TRUE;
						putmma8451running();
						SysTick_PDD_EnableDevice(SysTick_BASE_PTR, PDD_ENABLE);
					}
					
					
			break;

    case ACTIVE_STILL:
					bInitOpen=FALSE;
					bInitVLPS=FALSE;
				APP_TRACE ("ACTIVE_still\r\n");
					if(bInitStill==FALSE)
					{
						bInitStill=TRUE;
						putmma8451detect();
					}
					enter_vlps();
		case 	VLPSMODE:
					bInitOpen=FALSE;
					bInitStill=FALSE;
				APP_TRACE ("vlpsmode\r\n");
					if(bInitVLPS==FALSE)
					{
						bInitVLPS=TRUE;
						putmma8451standby();
					}
					enter_vlps();
    default:
            break;
	}


	} 
	
}