Esempio n. 1
0
/* API to enable the POSIF module */
void XMC_POSIF_Enable(XMC_POSIF_t *const peripheral)
{
#if UC_FAMILY == XMC4
  XMC_SCU_CLOCK_EnableClock(XMC_SCU_CLOCK_CCU);
#endif

  if (peripheral == POSIF0)
  {
#if defined(CLOCK_GATING_SUPPORTED)
    XMC_SCU_CLOCK_UngatePeripheralClock(XMC_SCU_PERIPHERAL_CLOCK_POSIF0);
#endif
#if defined(PERIPHERAL_RESET_SUPPORTED)
      XMC_SCU_RESET_DeassertPeripheralReset(XMC_SCU_PERIPHERAL_RESET_POSIF0);
#endif
  }
#if defined(POSIF1)
  else if (peripheral == POSIF1)
  {
#if defined(CLOCK_GATING_SUPPORTED)
      XMC_SCU_CLOCK_UngatePeripheralClock(XMC_SCU_PERIPHERAL_CLOCK_POSIF1);
#endif
#if defined(PERIPHERAL_RESET_SUPPORTED)
      XMC_SCU_RESET_DeassertPeripheralReset(XMC_SCU_PERIPHERAL_RESET_POSIF1);
#endif
  }
#endif
  else
  {
    XMC_ASSERT("XMC_POSIF_Disable:Invalid module pointer", 0);
  }
}
Esempio n. 2
0
__STATIC_INLINE void XMC_CCU4_lUngateClock(const XMC_CCU4_MODULE_t *const module)
{
  switch ((uint32_t)module)
  {
    case (uint32_t)CCU40:
      XMC_SCU_CLOCK_UngatePeripheralClock(XMC_SCU_PERIPHERAL_CLOCK_CCU40);
      break;
      
#if defined(CCU41)      
    case (uint32_t)CCU41:
      XMC_SCU_CLOCK_UngatePeripheralClock(XMC_SCU_PERIPHERAL_CLOCK_CCU41);
      break;
#endif

#if defined(CCU42)      
    case (uint32_t)CCU42:
      XMC_SCU_CLOCK_UngatePeripheralClock(XMC_SCU_PERIPHERAL_CLOCK_CCU42);
      break;
#endif

#if defined(CCU43)      
    case (uint32_t)CCU43:
      XMC_SCU_CLOCK_UngatePeripheralClock(XMC_SCU_PERIPHERAL_CLOCK_CCU43);
      break;
#endif  

    default:
      XMC_ASSERT("XMC_CCU4_lUngateClock:Invalid Module Pointer", 0);
      break;   
    
  }
}
Esempio n. 3
0
/**
  * Initialization of global register
  */
XMC_LEDTS_STATUS_t XMC_LEDTS_InitGlobal(XMC_LEDTS_t *const ledts, const XMC_LEDTS_GLOBAL_CONFIG_t *config)
{
  XMC_ASSERT("XMC_LEDTS_InitGlobal:Wrong Module Pointer", XMC_LEDTS_CHECK_KERNEL_PTR(ledts));
  XMC_ASSERT("XMC_LEDTS_InitGlobal:Null Pointer", (config != (XMC_LEDTS_GLOBAL_CONFIG_t *)NULL));

#if(UC_SERIES == XMC12)

  if(ledts == XMC_LEDTS0)
  {
    XMC_SCU_CLOCK_UngatePeripheralClock(XMC_SCU_PERIPHERAL_CLOCK_LEDTS0);
  }
  else
  {
    XMC_SCU_CLOCK_UngatePeripheralClock(XMC_SCU_PERIPHERAL_CLOCK_LEDTS1);
  }

#elif(UC_SERIES == XMC45)
  XMC_SCU_RESET_DeassertPeripheralReset(XMC_SCU_PERIPHERAL_RESET_LEDTS0);

#elif(UC_SERIES !=  XMC45)
  XMC_SCU_CLOCK_UngatePeripheralClock(XMC_SCU_PERIPHERAL_CLOCK_LEDTS0);
  XMC_SCU_RESET_DeassertPeripheralReset(XMC_SCU_PERIPHERAL_RESET_LEDTS0);

#endif

  if((ledts->GLOBCTL & LEDTS_GLOBCTL_CLK_PS_Msk) != XMC_LEDTS_CLOCK_NOT_RUNNING)
  {
    return XMC_LEDTS_STATUS_RUNNING;
  }

  ledts->GLOBCTL = config->globctl;

  return XMC_LEDTS_STATUS_SUCCESS;
}
Esempio n. 4
0
/* API to enable the POSIF module */
void XMC_POSIF_Enable(XMC_POSIF_t *const peripheral)
{
#if UC_FAMILY == XMC4
   XMC_SCU_CLOCK_EnableClock(XMC_SCU_CLOCK_CCU);
#endif

  switch ((uint32_t)peripheral)
  {
    case (uint32_t)POSIF0:
#if defined(CLOCK_GATING_SUPPORTED)
      XMC_SCU_CLOCK_UngatePeripheralClock(XMC_SCU_PERIPHERAL_CLOCK_POSIF0);
#endif
#if defined(PERIPHERAL_RESET_SUPPORTED)
      XMC_SCU_RESET_DeassertPeripheralReset(XMC_SCU_PERIPHERAL_RESET_POSIF0);
#endif
      break;
      
#if defined(POSIF1)
    case (uint32_t)POSIF1:
#if defined(CLOCK_GATING_SUPPORTED)
      XMC_SCU_CLOCK_UngatePeripheralClock(XMC_SCU_PERIPHERAL_CLOCK_POSIF1);
#endif
#if defined(PERIPHERAL_RESET_SUPPORTED)
      XMC_SCU_RESET_DeassertPeripheralReset(XMC_SCU_PERIPHERAL_RESET_POSIF1);
#endif
      break;
#endif

    default:
      XMC_ASSERT("XMC_POSIF_Disable:Invalid module pointer", 0);
      break;      
  }
}
Esempio n. 5
0
/*
 * API to initialise the global resources of a BCCU module
 */
void XMC_BCCU_GlobalInit(XMC_BCCU_t *const bccu, const XMC_BCCU_GLOBAL_CONFIG_t *const config)
{
  XMC_SCU_CLOCK_UngatePeripheralClock(XMC_SCU_PERIPHERAL_CLOCK_BCCU0);

  bccu->GLOBCON = config->globcon;
  
  bccu->GLOBCLK = config->globclk;
  bccu->GLOBDIM = config->global_dimlevel;  

}
Esempio n. 6
0
/* Enables watchdog clock and releases watchdog reset. */
void XMC_WDT_Enable(void)
{
#if UC_FAMILY == XMC4
  XMC_SCU_CLOCK_EnableClock(XMC_SCU_CLOCK_WDT);
#endif

#if defined(CLOCK_GATING_SUPPORTED)
  XMC_SCU_CLOCK_UngatePeripheralClock(XMC_SCU_PERIPHERAL_CLOCK_WDT);
#endif
#if defined(PERIPHERAL_RESET_SUPPORTED)
  XMC_SCU_RESET_DeassertPeripheralReset(XMC_SCU_PERIPHERAL_RESET_WDT);
#endif  
}
Esempio n. 7
0
/* Enable the clock and De-assert the ERU module from the reset state. */
void XMC_ERU_Enable(XMC_ERU_t *const eru)
{
#if defined(XMC_ERU1)
  if (eru == XMC_ERU1)
  {
#if defined(CLOCK_GATING_SUPPORTED)
    XMC_SCU_CLOCK_UngatePeripheralClock(XMC_SCU_PERIPHERAL_CLOCK_ERU1);
#endif
    XMC_SCU_RESET_DeassertPeripheralReset(XMC_SCU_PERIPHERAL_RESET_ERU1);
  }
#else
  XMC_UNUSED_ARG(eru);
  #endif
}
Esempio n. 8
0
/* Enable GPDMA module */
void XMC_DMA_Enable(XMC_DMA_t *const dma)
{
#if defined(GPDMA1)
  if (dma == XMC_DMA0)
  {
#endif
#if defined(CLOCK_GATING_SUPPORTED)
    XMC_SCU_CLOCK_UngatePeripheralClock(XMC_SCU_PERIPHERAL_CLOCK_GPDMA0);
#endif
    XMC_SCU_RESET_DeassertPeripheralReset(XMC_SCU_PERIPHERAL_RESET_GPDMA0);
#if defined(GPDMA1)
  }
  else
  {
#if defined(CLOCK_GATING_SUPPORTED)
    XMC_SCU_CLOCK_UngatePeripheralClock(XMC_SCU_PERIPHERAL_CLOCK_GPDMA1);
#endif
    XMC_SCU_RESET_DeassertPeripheralReset(XMC_SCU_PERIPHERAL_RESET_GPDMA1);
  }
#endif

  dma->DMACFGREG = 0x1U;
}
/*
 * Ungates a clock node for RTC
 */ 
void XMC_RTC_Enable(void)
{
  XMC_SCU_CLOCK_UngatePeripheralClock(XMC_SCU_PERIPHERAL_CLOCK_RTC);
}
/* Initializes HRPWM global registers */
XMC_HRPWM_STATUS_t XMC_HRPWM_Init(XMC_HRPWM_t *const hrpwm)
{
  uint32_t *csg_memory;
  uint32_t ccu_clock;
  uint32_t clkc;
  XMC_HRPWM_STATUS_t status;

  XMC_ASSERT("XMC_HRPWM_Init:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
  
  status = XMC_HRPWM_STATUS_ERROR;

  /* Apply reset to HRPWM module */ 
  XMC_SCU_RESET_AssertPeripheralReset(XMC_SCU_PERIPHERAL_RESET_HRPWM0);
 
  /* Release reset for HRPWM module */
  XMC_SCU_RESET_DeassertPeripheralReset(XMC_SCU_PERIPHERAL_RESET_HRPWM0);

  /* Ungate clock */
  XMC_SCU_CLOCK_UngatePeripheralClock(XMC_SCU_PERIPHERAL_CLOCK_HRPWM0);

  hrpwm->GLBANA = (uint32_t)0x00004A4E;  /* Initialization sequence */

  hrpwm->HRBSC |= (uint32_t)HRPWM0_HRBSC_HRBE_Msk;  /* Enable Bias Generator of HRPWM */
  
  /* Update CSG0 memory data */
  csg_memory = (uint32_t *)XMC_HRPWM_CSG0_MEMORY_ADDRESS;
  *csg_memory = g_hrpwm_char_data[0];
  /* write csg memory bits[14:11] with 0b1100 */
  *csg_memory &= (uint32_t)(0xFFFF87FF);
  *csg_memory |= (uint32_t)(0x00006000);

  /* Update CSG1 trimming data */
  csg_memory = (uint32_t *)XMC_HRPWM_CSG1_MEMORY_ADDRESS;
  *csg_memory = g_hrpwm_char_data[1];
  /* write csg memory bits[14:11] with 0b1100 */
  *csg_memory &= (uint32_t)(0xFFFF87FF);
  *csg_memory |= (uint32_t)(0x00006000);

  /* Update CSG2 trimming data */
  csg_memory = (uint32_t *)XMC_HRPWM_CSG2_MEMORY_ADDRESS;
  *csg_memory = g_hrpwm_char_data[2];
  /* write csg memory bits[14:11] with 0b1100 */
  *csg_memory &= (uint32_t)(0xFFFF87FF);
  *csg_memory |= (uint32_t)(0x00006000);
  
  /* Set CSG units to high speed mode */
  hrpwm->CSGCFG = (uint32_t)(0x0000003F);
  
  /* Read CCU clock frequency */
  ccu_clock = XMC_SCU_CLOCK_GetCcuClockFrequency();

  if ((ccu_clock > XMC_HRPWM_70MHZ_FREQUENCY) && (ccu_clock <= XMC_HRPWM_100MHZ_FREQUENCY))
  {
    clkc = 3U; /* Clock frequency range 70MHz+ - 100MHz is considered as 80MHz HRC operation */
  }
  else if ((ccu_clock > XMC_HRPWM_100MHZ_FREQUENCY) && (ccu_clock <= XMC_HRPWM_150MHZ_FREQUENCY))
  {
    clkc = 2U; /* Clock frequency range 100MHz+ - 150MHz is considered as 120MHz HRC operation */
  }
  else if ((ccu_clock > XMC_HRPWM_150MHZ_FREQUENCY) && (ccu_clock <= XMC_HRPWM_200MHZ_FREQUENCY))
  {
    clkc = 1U; /* Clock frequency range 150MHz+ - 200MHz is considered as 180MHz HRC operation */
  }
  else
  {
    clkc = 0U; /* Invalid frequency for HRC operation: Clock frequency <= 60MHz & Clock frequency > 200MHz */
  }

  if (clkc != 0U) /* Enter the loop only if the clock frequency is valid */
  {
    /* Program HRC clock configuration with clock frequency information */
    hrpwm->HRCCFG |= (clkc << HRPWM0_HRCCFG_CLKC_Pos);
    
    hrpwm->HRCCFG |= (uint32_t)HRPWM0_HRCCFG_HRCPM_Msk; /* Release HR generation from power down mode */
    
    XMC_HRPWM_lDelay(); /* As per Initialization sequence */
    
    /* Enable global high resolution generation / Force charge pump down */
    hrpwm->GLBANA |= (uint32_t)HRPWM0_GLBANA_GHREN_Msk;
    
    XMC_HRPWM_lDelay();

    /* Check High resolution ready bit field */
    if ((hrpwm->HRGHRS & HRPWM0_HRGHRS_HRGR_Msk) == 1U)
    {
      /* High resolution logic unit is ready */
      status = XMC_HRPWM_STATUS_OK;
    }
  }
  else
  {
    status = XMC_HRPWM_STATUS_ERROR; /* Clock frequency is invalid */
  }
 
  return (status);
}