OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [CORTEX_EFMG890F128_IAR/] [CMSIS/] [CM3/] [DeviceSupport/] [EnergyMicro/] [EFM32/] [system_efm32.c] - Blame information for rev 604

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 604 jeremybenn
/**************************************************************************//**
2
 * @file
3
 * @brief CMSIS Cortex-M3 Peripheral Access Layer for EFM32 devices
4
 *
5
 * @author Energy Micro AS
6
 * @version 1.0.2
7
 ******************************************************************************
8
 * @section License
9
 * <b>(C) Copyright 2009 Energy Micro AS, http://www.energymicro.com</b>
10
 ******************************************************************************
11
 *
12
 * This source code is the property of Energy Micro AS. The source and compiled
13
 * code may only be used on Energy Micro "EFM32" microcontrollers.
14
 *
15
 * This copyright notice may not be removed from the source code nor changed.
16
 *
17
 * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
18
 * obligation to support this Software. Energy Micro AS is providing the
19
 * Software "AS IS", with no express or implied warranties of any kind,
20
 * including, but not limited to, any implied warranties of merchantability
21
 * or fitness for any particular purpose or warranties against infringement
22
 * of any proprietary rights of a third party.
23
 *
24
 * Energy Micro AS will not be liable for any consequential, incidental, or
25
 * special damages, or any other relief, or for any claim by any third party,
26
 * arising from your use of this Software.
27
 *
28
 *****************************************************************************/
29
 
30
#include <stdint.h>
31
#include "efm32.h"
32
 
33
uint32_t SystemCoreClock;     /**< System Clock Frequency (Core Clock)  */
34
 
35
#ifndef EFM32_HFXO_FREQ
36
#define EFM32_HFXO_FREQ 32000000
37
#endif
38
#ifndef EFM32_LFXO_FREQ 
39
#define EFM32_LFXO_FREQ 32768
40
#endif
41
#ifndef EFM32_LFRCO_FREQ
42
#define EFM32_LFRCO_FREQ 32768
43
#endif
44
 
45
/**************************************************************************//**
46
 * @brief Initialize the system
47
 *
48
 * @param  none
49
 * @return none
50
 *
51
 * @brief  Setup the microcontroller system.
52
 *         Initialize the System and update the SystemCoreClock variable.
53
 *****************************************************************************/
54
void SystemInit(void)
55
{
56
#if EFM32_AUXHFROCO_ENABLE
57
  CMU_TypeDef *cmu = CMU;
58
 
59
  /* Enable clocks to debug modules in Cortex */
60
  /* This will enable Debug Trace and MSC Flash programming clocks */
61
  cmu->OSCENCMD = CMU_OSCENCMD_AUXHFRCOEN;
62
#endif
63
}
64
 
65
/**************************************************************************//**
66
 * @brief Update SystemCoreClock variable
67
 *
68
 * @param  none
69
 * @return none
70
 *
71
 * @brief  Updates the SystemCoreClock with current core Clock
72
 *         retrieved from cpu registers.
73
 *****************************************************************************/
74
void SystemCoreClockUpdate(void)
75
{
76
  CMU_TypeDef *cmu = CMU;
77
  uint32_t inputClock;
78
 
79
  /* Check source for core clock */
80
  switch (cmu->STATUS &
81
          (CMU_STATUS_HFRCOSEL |
82
           CMU_STATUS_HFXOSEL |
83
           CMU_STATUS_LFRCOSEL |
84
           CMU_STATUS_LFXOSEL))
85
  {
86
  case CMU_STATUS_HFXOSEL:
87
    inputClock = EFM32_HFXO_FREQ;
88
    break;
89
  case CMU_STATUS_LFRCOSEL:
90
    inputClock = EFM32_LFRCO_FREQ;
91
    break;
92
  case CMU_STATUS_LFXOSEL:
93
    inputClock = EFM32_LFXO_FREQ;
94
    break;
95
  case CMU_STATUS_HFRCOSEL:
96
  default:
97
    switch ((cmu->HFRCOCTRL & _CMU_HFRCOCTRL_BAND_MASK) >> _CMU_HFRCOCTRL_BAND_SHIFT)
98
    {
99
    case _CMU_HFRCOCTRL_BAND_28MHZ:
100
      inputClock = 28000000;
101
      break;
102
    case _CMU_HFRCOCTRL_BAND_21MHZ:
103
      inputClock = 21000000;
104
      break;
105
    case _CMU_HFRCOCTRL_BAND_14MHZ:
106
      inputClock = 14000000;
107
      break;
108
    case _CMU_HFRCOCTRL_BAND_11MHZ:
109
      inputClock = 11000000;
110
      break;
111
    case _CMU_HFRCOCTRL_BAND_7MHZ:
112
      inputClock = 7000000;
113
      break;
114
    case _CMU_HFRCOCTRL_BAND_1MHZ:
115
      inputClock = 1500000;
116
      break;
117
    default:
118
      inputClock = 0;
119
      break;
120
    }
121
    break;
122
  }
123
  /* Adjust according to clock divisor */
124
  SystemCoreClock = inputClock / (1<<((cmu->HFCORECLKDIV & _CMU_HFCORECLKDIV_MASK)>>_CMU_HFCORECLKDIV_HFCORECLKDIV_SHIFT));
125
}
126
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.