STM32F10x_StdPeriph_Examples/USART/HyperTerminal_Interrupt/main.c

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    USART/HyperTerminal_Interrupt/main.c 
00004   * @author  MCD Application Team
00005   * @version V3.4.0
00006   * @date    10/15/2010
00007   * @brief   Main program body
00008   ******************************************************************************
00009   * @copy
00010   *
00011   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
00012   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
00013   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
00014   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
00015   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
00016   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
00017   *
00018   * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>
00019   */ 
00020 
00021 /* Includes ------------------------------------------------------------------*/
00022 #include "stm32f10x.h"
00023 #include "stm32_eval.h"
00024 
00025 /** @addtogroup STM32F10x_StdPeriph_Examples
00026   * @{
00027   */
00028 
00029 /** @addtogroup USART_HyperTerminal_Interrupt
00030   * @{
00031   */ 
00032 
00033 /* Private typedef -----------------------------------------------------------*/
00034 /* Private define ------------------------------------------------------------*/
00035 #ifdef USE_STM3210C_EVAL
00036   #define USARTx_IRQn   USART2_IRQn
00037 #else
00038   #define USARTx_IRQn   USART1_IRQn
00039 #endif
00040 
00041 /* Private macro -------------------------------------------------------------*/
00042 /* Private variables ---------------------------------------------------------*/
00043 USART_InitTypeDef USART_InitStructure;
00044 
00045 /* Private function prototypes -----------------------------------------------*/
00046 void NVIC_Configuration(void);
00047   
00048 /* Private functions ---------------------------------------------------------*/
00049 
00050 /**
00051   * @brief   Main program
00052   * @param  None
00053   * @retval None
00054   */
00055 int main(void)
00056 {
00057   /*!< At this stage the microcontroller clock setting is already configured, 
00058        this is done through SystemInit() function which is called from startup
00059        file (startup_stm32f10x_xx.s) before to branch to application main.
00060        To reconfigure the default setting of SystemInit() function, refer to
00061        system_stm32f10x.c file
00062      */     
00063               
00064   /* NVIC configuration */
00065   NVIC_Configuration();
00066   
00067 /* USARTx configuration ------------------------------------------------------*/
00068   /* USARTx configured as follow:
00069         - BaudRate = 9600 baud  
00070         - Word Length = 8 Bits
00071         - Two Stop Bit
00072         - Odd parity
00073         - Hardware flow control disabled (RTS and CTS signals)
00074         - Receive and transmit enabled
00075   */
00076   USART_InitStructure.USART_BaudRate = 9600;
00077   USART_InitStructure.USART_WordLength = USART_WordLength_8b;
00078   USART_InitStructure.USART_StopBits = USART_StopBits_2;
00079   USART_InitStructure.USART_Parity = USART_Parity_Odd;
00080   USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
00081   USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
00082 
00083   STM_EVAL_COMInit(COM1, &USART_InitStructure);
00084 
00085   /* Enable the EVAL_COM1 Transmoit interrupt: this interrupt is generated when the 
00086      EVAL_COM1 transmit data register is empty */  
00087   USART_ITConfig(EVAL_COM1, USART_IT_TXE, ENABLE);
00088 
00089   /* Enable the EVAL_COM1 Receive interrupt: this interrupt is generated when the 
00090      EVAL_COM1 receive data register is not empty */
00091   USART_ITConfig(EVAL_COM1, USART_IT_RXNE, ENABLE);
00092 
00093   while (1)
00094   {
00095   }
00096 }
00097 
00098 /**
00099   * @brief  Configures the nested vectored interrupt controller.
00100   * @param  None
00101   * @retval None
00102   */
00103 void NVIC_Configuration(void)
00104 {
00105   NVIC_InitTypeDef NVIC_InitStructure;
00106 
00107   /* Enable the USARTx Interrupt */
00108   NVIC_InitStructure.NVIC_IRQChannel = USARTx_IRQn;
00109   NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
00110   NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
00111   NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
00112   NVIC_Init(&NVIC_InitStructure);
00113 }
00114 
00115 #ifdef  USE_FULL_ASSERT
00116 /**
00117   * @brief  Reports the name of the source file and the source line number
00118   *         where the assert_param error has occurred.
00119   * @param  file: pointer to the source file name
00120   * @param  line: assert_param error line source number
00121   * @retval None
00122   */
00123 void assert_failed(uint8_t* file, uint32_t line)
00124 { 
00125   /* User can add his own implementation to report the file name and line number,
00126      ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
00127 
00128   /* Infinite loop */
00129   while (1)
00130   {
00131   }
00132 }
00133 #endif
00134 
00135 /**
00136   * @}
00137   */ 
00138 
00139 /**
00140   * @}
00141   */ 
00142 
00143 /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
STM32F10x Standard Peripherals Library: Footer

 

 

 

      For complete documentation on STM32(CORTEX M3) 32-bit Microcontrollers platform visit  www.st.com/STM32