Paparazzi UAS  v5.0.5_stable-7-g4b8bbb7
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
mcu_arch.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010-2012 The Paparazzi team
3  *
4  * This file is part of Paparazzi.
5  *
6  * Paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * Paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *
21  */
22 
29 #include "mcu.h"
30 
31 #include BOARD_CONFIG
32 
33 #include <inttypes.h>
34 #include <libopencm3/stm32/gpio.h>
35 #include <libopencm3/stm32/rcc.h>
36 #if defined(STM32F1)
37 #include <libopencm3/stm32/f1/flash.h>
38 #elif defined(STM32F4)
39 #include <libopencm3/stm32/f4/flash.h>
40 #endif
41 #include <libopencm3/cm3/scb.h>
42 
43 #include "std.h"
44 
45 void mcu_arch_init(void) {
46 #if LUFTBOOT
47 PRINT_CONFIG_MSG("We are running luftboot, the interrupt vector is being relocated.")
48  SCB_VTOR = 0x00002000;
49 #endif
50 #if EXT_CLK == 8000000
51 #if defined(STM32F1)
52 PRINT_CONFIG_MSG("Using 8MHz external clock to PLL it to 72MHz.")
53  rcc_clock_setup_in_hse_8mhz_out_72mhz();
54 #elif defined(STM32F4)
55 PRINT_CONFIG_MSG("Using 8MHz external clock to PLL it to 168MHz.")
56  rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_168MHZ]);
57 #endif
58 #elif EXT_CLK == 12000000
59 #if defined(STM32F1)
60 PRINT_CONFIG_MSG("Using 12MHz external clock to PLL it to 72MHz.")
61  rcc_clock_setup_in_hse_12mhz_out_72mhz();
62 #elif defined(STM32F4)
63 PRINT_CONFIG_MSG("Using 12MHz external clock to PLL it to 168MHz.")
64  rcc_clock_setup_hse_3v3(&hse_12mhz_3v3[CLOCK_3V3_168MHZ]);
65 #endif
66 #elif EXT_CLK == 16000000
67 #if defined(STM32F4)
68 PRINT_CONFIG_MSG("Using 16MHz external clock to PLL it to 168MHz.")
69  rcc_clock_setup_hse_3v3(&hse_16mhz_3v3[CLOCK_3V3_168MHZ]);
70 #endif
71 #else
72 #error EXT_CLK is either set to an unsupported frequency or not defined at all. Please check!
73 #endif
74 }
75 
Arch independent mcu ( Micro Controller Unit ) utilities.
void mcu_arch_init(void)
Definition: mcu_arch.c:40