Paparazzi UAS  v4.2.2_stable-4-gcc32f65
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_CtsPin GPIO_Pin_11
59 #define UART1_RtsPin GPIO_Pin_12
60 
61 #define UART1_TxPort GPIOA
62 #define UART2_TxPort GPIOA
63 #define UART3_TxPort GPIOC
64 #define UART5_TxPort GPIOC
65 
66 #define UART1_RxPort GPIOA
67 #define UART2_RxPort GPIOA
68 #define UART3_RxPort GPIOC
69 #define UART5_RxPort GPIOD
70 
71 #define UART1_FlowControlPort GPIOA
72 
73 #define UART1_Periph RCC_APB2Periph_GPIOA
74 #define UART2_Periph RCC_APB2Periph_GPIOA
75 #define UART3_Periph RCC_APB2Periph_GPIOC
76 #define UART5_PeriphTx RCC_APB2Periph_GPIOC
77 #define UART5_PeriphRx RCC_APB2Periph_GPIOD
78 
79 /* this is unexpected the macros in spektrum_arch.c
80  didn't expect that rx and tx would be spilt over
81  two ports. As the spektrum code is only interested
82  in the rx pin we define this to be the Peripheral */
83 #define UART5_Periph RCC_APB2Periph_GPIOD
84 
85 #define UART1_UartPeriph RCC_APB2Periph_USART1
86 #define UART2_UartPeriph RCC_APB1Periph_USART2
87 #define UART3_UartPeriph RCC_APB1Periph_USART3
88 #define UART5_UartPeriph RCC_APB1Periph_UART5
89 
90 #define UART1_remap {}
91 #define UART2_remap {}
92 #define UART3_remap {RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); \
93  GPIO_PinRemapConfig(GPIO_PartialRemap_USART3, ENABLE);}
94 #define UART5_remap {}
95 
96 #define UART1_clk(_periph, _val) RCC_APB2PeriphClockCmd(_periph, _val)
97 #define UART2_clk(_periph, _val) RCC_APB1PeriphClockCmd(_periph, _val)
98 #define UART3_clk(_periph, _val) RCC_APB1PeriphClockCmd(_periph, _val);
99 #define UART5_clk(_periph, _val) RCC_APB1PeriphClockCmd(_periph, _val)
100 
101 #define Uart1_init uart1_init()
102 #define Uart2_init uart2_init()
103 #define Uart3_init uart3_init()
104 #define Uart5_init uart5_init()
105 
106 #define UART1_irq_handler usart1_irq_handler
107 #define UART2_irq_handler usart2_irq_handler
108 #define UART3_irq_handler usart3_irq_handler
109 #define UART5_irq_handler usart5_irq_handler
110 
111 #define UART1_IRQn USART1_IRQn
112 #define UART2_IRQn USART2_IRQn
113 #define UART3_IRQn USART3_IRQn
114 
115 #define UART1_reg USART1
116 #define UART2_reg USART2
117 #define UART3_reg USART3
118 #define UART5_reg USART5
119 
120 #if defined UART1_FLOW_CONTROL
121 #error UART1_FLOW_CONTROL is renamed to UART1_HW_FLOW_CONTROL
122 #endif
123 
124 #if defined USE_UART1 || OVERRIDE_UART1_IRQ_HANDLER
125 extern void usart1_irq_handler(void);
126 #endif
127 
128 #if defined USE_UART2 || OVERRIDE_UART2_IRQ_HANDLER
129 extern void usart2_irq_handler(void);
130 #endif
131 
132 #if defined USE_UART3 || OVERRIDE_UART3_IRQ_HANDLER
133 extern void usart3_irq_handler(void);
134 #endif
135 
136 #if defined USE_UART5 || OVERRIDE_UART5_IRQ_HANDLER
137 extern void usart5_irq_handler(void);
138 #endif
139 
140 //void uart_init( void );
141 
142 #endif /* STM32_UART_ARCH_H */