Paparazzi UAS  v4.0.4_stable-3-gf39211a
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
uart_arch.h
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Copyright (C) 2009-2010 The Paparazzi Team
5  *
6  * This file is part of paparazzi.
7  *
8  * paparazzi is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2, or (at your option)
11  * any later version.
12  *
13  * paparazzi is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with paparazzi; see the file COPYING. If not, write to
20  * the Free Software Foundation, 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23 
24 /*
25  *\brief STM32 usart functions
26  *
27  */
28 
29 #ifndef STM32_UART_ARCH_H
30 #define STM32_UART_ARCH_H
31 
32 #include "std.h"
33 
34 #define B4800 4800
35 #define B9600 9600
36 #define B38400 38400
37 #define B57600 57600
38 #define B115200 115200
39 
40 /* junk for gps_configure_uart in gps_ubx.c to compile */
41 #define UART_8N1 1
42 #define UART_FIFO_8 1
43 
44 /* sort out the problem of UART5 already defined in stm32.h */
45 #define USART5 ((USART_TypeDef *) UART5_BASE)
46 #undef UART5
47 
48 #define UART1_TxPin GPIO_Pin_9
49 #define UART2_TxPin GPIO_Pin_2
50 #define UART3_TxPin GPIO_Pin_10
51 #define UART5_TxPin GPIO_Pin_12
52 
53 #define UART1_RxPin GPIO_Pin_10
54 #define UART2_RxPin GPIO_Pin_3
55 #define UART3_RxPin GPIO_Pin_11
56 #define UART5_RxPin GPIO_Pin_2
57 
58 #define UART1_TxPort GPIOA
59 #define UART2_TxPort GPIOA
60 #define UART3_TxPort GPIOC
61 #define UART5_TxPort GPIOC
62 
63 #define UART1_RxPort GPIOA
64 #define UART2_RxPort GPIOA
65 #define UART3_RxPort GPIOC
66 #define UART5_RxPort GPIOD
67 
68 #define UART1_Periph RCC_APB2Periph_GPIOA
69 #define UART2_Periph RCC_APB2Periph_GPIOA
70 #define UART3_Periph RCC_APB2Periph_GPIOC
71 #define UART5_PeriphTx RCC_APB2Periph_GPIOC
72 #define UART5_PeriphRx RCC_APB2Periph_GPIOD
73 
74 /* this is unexpected the macros in spektrum_arch.c
75  didn't expect that rx and tx would be spilt over
76  two ports. As the spektrum code is only interested
77  in the rx pin we define this to be the Peripheral */
78 #define UART5_Periph RCC_APB2Periph_GPIOD
79 
80 #define UART1_UartPeriph RCC_APB2Periph_USART1
81 #define UART2_UartPeriph RCC_APB1Periph_USART2
82 #define UART3_UartPeriph RCC_APB1Periph_USART3
83 #define UART5_UartPeriph RCC_APB1Periph_UART5
84 
85 #define UART1_remap {}
86 #define UART2_remap {}
87 #define UART3_remap {RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); \
88  GPIO_PinRemapConfig(GPIO_PartialRemap_USART3, ENABLE);}
89 #define UART5_remap {}
90 
91 #define UART1_clk(_periph, _val) RCC_APB2PeriphClockCmd(_periph, _val)
92 #define UART2_clk(_periph, _val) RCC_APB1PeriphClockCmd(_periph, _val)
93 #define UART3_clk(_periph, _val) RCC_APB1PeriphClockCmd(_periph, _val);
94 #define UART5_clk(_periph, _val) RCC_APB1PeriphClockCmd(_periph, _val)
95 
96 #define Uart1_init uart1_init()
97 #define Uart2_init uart2_init()
98 #define Uart3_init uart3_init()
99 #define Uart5_init uart5_init()
100 
101 #define UART1_irq_handler usart1_irq_handler
102 #define UART2_irq_handler usart2_irq_handler
103 #define UART3_irq_handler usart3_irq_handler
104 #define UART5_irq_handler usart5_irq_handler
105 
106 #define UART1_IRQn USART1_IRQn
107 #define UART2_IRQn USART2_IRQn
108 #define UART3_IRQn USART3_IRQn
109 
110 #define UART1_reg USART1
111 #define UART2_reg USART2
112 #define UART3_reg USART3
113 #define UART5_reg USART5
114 
115 
116 #if defined USE_UART1 || OVERRIDE_UART1_IRQ_HANDLER
117 extern void usart1_irq_handler(void);
118 #endif
119 
120 #if defined USE_UART2 || OVERRIDE_UART2_IRQ_HANDLER
121 extern void usart2_irq_handler(void);
122 #endif
123 
124 #if defined USE_UART3 || OVERRIDE_UART3_IRQ_HANDLER
125 extern void usart3_irq_handler(void);
126 #endif
127 
128 #if defined USE_UART5 || OVERRIDE_UART5_IRQ_HANDLER
129 extern void usart5_irq_handler(void);
130 #endif
131 
132 //void uart_init( void );
133 
134 #endif /* STM32_UART_ARCH_H */