Exemple #1
0
EXTERN_C
void Mcu_Init(const Mcu_ConfigType* McuConfig)
{
  static_cast<void>(McuConfig);

  mcal::cpu::init(nullptr);
  mcal::osc::init(nullptr);

  // Initialize the MCU clock.
  Mcu_InitClock(static_cast<Mcu_ClockType>(0));

  // Wait for PLL lock.
  while(MCU_PLL_LOCKED != Mcu_GetPllStatus())
  {
    mcal::cpu::nop();
  }
}
void EcuM_CheckWakeup(EcuM_WakeupSourceType source) {

	/* Re-enable PLL again */
	EcuM_ConfigType *ecuMConfigPtr;
	ecuMConfigPtr = EcuM_DeterminePbConfiguration();
	(void) Mcu_InitClock(ecuMConfigPtr->McuConfig->McuDefaultClockSettings);

	// Wait for PLL to sync.
	while (Mcu_GetPllStatus() != MCU_PLL_LOCKED) {
		;
	}

	/* ADD CODE BELOW */
#if 0
	/* Example */
	if (ECUM_WKSOURCE_SWITCH & wakeupSource) {
		if (CRP.PSCR.R & 0x00020000) {
			EcuM_SetWakeupEvent(ECUM_WKSOURCE_SWITCH);
		}
	}
#endif

}
/**
 * Part of STARTUP I
 *
 * @param ConfigPtr
 */
void EcuM_AL_DriverInitOne(const EcuM_ConfigType *ConfigPtr)
{
	(void)ConfigPtr;

#if defined(USE_MCU)
	Mcu_Init(ConfigPtr->McuConfig);

	/* Set up default clock (Mcu_InitClock requires initRun==1) */
	/* Ignoring return value */
	(void) Mcu_InitClock(ConfigPtr->McuConfig->McuDefaultClockSettings);

	// Wait for PLL to sync.
	while (Mcu_GetPllStatus() != MCU_PLL_LOCKED) {
		;
	}

	Mcu_DistributePllClock();
#endif

#if defined(USE_DEM)
	// Preinitialize DEM
	NO_DRIVER(Dem_PreInit(ConfigPtr->DemConfig));
#endif

#if defined(USE_PORT)
	// Setup Port
	Port_Init(ConfigPtr->PortConfig);
#endif

#if defined(USE_DIO)
    // Setup Dio
    Dio_Init(ConfigPtr->DioCfg);
#endif

#if defined(USE_GPT)
	// Setup the GPT
	Gpt_Init(ConfigPtr->GptConfig);
#endif

	// Setup watchdog
#if defined(USE_WDG)
	Wdg_Init(ConfigPtr->WdgConfig);
#endif
#if defined(USE_WDGM)
	NO_DRIVER(WdgM_Init(ConfigPtr->WdgMConfig));
#endif

#if defined(USE_DMA)
	// Setup DMA
	Dma_Init(ConfigPtr->DmaConfig);
#endif

#if defined(USE_ADC)
	// Setup ADC
	Adc_Init(ConfigPtr->AdcConfig);
#endif

#if defined(USE_BSWM)
	// Setup BSWM - not supporting configustructure for BswM
	BswM_Init(NULL);
#endif

	// Setup ICU
#if defined(USE_ICU)
     Icu_Init(ConfigPtr->IcuConfig);
#endif

	// Setup PWM
#if defined(USE_PWM)
	// Setup PWM
	Pwm_Init(ConfigPtr->PwmConfig);
#endif

    // Setup OCU
#if defined(USE_OCU)
	 Ocu_Init(ConfigPtr->OcuConfig);
#endif

#if defined(CFG_SHELL)
	SHELL_Init();
#endif
}
Exemple #4
0
/**
* \brief    Mcu init. Initialize PLL
* \author   Gerardo Valdovinos
* \param    void 
* \return   void
*/
void Mcu_Init( void )
{
    Mcu_InitClock();
    Mcu_DistributePllClock();
    u32BusFreq = BUS_FREQ_MHZ * (u32)1000000;
}
Exemple #5
0
void EcuM_AL_DriverInitOne(const EcuM_ConfigType* configPtr) {

   /* provide a proper clock */
   Mcu_Init(configPtr->bsw_driver.init_one.mcu_cfg);
   Mcu_InitClock(0);
   Mcu_DistributePllClock();

   /* -----------------------------------------------------------------------
	      Interrupt System:
	      -----------------------------------------------------------------------
	      - four arbitration cycles (max. 255 interrupt sources)
	      - two clocks per arbitration cycle */

   __mtcr(0xFE2C,  0x00000000);     /* load CPU interrupt control register */
   __isync();

   /* -----------------------------------------------------------------------
	      Peripheral Control Processor (PCP):
	      -----------------------------------------------------------------------
	      - the PCP internal clock is always running

	      - use Full Context save area (R[0] - R[7])
	      - start progam counter as left by last invocation
	      - channel watchdog is disabled
	      - maximum channel number checking is disabled */

   /* - four arbitration cycles (max. 255 PCP channels) */
   /* - two clocks per arbitration cycle */
   PCP_ICR.U        =  0x00000000;  /* load PCP interrupt control register */

   /* - the PCP warning mechanism is disabled */
   PCP_ITR.U        =  0x00000000;  /* load PCP interrupt threshold register */

   /* - type of service of PCP node 4 is CPU interrupt */
   PCP_SRC4.U       =  0x00001000;  /* load service request control register 4 */

   /* - type of service of PCP node 5 is CPU interrupt */
   PCP_SRC5.U       =  0x00001000;  /* load service request control register 5 */

   /* - type of service of PCP node 6 is CPU interrupt */
   PCP_SRC6.U       =  0x00001000;  /* load service request control register 6 */

   /* - type of service of PCP node 7 is CPU interrupt */
   PCP_SRC7.U       =  0x00001000;  /* load service request control register 7 */

   /* - type of service of PCP node 8 is CPU interrupt */
   PCP_SRC8.U       =  0x00001000;  /* load service request control register 8 */


   ts_initGPTAInt();

   Port_Init(configPtr->bsw_driver.init_one.port_cfg);

   Adc_Init(configPtr->bsw_driver.init_one.adc_cfg);
   Fls_Init(configPtr->bsw_driver.init_one.fls_cfg);
   Gpt_Init(configPtr->bsw_driver.init_one.gpt_cfg);
   Pwm_Init(configPtr->bsw_driver.init_one.pwm_cfg);
   Spi_Init(configPtr->bsw_driver.init_one.spi_cfg);
   Wdg_Init(configPtr->bsw_driver.init_one.wdg_cfg);
#ifdef ECUM_WDGM_INCLUDED
   WdgM_Init(configPtr->bsw_driver.init_one.wdgm_cfg);
#endif

   /* setup end of init protected registers for OS */
   ts_endinit_clear();
   osInitProtected();
   ts_endinit_set();

   /* Overlay Ram:
    * Init registers and mem areas for switching from
    * working page (overlay ram) <-> reference page (flash)
    */
   RAM_OverlayRamReset();

   /* - the CPU interrupt system is globally disabled */
   __enable();


   Spi_SetAsyncMode(SPI_INTERRUPT_MODE);
   Adc_StartGroupConversion(0);
   Adc_StartGroupConversion(1);
   EcuM_SelectApplicationMode(OSDEFAULTAPPMODE);

}
/**
 * Part of STARTUP I
 *
 * @param ConfigPtr
 */
void EcuM_AL_DriverInitOne(const EcuM_ConfigType *ConfigPtr)
{
	(void)ConfigPtr;

//	VALIDATE_STATE( ECUM_STATE_STARTUP_ONE );

  //lint --e{715}       PC-Lint (715) - ConfigPtr usage depends on configuration of modules

#if defined(USE_MCU)
	Mcu_Init(ConfigPtr->McuConfig);

	/* Set up default clock (Mcu_InitClock requires initRun==1) */
	/* Ignoring return value */
	(void) Mcu_InitClock(ConfigPtr->McuConfig->McuDefaultClockSettings);

	// Wait for PLL to sync.
	while (Mcu_GetPllStatus() != MCU_PLL_LOCKED) {
		;
	}

	Mcu_DistributePllClock();
#endif

#if defined(USE_DEM)
	// Preinitialize DEM
	NO_DRIVER(Dem_PreInit(ConfigPtr->DemConfig));
#endif

#if defined(USE_PORT)
	// Setup Port
	Port_Init(ConfigPtr->PortConfig);
#endif

#if defined(USE_GPT)
	// Setup the GPT
	Gpt_Init(ConfigPtr->GptConfig);
#endif

	// Setup watchdog
#if defined(USE_WDG)
	Wdg_Init(ConfigPtr->WdgConfig);
#endif
#if defined(USE_WDGM)
	NO_DRIVER(WdgM_Init(ConfigPtr->WdgMConfig));
#endif

#if defined(USE_DMA)
	// Setup DMA
	Dma_Init(ConfigPtr->DmaConfig);
#endif

#if defined(USE_ADC)
	// Setup ADC
	Adc_Init(ConfigPtr->AdcConfig);
#endif

	// Setup ICU
	// TODO
	// Setup PWM
#if defined(USE_PWM)
	// Setup PWM
	Pwm_Init(ConfigPtr->PwmConfig);
#endif

#if defined(CFG_SHELL)
	SHELL_Init();
#endif


}