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.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 
28 #include "mcu.h"
29 #include "std.h"
30 
31 #ifdef PERIPHERALS_AUTO_INIT
32 #include "mcu_periph/sys_time.h"
33 #ifdef USE_LED
34 #include "led.h"
35 #endif
36 #if defined RADIO_CONTROL
37 #if defined RADIO_CONTROL_LINK || defined RADIO_CONTROL_SPEKTRUM_PRIMARY_PORT
39 #endif
40 #endif
41 #if defined USE_UART0 || defined USE_UART1 || defined USE_UART2 || defined USE_UART3 || defined USE_UART4 || defined USE_UART5 || defined USE_UART6
42 #include "mcu_periph/uart.h"
43 #endif
44 #if defined USE_I2C0 || defined USE_I2C1 || defined USE_I2C2
45 #include "mcu_periph/i2c.h"
46 #endif
47 #if defined USE_ADC
48 #include "mcu_periph/adc.h"
49 #endif
50 #ifdef USE_USB_SERIAL
51 #include "mcu_periph/usb_serial.h"
52 #endif
53 #if USE_SPI
54 #include "mcu_periph/spi.h"
55 #endif
56 #ifdef USE_DAC
57 #include "mcu_periph/dac.h"
58 #endif
59 #endif /* PERIPHERALS_AUTO_INIT */
60 
61 void mcu_init(void) {
62 
63  mcu_arch_init();
64 
65 #ifdef PERIPHERALS_AUTO_INIT
66  sys_time_init();
67 #ifdef USE_LED
68  led_init();
69 #endif
70  /* for now this means using spektrum */
71 #if defined RADIO_CONTROL & defined RADIO_CONTROL_SPEKTRUM_PRIMARY_PORT & defined RADIO_CONTROL_BIND_IMPL_FUNC
72  RADIO_CONTROL_BIND_IMPL_FUNC();
73 #endif
74 #ifdef USE_UART0
75  uart0_init();
76 #endif
77 #ifdef USE_UART1
78  uart1_init();
79 #endif
80 #ifdef USE_UART2
81  uart2_init();
82 #endif
83 #ifdef USE_UART3
84  uart3_init();
85 #endif
86 #ifdef USE_UART4
87  uart4_init();
88 #endif
89 #ifdef USE_UART5
90  uart5_init();
91 #endif
92 #ifdef USE_UART6
93  uart6_init();
94 #endif
95 #ifdef USE_I2C0
96  i2c0_init();
97 #endif
98 #ifdef USE_I2C1
99  i2c1_init();
100 #endif
101 #ifdef USE_I2C2
102  i2c2_init();
103 #endif
104 #ifdef USE_I2C3
105  i2c3_init();
106 #endif
107 #ifdef USE_ADC
108  adc_init();
109 #endif
110 #ifdef USE_USB_SERIAL
111  VCOM_init();
112 #endif
113 
114 #if USE_SPI
115 #if SPI_MASTER
116 
117 #if USE_SPI0
118  spi0_init();
119 #endif
120 #if USE_SPI1
121  spi1_init();
122 #endif
123 #if USE_SPI2
124  spi2_init();
125 #endif
126 #if USE_SPI3
127  spi3_init();
128 #endif
129  spi_init_slaves();
130 #endif // SPI_MASTER
131 
132 #if SPI_SLAVE
133 #if USE_SPI0_SLAVE
134  spi0_slave_init();
135 #endif
136 #if USE_SPI1_SLAVE
137  spi1_slave_init();
138 #endif
139 #if USE_SPI2_SLAVE
140  spi2_slave_init();
141 #endif
142 #if USE_SPI3_SLAVE
143  spi3_slave_init();
144 #endif
145 #endif // SPI_SLAVE
146 
147 #if SPI_SLAVE_HS
149 #endif
150 #endif // USE_SPI
151 
152 #ifdef USE_DAC
153  dac_init();
154 #endif
155 #else
156 INFO("PERIPHERALS_AUTO_INIT not enabled! Peripherals (including sys_time) need explicit initialization.")
157 #endif /* PERIPHERALS_AUTO_INIT */
158 
159 }
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
void mcu_init(void)
Microcontroller peripherals initialization.
Definition: mcu.c:61
void spi_slave_hs_init(void)
arch independent ADC (Analog to Digital Converter) API
Architecture independent SPI (Serial Peripheral Interface) API.
Architecture independent timing functions.
void VCOM_init(void)
static void led_init(void)
Definition: led.h:89
void sys_time_init(void)
Definition: sys_time.c:70
void spi1_init(void)
Definition: spi.c:47
Arch independent mcu ( Micro Controller Unit ) utilities.
void spi2_init(void)
Definition: spi.c:57
void adc_init(void)
Starts conversions.
Definition: adc_arch.c:194
arch independent LED (Light Emitting Diodes) API
void dac_init(void)
Definition: dac_arch.c:33
void spi_init_slaves(void)
Initialize all used slaves and uselect them.
Definition: spi_arch.c:503
void mcu_arch_init(void)
Definition: mcu_arch.c:40
void spi0_init(void)
Definition: spi.c:37
arch independent USB API
Architecture independent I2C (Inter-Integrated Circuit Bus) API.