Blame view

RIOT/boards/msba2/board_init.c 1.62 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
  /*
   * main.c - Main function of the SRF02 ultrasonic sensor project.
   * Copyright (C) 2013 Zakaria Kasmi <zkasmi@inf.fu-berlin.de>
   *
   * 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 msba2
   * @{
   */
  
  /**
   * @file
   * @brief       MSB-A2 board initialization
   *
   * @author      Heiko Will
   * @author      Kaspar Schleiser
   * @author      Michael Baar <baar@inf.fu-berlin.de>
   * @author      Zakaria Kasmi <zkasmi@inf.fu-berlin.de>
   *
   * @note        $Id$
   */
  
  #include "board.h"
  #include "cpu.h"
  
  void bl_init_ports(void)
  {
      gpio_init_ports();
  
      /* UART0 */
      PINSEL0 |= BIT4 + BIT6;                                 // RxD0 and TxD0
      PINSEL0 &= ~(BIT5 + BIT7);
  
      /* LEDS */
      FIO3DIR |= LED0_MASK;
      FIO3DIR |= LED1_MASK;
  
      LED0_OFF;
      LED0_OFF;
  }
  
  void init_clks1(void)
  {
      // Disconnect PLL
      PLLCON &= ~0x0002;
      pllfeed();
  
      // Disable PLL
      PLLCON &= ~0x0001;
      pllfeed();
  
      SCS |= 0x20;                        // Enable main OSC
  
      while (!(SCS & 0x40));              // Wait until main OSC is usable
  
      /* select main OSC, 16MHz, as the PLL clock source */
      CLKSRCSEL = 0x0001;
  
      // Setting Multiplier and Divider values
      PLLCFG = 0x0008;                    // M=9 N=1 Fcco = 288 MHz
      pllfeed();
  
      // Enabling the PLL */
      PLLCON = 0x0001;
      pllfeed();
  
      /* Set clock divider to 4 (value+1) */
      CCLKCFG = CL_CPU_DIV - 1;           // Fcpu = 72 MHz
  
  #if USE_USB
      USBCLKCFG = USBCLKDivValue;     /* usbclk = 288 MHz/6 = 48 MHz */
  #endif
  }