STM32F10x_StdPeriph_Examples/USART/Interrupt/stm32f10x_it.c

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    USART/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 "platform_config.h"
00026 
00027 /** @addtogroup STM32F10x_StdPeriph_Examples
00028   * @{
00029   */
00030 
00031 /** @addtogroup USART_Interrupt
00032   * @{
00033   */ 
00034 
00035 /* Private typedef -----------------------------------------------------------*/
00036 /* Private define ------------------------------------------------------------*/
00037 /* Private macro -------------------------------------------------------------*/
00038 /* Private variables ---------------------------------------------------------*/
00039 extern uint8_t TxBuffer1[]; 
00040 extern uint8_t TxBuffer2[]; 
00041 extern uint8_t RxBuffer1[];
00042 extern uint8_t RxBuffer2[];
00043 extern __IO uint8_t TxCounter1;
00044 extern __IO uint8_t TxCounter2;
00045 extern __IO uint8_t RxCounter1; 
00046 extern __IO uint8_t RxCounter2;
00047 extern uint8_t NbrOfDataToTransfer1;
00048 extern uint8_t NbrOfDataToTransfer2;
00049 extern uint8_t NbrOfDataToRead1;
00050 extern uint8_t NbrOfDataToRead2;
00051 
00052 /* Private function prototypes -----------------------------------------------*/
00053 /* Private functions ---------------------------------------------------------*/
00054 
00055 /******************************************************************************/
00056 /*            Cortex-M3 Processor Exceptions Handlers                         */
00057 /******************************************************************************/
00058 
00059 /**
00060   * @brief  This function handles NMI exception.
00061   * @param  None
00062   * @retval None
00063   */
00064 void NMI_Handler(void)
00065 {
00066 }
00067 
00068 /**
00069   * @brief  This function handles Hard Fault exception.
00070   * @param  None
00071   * @retval None
00072   */
00073 void HardFault_Handler(void)
00074 {
00075   /* Go to infinite loop when Hard Fault exception occurs */
00076   while (1)
00077   {
00078   }
00079 }
00080 
00081 /**
00082   * @brief  This function handles Memory Manage exception.
00083   * @param  None
00084   * @retval None
00085   */
00086 void MemManage_Handler(void)
00087 {
00088   /* Go to infinite loop when Memory Manage exception occurs */
00089   while (1)
00090   {
00091   }
00092 }
00093 
00094 /**
00095   * @brief  This function handles Bus Fault exception.
00096   * @param  None
00097   * @retval None
00098   */
00099 void BusFault_Handler(void)
00100 {
00101   /* Go to infinite loop when Bus Fault exception occurs */
00102   while (1)
00103   {
00104   }
00105 }
00106 
00107 /**
00108   * @brief  This function handles Usage Fault exception.
00109   * @param  None
00110   * @retval None
00111   */
00112 void UsageFault_Handler(void)
00113 {
00114   /* Go to infinite loop when Usage Fault exception occurs */
00115   while (1)
00116   {
00117   }
00118 }
00119 
00120 /**
00121   * @brief  This function handles SVCall exception.
00122   * @param  None
00123   * @retval None
00124   */
00125 void SVC_Handler(void)
00126 {
00127 }
00128 
00129 /**
00130   * @brief  This function handles Debug Monitor exception.
00131   * @param  None
00132   * @retval None
00133   */
00134 void DebugMon_Handler(void)
00135 {
00136 }
00137 
00138 /**
00139   * @brief  This function handles PendSV_Handler exception.
00140   * @param  None
00141   * @retval None
00142   */
00143 void PendSV_Handler(void)
00144 {
00145 }
00146 
00147 /**
00148   * @brief  This function handles SysTick Handler.
00149   * @param  None
00150   * @retval None
00151   */
00152 void SysTick_Handler(void)
00153 {
00154 }
00155 
00156 /******************************************************************************/
00157 /*            STM32F10x Peripherals Interrupt Handlers                        */
00158 /******************************************************************************/
00159 
00160 /**
00161   * @brief  This function handles USARTy global interrupt request.
00162   * @param  None
00163   * @retval None
00164   */
00165 void USARTy_IRQHandler(void)
00166 {
00167   if(USART_GetITStatus(USARTy, USART_IT_RXNE) != RESET)
00168   {
00169     /* Read one byte from the receive data register */
00170     RxBuffer1[RxCounter1++] = USART_ReceiveData(USARTy);
00171 
00172     if(RxCounter1 == NbrOfDataToRead1)
00173     {
00174       /* Disable the USARTy Receive interrupt */
00175       USART_ITConfig(USARTy, USART_IT_RXNE, DISABLE);
00176     }
00177   }
00178   
00179   if(USART_GetITStatus(USARTy, USART_IT_TXE) != RESET)
00180   {   
00181     /* Write one byte to the transmit data register */
00182     USART_SendData(USARTy, TxBuffer1[TxCounter1++]);
00183 
00184     if(TxCounter1 == NbrOfDataToTransfer1)
00185     {
00186       /* Disable the USARTy Transmit interrupt */
00187       USART_ITConfig(USARTy, USART_IT_TXE, DISABLE);
00188     }    
00189   }
00190 }
00191 
00192 /**
00193   * @brief  This function handles USARTz global interrupt request.
00194   * @param  None
00195   * @retval None
00196   */
00197 void USARTz_IRQHandler(void)
00198 {
00199   if(USART_GetITStatus(USARTz, USART_IT_RXNE) != RESET)
00200   {
00201     /* Read one byte from the receive data register */
00202     RxBuffer2[RxCounter2++] = USART_ReceiveData(USARTz);
00203 
00204     if(RxCounter2 == NbrOfDataToRead1)
00205     {
00206       /* Disable the USARTz Receive interrupt */
00207       USART_ITConfig(USARTz, USART_IT_RXNE, DISABLE);
00208     }
00209   }
00210   
00211   if(USART_GetITStatus(USARTz, USART_IT_TXE) != RESET)
00212   {   
00213     /* Write one byte to the transmit data register */
00214     USART_SendData(USARTz, TxBuffer2[TxCounter2++]);
00215 
00216     if(TxCounter2 == NbrOfDataToTransfer2)
00217     {
00218       /* Disable the USARTz Transmit interrupt */
00219       USART_ITConfig(USARTz, USART_IT_TXE, DISABLE);
00220     }
00221   }
00222 }
00223 
00224 /******************************************************************************/
00225 /*                 STM32F10x Peripherals Interrupt Handlers                   */
00226 /*  Add here the Interrupt Handler for the used peripheral(s) (PPP), for the  */
00227 /*  available peripheral interrupt handler's name please refer to the startup */
00228 /*  file (startup_stm32f10x_xx.s).                                            */
00229 /******************************************************************************/
00230 
00231 /**
00232   * @brief  This function handles PPP interrupt request.
00233   * @param  None
00234   * @retval None
00235   */
00236 /*void PPP_IRQHandler(void)
00237 {
00238 }*/
00239 
00240 /**
00241   * @}
00242   */ 
00243 
00244 /**
00245   * @}
00246   */ 
00247 
00248 /******************* (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