Esempio n. 1
0
/*****************************************************************************
* Initialization function for the App Task. This is called during
* initialization and should contain any application specific initialization
* (ie. hardware initialization/setup, table initialization, power up
* notificaiton.
*
* Interface assumptions: None
*
* Return value: None
*
*****************************************************************************/
void MApp_init(void)
{ 
  
  /* The initial application state */
  gState = stateInit;  
  /* Reset number of pending packets */
  mcPendingPackets = 0;
  
  /* Allow sending a poll request */  
  mWaitPollConfirm = FALSE;    
  
  /* Initialize the poll interval */
  mPollInterval = mDefaultValueOfPollIntervalSlow_c;

  /* Initialize the MAC 802.15.4 extended address */
  Init_MacExtendedAddress();
  mTimer_c = TMR_AllocateTimer();
  /* register keyboard callback function */
  KBD_Init(App_HandleKeys);
  /* initialize LCD Module */
  LCD_Init();
  /* initialize LED Module */
  LED_Init();
  //WSNProject
   /*initialize the usage of power consumption*/
  PWR_CheckForAndEnterNewPowerState_Init();
  /* Initialize the UART so that we can print out status messages */
  UartX_SetBaud(gUartDefaultBaud_c);
  UartX_SetRxCallBack(UartRxCallBack);
  /* Prepare input queues.*/
  MSG_InitQueue(&mMlmeNwkInputQueue); 
  MSG_InitQueue(&mMcpsNwkInputQueue);
  /* Enable MCU interrupts */
  IntEnableAll();
  /*signal app ready*/  
  Led1Flashing();
  Led2Flashing();
  Led3Flashing();
  Led4Flashing();
    
  UartUtil_Print("\n\rPress any switch on board to start running the application.\n\r", gAllowToBlock_d);  
  LCD_ClearDisplay();
  LCD_WriteString(1,"Press any key");
  LCD_WriteString(2,"to start.");
}
Esempio n. 2
0
void InitDevice(void)
{
    IntDisableAll();
    WDT_INIT();
    Digitals_Init();  
    ItcInit();
    NVM_FlashInit();
    CRM_Init();  
    TMR_Init();
    ASM_Init();
    UART1_Init();
    UART2_Init();
    SPI_Init();
    MACA_Init(); 
    
///    DMAP_ResetStack(0);
  // WirelessHART Stack Initialisation
    NVM_ReadRecords(); // persistent data reading
    APP_Init();
    DLL_Init();   // reset the modem inside
    TL_Init();
    NET_Init();
    HART_DLL_Init(HART_ROLE_DECIDED);
  
  #if ( SHT1X_MODE != 0 )
    SHT1x_INIT();
  #endif
 
  #if ( (BOARD_TYPE == BOARD_TYPE_HART_DEV_KIT) )
    #if (!defined (IS_VN220))
      ADC_Extern_Init();
    #endif
  #endif
    
    IntEnableAll(); 
}    
Esempio n. 3
0
///////////////////////////////////////////////////////////////////////////////////
// Name: MAIN Function
///////////////////////////////////////////////////////////////////////////////////
  void main(void)
  {
    IntDisableAll();
  
    WDT_INIT();  
             
    Digitals_Init();
   
    ItcInit();
    
    NVM_FlashInit();
    
    CRM_Init();  
        
    TMR_Init();
    ASM_Init();
    UART1_Init();
    UART2_Init();
    SPI_Init();
    
    PROVISION_Init();
        
    MACA_Init(); 
    
    DAQ_Init();
        
    DMAP_ResetStack(0);
    
    IntEnableAll();
    
    //--------------------------------------------------------------------
    // Main Loop
    //--------------------------------------------------------------------
    for (;;)
    {           
        NLDE_Task();        // as fast as possible, keep this task first on loop
  
        DMAP_Task();        //
        ASLDE_ASLTask();    //
 
        UART_LINK_Task();   //
        UART2_CommControl();
        
        DAQ_RxHandler();
        
        if( g_uc250msFlag ) // 250ms Tasks
        {
            g_uc250msFlag = 0;
            
            // Handle DAQ after all other stack related tasks.
            DAQ_TxHandler();            
            UAP_MainTask();     
            
            ARMO_Task();
            
            if( !g_stTAI.m_uc250msStep ) // first 250ms slot from each second -> 1sec Tasks
            {
                ASLDE_PerformOneSecondOperations();
                DMAP_DMO_CheckNewDevInfoTTL();
    
                DMAP_CheckSecondCounter();
                
                ARMO_OneSecondTask();
    
                SLME_KeyUpdateTask();
                
                DMO_PerformOneSecondTasks();  
                
                MACA_WachDog();
            }
        }

        FEED_WDT();
    }
  }