STM32F0xx Standard Peripherals Firmware Library: stm32f0xx_it.c Source File

STM32F0xx Standard Peripherals Library

STM32F0xx_StdPeriph_Examples/USART/USART_HyperTerminalInterrupt/stm32f0xx_it.c
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    USART/USART_HyperTerminalInterrupt/stm32f0xx_it.c 
00004   * @author  MCD Application Team
00005   * @version V1.4.0
00006   * @date    24-July-2014
00007   * @brief   Main Interrupt Service Routines.
00008   *          This file provides template for all exceptions handler and 
00009   *          peripherals interrupt service routine.
00010   ******************************************************************************
00011   * @attention
00012   *
00013   * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
00014   *
00015   * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
00016   * You may not use this file except in compliance with the License.
00017   * You may obtain a copy of the License at:
00018   *
00019   *        http://www.st.com/software_license_agreement_liberty_v2
00020   *
00021   * Unless required by applicable law or agreed to in writing, software 
00022   * distributed under the License is distributed on an "AS IS" BASIS, 
00023   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00024   * See the License for the specific language governing permissions and
00025   * limitations under the License.
00026   *
00027   ******************************************************************************
00028   */
00029 
00030 /* Includes ------------------------------------------------------------------*/
00031 #include "stm32f0xx_it.h"
00032 #include "main.h"
00033 
00034 /** @addtogroup STM32F0xx_StdPeriph_Examples
00035   * @{
00036   */
00037 
00038 /** @addtogroup HyperTerminal_Interrupt
00039   * @{
00040   */
00041 
00042 /* Private typedef -----------------------------------------------------------*/
00043 /* Private define ------------------------------------------------------------*/
00044 #define TXBUFFERSIZE   (countof(TxBuffer) - 1)
00045 #define RXBUFFERSIZE   0x20
00046 
00047 /* Private macro -------------------------------------------------------------*/
00048 #define countof(a)   (sizeof(a) / sizeof(*(a)))
00049 
00050 /* Private variables ---------------------------------------------------------*/
00051 uint8_t TxBuffer[] = "\n\rUSART Hyperterminal Interrupts Example: USART-Hyperterminal\
00052  communication using Interrupt\n\r";
00053 uint8_t RxBuffer[RXBUFFERSIZE];
00054 uint8_t NbrOfDataToTransfer = TXBUFFERSIZE;
00055 uint8_t NbrOfDataToRead = RXBUFFERSIZE;
00056 __IO uint8_t TxCount = 0; 
00057 __IO uint16_t RxCount = 0; 
00058 
00059 /* Private function prototypes -----------------------------------------------*/
00060 /* Private functions ---------------------------------------------------------*/
00061 
00062 /******************************************************************************/
00063 /*            Cortex-M0 Processor Exceptions Handlers                         */
00064 /******************************************************************************/
00065 
00066 /**
00067   * @brief  This function handles NMI exception.
00068   * @param  None
00069   * @retval None
00070   */
00071 void NMI_Handler(void)
00072 {
00073 }
00074 
00075 /**
00076   * @brief  This function handles Hard Fault exception.
00077   * @param  None
00078   * @retval None
00079   */
00080 void HardFault_Handler(void)
00081 {
00082   /* Go to infinite loop when Hard Fault exception occurs */
00083   while (1)
00084   {
00085   }
00086 }
00087 
00088 /**
00089   * @brief  This function handles SVCall exception.
00090   * @param  None
00091   * @retval None
00092   */
00093 void SVC_Handler(void)
00094 {
00095 }
00096 
00097 /**
00098   * @brief  This function handles PendSVC exception.
00099   * @param  None
00100   * @retval None
00101   */
00102 void PendSV_Handler(void)
00103 {
00104 }
00105 
00106 /**
00107   * @brief  This function handles SysTick Handler.
00108   * @param  None
00109   * @retval None
00110   */
00111 void SysTick_Handler(void)
00112 {
00113 }
00114 
00115 /******************************************************************************/
00116 /*                 STM32F0xx Peripherals Interrupt Handlers                   */
00117 /*  Add here the Interrupt Handler for the used peripheral(s) (PPP), for the  */
00118 /*  available peripheral interrupt handler's name please refer to the startup */
00119 /*  file (startup_stm32f0xx.s).                                               */
00120 /******************************************************************************/
00121 
00122 /**
00123   * @brief  This function handles PPP interrupt request.
00124   * @param  None
00125   * @retval None
00126   */
00127 /*void PPP_IRQHandler(void)
00128 {
00129 }*/
00130 
00131 /**
00132   * @brief  This function handles USART1 global interrupt request.
00133   * @param  None
00134   * @retval None
00135   */
00136 #ifdef USE_STM320518_EVAL
00137 void USART1_IRQHandler(void)
00138 {
00139   if(USART_GetITStatus(EVAL_COM1, USART_IT_RXNE) != RESET)
00140   {
00141     /* Read one byte from the receive data register */
00142     RxBuffer[RxCount++] = (USART_ReceiveData(EVAL_COM1) & 0x7F);
00143 
00144     if(RxCount == NbrOfDataToRead)
00145     {
00146       /* Disable the EVAL_COM1 Receive interrupt */
00147       USART_ITConfig(EVAL_COM1, USART_IT_RXNE, DISABLE);
00148     }
00149   }
00150 
00151   if(USART_GetITStatus(EVAL_COM1, USART_IT_TXE) != RESET)
00152   {   
00153     /* Write one byte to the transmit data register */
00154     USART_SendData(EVAL_COM1, TxBuffer[TxCount++]);
00155 
00156     if(TxCount == NbrOfDataToTransfer)
00157     {
00158       /* Disable the EVAL_COM1 Transmit interrupt */
00159       USART_ITConfig(EVAL_COM1, USART_IT_TXE, DISABLE);
00160     }
00161   }
00162 }
00163 #else
00164 void USART2_IRQHandler(void)
00165 {
00166   if(USART_GetITStatus(EVAL_COM1, USART_IT_RXNE) != RESET)
00167   {
00168     /* Read one byte from the receive data register */
00169     RxBuffer[RxCount++] = (USART_ReceiveData(EVAL_COM1) & 0x7F);
00170 
00171     if(RxCount == NbrOfDataToRead)
00172     {
00173       /* Disable the EVAL_COM1 Receive interrupt */
00174       USART_ITConfig(EVAL_COM1, USART_IT_RXNE, DISABLE);
00175     }
00176   }
00177 
00178   if(USART_GetITStatus(EVAL_COM1, USART_IT_TXE) != RESET)
00179   {   
00180     /* Write one byte to the transmit data register */
00181     USART_SendData(EVAL_COM1, TxBuffer[TxCount++]);
00182 
00183     if(TxCount == NbrOfDataToTransfer)
00184     {
00185       /* Disable the EVAL_COM1 Transmit interrupt */
00186       USART_ITConfig(EVAL_COM1, USART_IT_TXE, DISABLE);
00187     }
00188   }
00189 }
00190 #endif /* USE_STM320518_EVAL */
00191 
00192 /**
00193   * @}
00194   */
00195 
00196 /**
00197   * @}
00198   */
00199 
00200 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
STM32L1xx Standard Peripherals Library: Footer

 

 

 For complete documentation on STM32 Microcontrollers visit www.st.com/STM32