Mercurial > ~darius > hgwebdir.cgi > stm32temp
comparison libs/STM32F10x_StdPeriph_Lib_V3.5.0/Project/STM32F10x_StdPeriph_Examples/USART/HyperTerminal_Interrupt/main.c @ 0:c59513fd84fb
Initial commit of STM32 test code.
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Mon, 03 Oct 2011 21:19:15 +1030 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c59513fd84fb |
---|---|
1 /** | |
2 ****************************************************************************** | |
3 * @file USART/HyperTerminal_Interrupt/main.c | |
4 * @author MCD Application Team | |
5 * @version V3.5.0 | |
6 * @date 08-April-2011 | |
7 * @brief Main program body | |
8 ****************************************************************************** | |
9 * @attention | |
10 * | |
11 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS | |
12 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE | |
13 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY | |
14 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING | |
15 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE | |
16 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. | |
17 * | |
18 * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2> | |
19 ****************************************************************************** | |
20 */ | |
21 | |
22 /* Includes ------------------------------------------------------------------*/ | |
23 #include "stm32f10x.h" | |
24 #include "stm32_eval.h" | |
25 | |
26 /** @addtogroup STM32F10x_StdPeriph_Examples | |
27 * @{ | |
28 */ | |
29 | |
30 /** @addtogroup USART_HyperTerminal_Interrupt | |
31 * @{ | |
32 */ | |
33 | |
34 /* Private typedef -----------------------------------------------------------*/ | |
35 /* Private define ------------------------------------------------------------*/ | |
36 #ifdef USE_STM3210C_EVAL | |
37 #define USARTx_IRQn USART2_IRQn | |
38 #else | |
39 #define USARTx_IRQn USART1_IRQn | |
40 #endif | |
41 | |
42 /* Private macro -------------------------------------------------------------*/ | |
43 /* Private variables ---------------------------------------------------------*/ | |
44 USART_InitTypeDef USART_InitStructure; | |
45 | |
46 /* Private function prototypes -----------------------------------------------*/ | |
47 void NVIC_Configuration(void); | |
48 | |
49 /* Private functions ---------------------------------------------------------*/ | |
50 | |
51 /** | |
52 * @brief Main program | |
53 * @param None | |
54 * @retval None | |
55 */ | |
56 int main(void) | |
57 { | |
58 /*!< At this stage the microcontroller clock setting is already configured, | |
59 this is done through SystemInit() function which is called from startup | |
60 file (startup_stm32f10x_xx.s) before to branch to application main. | |
61 To reconfigure the default setting of SystemInit() function, refer to | |
62 system_stm32f10x.c file | |
63 */ | |
64 | |
65 /* NVIC configuration */ | |
66 NVIC_Configuration(); | |
67 | |
68 /* USARTx configuration ------------------------------------------------------*/ | |
69 /* USARTx configured as follow: | |
70 - BaudRate = 9600 baud | |
71 - Word Length = 8 Bits | |
72 - Two Stop Bit | |
73 - Odd parity | |
74 - Hardware flow control disabled (RTS and CTS signals) | |
75 - Receive and transmit enabled | |
76 */ | |
77 USART_InitStructure.USART_BaudRate = 9600; | |
78 USART_InitStructure.USART_WordLength = USART_WordLength_8b; | |
79 USART_InitStructure.USART_StopBits = USART_StopBits_2; | |
80 USART_InitStructure.USART_Parity = USART_Parity_Odd; | |
81 USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; | |
82 USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; | |
83 | |
84 STM_EVAL_COMInit(COM1, &USART_InitStructure); | |
85 | |
86 /* Enable the EVAL_COM1 Transmit interrupt: this interrupt is generated when the | |
87 EVAL_COM1 transmit data register is empty */ | |
88 USART_ITConfig(EVAL_COM1, USART_IT_TXE, ENABLE); | |
89 | |
90 /* Enable the EVAL_COM1 Receive interrupt: this interrupt is generated when the | |
91 EVAL_COM1 receive data register is not empty */ | |
92 USART_ITConfig(EVAL_COM1, USART_IT_RXNE, ENABLE); | |
93 | |
94 while (1) | |
95 { | |
96 } | |
97 } | |
98 | |
99 /** | |
100 * @brief Configures the nested vectored interrupt controller. | |
101 * @param None | |
102 * @retval None | |
103 */ | |
104 void NVIC_Configuration(void) | |
105 { | |
106 NVIC_InitTypeDef NVIC_InitStructure; | |
107 | |
108 /* Enable the USARTx Interrupt */ | |
109 NVIC_InitStructure.NVIC_IRQChannel = USARTx_IRQn; | |
110 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; | |
111 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; | |
112 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; | |
113 NVIC_Init(&NVIC_InitStructure); | |
114 } | |
115 | |
116 #ifdef USE_FULL_ASSERT | |
117 | |
118 /** | |
119 * @brief Reports the name of the source file and the source line number | |
120 * where the assert_param error has occurred. | |
121 * @param file: pointer to the source file name | |
122 * @param line: assert_param error line source number | |
123 * @retval None | |
124 */ | |
125 void assert_failed(uint8_t* file, uint32_t line) | |
126 { | |
127 /* User can add his own implementation to report the file name and line number, | |
128 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ | |
129 | |
130 /* Infinite loop */ | |
131 while (1) | |
132 { | |
133 } | |
134 } | |
135 | |
136 #endif | |
137 | |
138 /** | |
139 * @} | |
140 */ | |
141 | |
142 /** | |
143 * @} | |
144 */ | |
145 | |
146 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ |