Beispiel #1
0
static void mpc5200_fec_start_dma_and_controller(void)
{
  TaskStart(FEC_RECV_TASK_NO, 1, FEC_RECV_TASK_NO, 1);
  TaskStart(FEC_XMIT_TASK_NO, 1, FEC_XMIT_TASK_NO, 1);

  mpc5200.ecntrl |= FEC_ECNTRL_OE | FEC_ECNTRL_EN;
}
Beispiel #2
0
void *Task::Entry()
{
	OnTaskStart();
	TaskStart();
	OnTaskEnd();
	return NULL;
}
Beispiel #3
0
/*********************************************************** 
函数功能:按键唤醒初始化
入口参数:
出口参数:
备注说明:1 按键唤醒后调用
          2 初始化唤醒下的任务
          
***********************************************************/
void PowerSleepWakeInit(void)
{	
	//按键唤醒后跑高速RC//后面有必要再调
	SwitchToHighCR(CLOCK_MAINPLL_OFF, CLOCK_MAIN_OSC_OFF, CLOCK_SUB_OSC_ON, BaseSysetmClockDIV8);
	//初始化主任务
	TaskInit(SYS_TICK_LOW, 0);

	//硬件设置为低功耗模式
	KeyPowerDownInit();
	DRV_LCD_Init(1);	//7天后需要重新打开LCD
	KeyPowerDownInit();
    DRV_RTC_FlashTask();
	//Clock_CheckDST();
	//存储器相关
	IIcPowerDownInit(); 
	//MX25L3206_IOPowerDownInt();//!
    
	//2 应用模块掉电初始化,保存数据等
	//==============================================================
	Init_DispPowerDown();
	//KeyScrTaskAdd(PowerWakeTierRst);
	PowerWakeTierRst();
	//==============================================================
	SleepDispTimerRst();   //按键重新开启7天
	TaskStart();
}
Beispiel #4
0
/**
 * Startup function for user specified task,
 * calls task function with proper signature
 *
 * @param data  the previously allocated lpel_task_t TCB
 */
void TaskStartup( void *data)
{
  lpel_task_t *t = (lpel_task_t *)data;

#if 0
  unsigned long z;

  z = x<<16;
  z <<= 16;
  z |= y;
  t = (lpel_task_t *)z;
#endif
  TaskStart( t);

  /* call the task function with inarg as parameter */
  t->outarg = t->func(t->inarg);

  /* if task function returns, exit properly */
  t->state = TASK_ZOMBIE;
  LpelWorkerSelfTaskExit(t);
  TaskStop( t);
  LpelWorkerDispatcher( t);
  /* execution never comes back here */
  assert(0);
}
Beispiel #5
0
/**
 * Block a task by reading from/writing to a stream
 */
void LpelTaskBlockStream(lpel_task_t *t)
{
  /* a reference to it is held in the stream */
  t->state = TASK_BLOCKED;
  LpelWorkerTaskBlock(t);
  TaskStop( t);
  LpelWorkerDispatcher( t);
  TaskStart( t);
}
Beispiel #6
0
/**
 * Yield execution back to scheduler voluntarily
 *
 * @pre This call must be made from within a LPEL task!
 */
void LpelTaskYield(void)
{
  lpel_task_t *ct = LpelTaskSelf();
  assert( ct->state == TASK_RUNNING );

  ct->state = TASK_READY;
  LpelWorkerSelfTaskYield(ct);
  TaskStop( ct);
  LpelWorkerDispatcher( ct);
  TaskStart( ct);
}
Beispiel #7
0
void mpc5200_pcmciaide_dma_blockop(bool is_write,
				   int minor,
				   uint16_t block_size,
				   rtems_blkdev_sg_buffer *bufs,
				   uint32_t *cbuf,
				   uint32_t *pos)

{
#if IDE_USE_DMA
  /*
   * Nameing:
   * - a block is one unit of data on disk (multiple sectors)
   * - a buffer is a contignuous chunk of data in memory
   * a block on disk may be filled with data from several buffers
   */
  uint32_t buf_idx,bufs_from_dma, bufs_to_dma,bufs_total;
  uint32_t bds_free;
  uint32_t llength;
  rtems_status_code rc = RTEMS_SUCCESSFUL;
  rtems_event_set events;
  BDIdx nxt_bd_idx;
  bool use_irq = (_System_state_Current == SYSTEM_STATE_UP);
  /*
   * determine number of blocks
   */
  llength = 0;
  buf_idx = 0;
  bufs += *cbuf; /* *cbuf is the index of the next buffer to send in this transaction */
  while (llength < block_size) {
    llength += bufs[buf_idx++].length;
  }
  bufs_from_dma = 0;
  bufs_to_dma   = 0;
  bufs_total    = buf_idx;
  /*
   * here all BDs should be unused
   */
  bds_free = is_write ? PCMCIA_IDE_DMA_WR_BD_CNT : PCMCIA_IDE_DMA_RD_BD_CNT;
  /*
   * repeat, until all bufs are transferred
   */
  while ((rc == RTEMS_SUCCESSFUL) &&
	 (bufs_from_dma < bufs_total)) {

    while ((rc == RTEMS_SUCCESSFUL) &&
	   (bufs_to_dma < bufs_total) &&
	   (bds_free > 0)) {
      /*
       * fill in BD, set interrupt if needed
       */
    SDMA_CLEAR_IEVENT(&mpc5200.sdma.IntPend,(is_write
	                                  ? IDE_TX_TASK_NO
	                                  : IDE_RX_TASK_NO));
      if (is_write) {
	TaskBDAssign(pcmcia_ide_txTaskId ,
		     (void *)bufs[bufs_to_dma].buffer,
		     (void *)mpc5200_ata_drive_regs[IDE_REGISTER_DATA_WORD],
		     bufs[bufs_to_dma].length,
		     0/* flags */);
#if IDE_USE_STATISTICS
	mpc5200_pcmciaide_write_block_block_cnt++;
#endif
      }
      else {
	TaskBDAssign(pcmcia_ide_rxTaskId ,
		     (void *)mpc5200_ata_drive_regs[IDE_REGISTER_DATA_WORD],
		     (void *)bufs[bufs_to_dma].buffer,
		     bufs[bufs_to_dma].length,
		     0/* flags */);
#if IDE_USE_STATISTICS
	mpc5200_pcmciaide_read_block_block_cnt++;
#endif
      }
      bufs_to_dma ++;
      bds_free    --;
    }
    if (is_write) {
      TaskStart( pcmcia_ide_txTaskId, TASK_AUTOSTART_DISABLE,
		 pcmcia_ide_txTaskId, TASK_INTERRUPT_DISABLE );
    }
    else {
      TaskStart( pcmcia_ide_rxTaskId, TASK_AUTOSTART_DISABLE,
		 pcmcia_ide_rxTaskId, TASK_INTERRUPT_DISABLE );
    }
    if (use_irq) {

      /*
       * enable interrupts, wait for interrupt event
       */
      pcmcia_ide_hdl_task = rtems_task_self();
      bestcomm_glue_irq_enable((is_write
				? IDE_TX_TASK_NO
				: IDE_RX_TASK_NO));

      rtems_event_receive(PCMCIA_IDE_INTERRUPT_EVENT,
			  RTEMS_WAIT | RTEMS_EVENT_ANY,
			  RTEMS_NO_TIMEOUT, &events);

      pcmcia_ide_hdl_task = 0;
    }
    else {
      /*
       * HACK: just wait some time...
       */
      /*
       * FIXME: poll, until SDMA is finished
       */
      volatile int32_t i;
      for (i = 0;i < 10000;i++) {};
    }

    do {
	  nxt_bd_idx = TaskBDRelease(is_write
	   				             ? pcmcia_ide_txTaskId
					             : pcmcia_ide_rxTaskId);
      if ((nxt_bd_idx != TASK_ERR_BD_RING_EMPTY) &&
          (nxt_bd_idx != TASK_ERR_BD_BUSY)) {
        (*cbuf)++;
        (*pos) += bufs[bufs_from_dma].length;
        bufs_from_dma++;
        bds_free++;
	  }
    } while ((nxt_bd_idx != TASK_ERR_BD_RING_EMPTY) &&
             (nxt_bd_idx != TASK_ERR_BD_BUSY)       &&
  	         (bufs_from_dma < bufs_to_dma));
  }
#endif /* IDE_USE_DMA */
}
Beispiel #8
0
/*********************************************************** 
函数功能:上电模式初始化
入口参数:
出口参数:
备注说明:1 市电上电时调用
          2 调用每个模块初始化函数,初始化函数包括所有的硬件初始化、数据初始化、任务初始化
***********************************************************/
uint16 PowerUpInit(void)
{
	DRV_WD_FeedDog();		//喂狗
	//切换到高速时钟
    SwitchToMainPLL(CLOCK_SUB_OSC_ON,BaseSysetmClockDIV1,PLLMultiplier2);
    DRV_RTC_CalcSecDeviation();           //上电马上进行补偿
	/*设置中断优先级*/
	Config_SystemClock_Priority();
    LvdOpen();		//打开LVD
    EXTI_DisableInt(EXTI_CH1);
	if(PowerDownDetect() != 0)
	{
		return 0;
	}
	/*初始化主任务*/
	TaskInit(SYS_TICK_LOW, SYS_TICK_HIGH);	//只初始化,不启动		
	/*初始化驱动模块*/
	DRV_IO_Init();
	Drv_Calibrate_Init();
	DRV_Calibrate_PRO_SWI_INIT();			//used for calibrate
	IIcInit();	
	//MX25L3206_IOInt();
	KeyInit();
	DRV_ADC_Init(1);
    DRV_ADC_On();
//	DRV_RTC_CalcSecDeviation();
    DRV_RTC_Init();  		//rtc初始化
    InitCaliVal();      	//RTC温补
    DRV_RTCSecPulseInit();  //rtc秒脉冲初始化
	DRV_LCD_Init(0);
	DRV_LCD_FillAll();
	LEDInit();
	ProtocolManageInit();	//通讯串口打开
	//RF 初始化
	RFModeChangeInit();     //RF切换模块
	RFIOPowerUpInit();
    
	if(0 == DRV_EMU_PowerUpInit())//used for EMU,load cailibrate data
	{
		return POWER_UP_INIT_FAIL;
	}
	//初始化应用模块
	ClockPowerUpInit();
//	if(POWER_UP_INIT_FAIL == TariffInit())
//	{
//		return POWER_UP_INIT_FAIL;
//	}
	//DRV_WD_FeedDog();		//?11·
	//DemandDataClear();
	//DemandInit();
	if(POWER_UP_INIT_FAIL == EnergyDataInit())
	{
		return POWER_UP_INIT_FAIL;
	}
	DRV_WD_FeedDog();		//?11·
	if(POWER_UP_INIT_FAIL == BillingPowerUpInit())
	{
		return POWER_UP_INIT_FAIL;
	}
	DRV_WD_FeedDog();		//?11·
//	if(POWER_UP_INIT_FAIL == LoadProfilePowerUpInit())
//	{
//		return POWER_UP_INIT_FAIL;
//	}
	if(POWER_UP_INIT_FAIL == FreezeInit())
	{
		return POWER_UP_INIT_FAIL;
	}
	DRV_WD_FeedDog();		//?11·
	if(POWER_UP_INIT_FAIL == EventPowerUpInit())
	{
		return POWER_UP_INIT_FAIL;
	}
	MeterInfoPowerUpInit();
	//DLMS_AA_Init();
	//------end----------
   //==============================================================
	Init_Disp();
   //==============================================================
    MeterPowerUPClearAll();         //全清,生产用
	//任务起动
   	MFT_FRTStart(MFT_UNIT0, FRT_CH2);
	TaskStart();
	//RF1MSStart();
	return POWER_UP_INIT_SUCESS;
}