Blame view

RIOT/cpu/cc26x0/cpu.c 1.32 KB
fb11e647   vrobic   reseau statique a...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
  /*
   * Copyright (C) 2016 Leon George
   *
   * This file is subject to the terms and conditions of the GNU Lesser
   * General Public License v2.1. See the file LICENSE in the top level
   * directory for more details.
   */
  
  /**
   * @ingroup     cpu_cc26x0
   * @{
   *
   * @file
   * @brief       implementation of the CPU initialization
   *
   * @author      Leon M. George <leon@georgemail.eu>
   * @}
   */
  
   #include "cpu.h"
   #include "periph_conf.h"
  
  #ifndef HF_CLOCK_SOURCE
  #define HF_CLOCK_SOURCE DDI_0_OSC_CTL0_SCLK_HF_SRC_SEL_RCOSC /* set 48MHz RCOSC */
  #endif
  #ifndef LF_CLOCK_SOURCE
  #define LF_CLOCK_SOURCE DDI_0_OSC_CTL0_SCLK_LF_SRC_SEL_HF_RCOSC /* set 31.25kHz derived from 48MHz RCOSC */
  #endif
  
  /**
   *@brief Configure the MCU system clock
   */
  static void cpu_clock_init(void);
  
  /**
   * @brief Initialize the CPU, set IRQ priorities
   */
  void cpu_init(void)
  {
      /* initialize the Cortex-M core */
      cortexm_init();
  
      /* initialize the system clock */
      cpu_clock_init();
  }
  
  static void cpu_clock_init(void)
  {
      AON_WUC->AUXCTL |= AUXCTL_AUX_FORCE_ON; /* power on AUX_PD */
      while(!(AON_WUC->PWRSTAT & PWRSTAT_AUX_PD_ON)); /* wait for AUX_PD to be powered on */
      AUX_WUC->MODCLKEN0 |= MODCLKEN0_AUX_DDI0_OSC_EN; /* turn on oscillator interface clock */
  
      DDI_0_OSC->CTL0 |= HF_CLOCK_SOURCE | LF_CLOCK_SOURCE; /* configure HF and LF clocks */
  }