STM32F10x_StdPeriph_Examples/USART/HyperTerminal_Interrupt/stm32f10x_it.c

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    USART/HyperTerminal_Interrupt/stm32f10x_it.c 
00004   * @author  MCD Application Team
00005   * @version V3.4.0
00006   * @date    10/15/2010
00007   * @brief   Main Interrupt Service Routines.
00008   *          This file provides template for all exceptions handler and peripherals
00009   *          interrupt service routine.
00010   ******************************************************************************
00011   * @copy
00012   *
00013   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
00014   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
00015   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
00016   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
00017   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
00018   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
00019   *
00020   * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>
00021   */ 
00022 
00023 /* Includes ------------------------------------------------------------------*/
00024 #include "stm32f10x_it.h"
00025 #include "stm32_eval.h"
00026 
00027 /** @addtogroup STM32F10x_StdPeriph_Examples
00028   * @{
00029   */
00030 
00031 /** @addtogroup USART_HyperTerminal_Interrupt
00032   * @{
00033   */ 
00034 
00035 /* Private typedef -----------------------------------------------------------*/
00036 /* Private define ------------------------------------------------------------*/
00037 #ifdef USE_STM3210C_EVAL
00038   #define USARTx_IRQHandler   USART2_IRQHandler
00039 #else
00040   #define USARTx_IRQHandler   USART1_IRQHandler
00041 #endif
00042 
00043 #define TxBufferSize   (countof(TxBuffer) - 1)
00044 #define RxBufferSize   0x20
00045 
00046 /* Private macro -------------------------------------------------------------*/
00047 #define countof(a)   (sizeof(a) / sizeof(*(a)))
00048 
00049 /* Private variables ---------------------------------------------------------*/
00050 uint8_t TxBuffer[] = "\n\rUSART Hyperterminal Interrupts Example: USART-Hyperterminal\
00051  communication using Interrupt\n\r";
00052 uint8_t RxBuffer[RxBufferSize];
00053 uint8_t NbrOfDataToTransfer = TxBufferSize;
00054 uint8_t NbrOfDataToRead = RxBufferSize;
00055 uint8_t TxCounter = 0; 
00056 uint16_t RxCounter = 0; 
00057 
00058 /* Private function prototypes -----------------------------------------------*/
00059 /* Private functions ---------------------------------------------------------*/
00060 
00061 /******************************************************************************/
00062 /*            Cortex-M3 Processor Exceptions Handlers                         */
00063 /******************************************************************************/
00064 
00065 /**
00066   * @brief  This function handles NMI exception.
00067   * @param  None
00068   * @retval None
00069   */
00070 void NMI_Handler(void)
00071 {
00072 }
00073 
00074 /**
00075   * @brief  This function handles Hard Fault exception.
00076   * @param  None
00077   * @retval None
00078   */
00079 void HardFault_Handler(void)
00080 {
00081   /* Go to infinite loop when Hard Fault exception occurs */
00082   while (1)
00083   {
00084   }
00085 }
00086 
00087 /**
00088   * @brief  This function handles Memory Manage exception.
00089   * @param  None
00090   * @retval None
00091   */
00092 void MemManage_Handler(void)
00093 {
00094   /* Go to infinite loop when Memory Manage exception occurs */
00095   while (1)
00096   {
00097   }
00098 }
00099 
00100 /**
00101   * @brief  This function handles Bus Fault exception.
00102   * @param  None
00103   * @retval None
00104   */
00105 void BusFault_Handler(void)
00106 {
00107   /* Go to infinite loop when Bus Fault exception occurs */
00108   while (1)
00109   {
00110   }
00111 }
00112 
00113 /**
00114   * @brief  This function handles Usage Fault exception.
00115   * @param  None
00116   * @retval None
00117   */
00118 void UsageFault_Handler(void)
00119 {
00120   /* Go to infinite loop when Usage Fault exception occurs */
00121   while (1)
00122   {
00123   }
00124 }
00125 
00126 /**
00127   * @brief  This function handles SVCall exception.
00128   * @param  None
00129   * @retval None
00130   */
00131 void SVC_Handler(void)
00132 {
00133 }
00134 
00135 /**
00136   * @brief  This function handles Debug Monitor exception.
00137   * @param  None
00138   * @retval None
00139   */
00140 void DebugMon_Handler(void)
00141 {
00142 }
00143 
00144 /**
00145   * @brief  This function handles PendSV_Handler exception.
00146   * @param  None
00147   * @retval None
00148   */
00149 void PendSV_Handler(void)
00150 {
00151 }
00152 
00153 /**
00154   * @brief  This function handles SysTick Handler.
00155   * @param  None
00156   * @retval None
00157   */
00158 void SysTick_Handler(void)
00159 {
00160 }
00161 
00162 /******************************************************************************/
00163 /*            STM32F10x Peripherals Interrupt Handlers                        */
00164 /******************************************************************************/
00165 
00166 /**
00167   * @brief  This function handles USARTx global interrupt request.
00168   * @param  None
00169   * @retval None
00170   */
00171 void USARTx_IRQHandler(void)
00172 {
00173   if(USART_GetITStatus(EVAL_COM1, USART_IT_RXNE) != RESET)
00174   {
00175     /* Read one byte from the receive data register */
00176     RxBuffer[RxCounter++] = (USART_ReceiveData(EVAL_COM1) & 0x7F);
00177 
00178     if(RxCounter == NbrOfDataToRead)
00179     {
00180       /* Disable the EVAL_COM1 Receive interrupt */
00181       USART_ITConfig(EVAL_COM1, USART_IT_RXNE, DISABLE);
00182     }
00183   }
00184 
00185   if(USART_GetITStatus(EVAL_COM1, USART_IT_TXE) != RESET)
00186   {   
00187     /* Write one byte to the transmit data register */
00188     USART_SendData(EVAL_COM1, TxBuffer[TxCounter++]);
00189 
00190     if(TxCounter == NbrOfDataToTransfer)
00191     {
00192       /* Disable the EVAL_COM1 Transmit interrupt */
00193       USART_ITConfig(EVAL_COM1, USART_IT_TXE, DISABLE);
00194     }
00195   }
00196 }
00197 
00198 /******************************************************************************/
00199 /*                 STM32F10x Peripherals Interrupt Handlers                   */
00200 /*  Add here the Interrupt Handler for the used peripheral(s) (PPP), for the  */
00201 /*  available peripheral interrupt handler's name please refer to the startup */
00202 /*  file (startup_stm32f10x_xx.s).                                            */
00203 /******************************************************************************/
00204 
00205 /**
00206   * @brief  This function handles PPP interrupt request.
00207   * @param  None
00208   * @retval None
00209   */
00210 /*void PPP_IRQHandler(void)
00211 {
00212 }*/
00213 
00214 /**
00215   * @}
00216   */ 
00217 
00218 /**
00219   * @}
00220   */ 
00221 
00222 /******************* (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