STM32F0xx Standard Peripherals Firmware Library
|
STM32F0xx_StdPeriph_Examples/CRC/CRC_TwoBoards/stm32f0xx_it.c
Go to the documentation of this file.
00001 /** 00002 ****************************************************************************** 00003 * @file CRC/CRC_8BitsCRCMessage/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>© 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 00033 /** @addtogroup CRC_TwoBoards 00034 * @{ 00035 */ 00036 00037 /* Private typedef -----------------------------------------------------------*/ 00038 /* Private define ------------------------------------------------------------*/ 00039 /* Private macro -------------------------------------------------------------*/ 00040 /* Private variables ---------------------------------------------------------*/ 00041 extern uint8_t TxBuffer[]; 00042 extern uint8_t RxBuffer[]; 00043 extern __IO uint8_t RxIndex; 00044 extern __IO uint8_t TxIndex; 00045 extern __IO JOYState_TypeDef PressedButton; 00046 00047 __IO uint8_t Counter = 0x00; 00048 __IO uint32_t TimeOut = 0x00; 00049 uint8_t ComputedCRC = 0; 00050 00051 /* Private function prototypes -----------------------------------------------*/ 00052 /* Private functions ---------------------------------------------------------*/ 00053 00054 /******************************************************************************/ 00055 /* Cortex-M0 Processor Exceptions Handlers */ 00056 /******************************************************************************/ 00057 00058 /** 00059 * @brief This function handles NMI exception. 00060 * @param None 00061 * @retval None 00062 */ 00063 void NMI_Handler(void) 00064 { 00065 } 00066 00067 /** 00068 * @brief This function handles Hard Fault exception. 00069 * @param None 00070 * @retval None 00071 */ 00072 void HardFault_Handler(void) 00073 { 00074 /* Go to infinite loop when Hard Fault exception occurs */ 00075 while (1) 00076 { 00077 } 00078 } 00079 00080 /** 00081 * @brief This function handles SVCall exception. 00082 * @param None 00083 * @retval None 00084 */ 00085 void SVC_Handler(void) 00086 { 00087 } 00088 00089 /** 00090 * @brief This function handles PendSVC exception. 00091 * @param None 00092 * @retval None 00093 */ 00094 void PendSV_Handler(void) 00095 { 00096 } 00097 00098 /** 00099 * @brief This function handles SysTick Handler. 00100 * @param None 00101 * @retval None 00102 */ 00103 void SysTick_Handler(void) 00104 { 00105 if (Counter < 10) 00106 { 00107 Counter++; 00108 } 00109 else 00110 { 00111 Counter = 0x00; 00112 STM_EVAL_LEDToggle(LED1); 00113 } 00114 } 00115 /******************************************************************************/ 00116 /* STM32F0xx Peripherals Interrupt Handlers */ 00117 /******************************************************************************/ 00118 /** 00119 * @brief This function handles USRAT interrupt request. 00120 * @param None 00121 * @retval None 00122 */ 00123 void USARTx_IRQHandler(void) 00124 { 00125 #ifdef MODE_TRANSMITTER 00126 /* ------------------ USART in mode Tramitter ------------------------------*/ 00127 if (USART_GetITStatus(USARTx, USART_IT_TXE) == SET) 00128 { 00129 if (TxIndex < 0x48) 00130 { 00131 /* Send TxBuffer data */ 00132 USART_SendData(USARTx, TxBuffer[TxIndex]); 00133 00134 /* Compute 8-bit CRC */ 00135 CRC_CalcCRC8bits(TxBuffer[TxIndex++]); 00136 00137 } else if (TxIndex == 0x48) 00138 { 00139 /* Get computed computed value */ 00140 TxBuffer[TxIndex] = (uint8_t)CRC_GetCRC(); 00141 00142 /* Reset CRC calculation unit */ 00143 CRC_ResetDR(); 00144 00145 /* Send CRC computed value */ 00146 USART_SendData(USARTx, TxBuffer[TxIndex]); 00147 00148 /* Disable the USARTx transmit data register empty interrupt */ 00149 USART_ITConfig(USARTx, USART_IT_TXE, DISABLE); 00150 00151 /*Discard CRC sent value*/ 00152 TxBuffer[TxIndex] = 0; 00153 00154 /*reset TxBuffer index*/ 00155 TxIndex = 0; 00156 } 00157 } 00158 #else 00159 /* ------------------ USART in mode Receiver -------------------------------*/ 00160 if (USART_GetITStatus(USARTx, USART_IT_RXNE) == SET) 00161 { 00162 if (RxIndex < 0x48) 00163 { 00164 /* Receive the USART data */ 00165 RxBuffer[RxIndex] = USART_ReceiveData(USARTx); 00166 00167 /* compute 8-bit CRC */ 00168 CRC_CalcCRC8bits(RxBuffer[RxIndex++]); 00169 } 00170 else if (RxIndex == 0x48) 00171 { 00172 /* Get computed computed value */ 00173 ComputedCRC = (uint8_t)CRC_GetCRC(); 00174 00175 /* Reset CRC calculation unit */ 00176 CRC_ResetDR(); 00177 00178 /* Recive expected CRC value */ 00179 RxBuffer[RxIndex] = USART_ReceiveData(USARTx); 00180 00181 /* Compare computed CRC and recived CRC values*/ 00182 if (ComputedCRC == RxBuffer[RxIndex]) 00183 { 00184 /* LED3 Off */ 00185 STM_EVAL_LEDOff(LED3); 00186 /* Toggle LED2 */ 00187 STM_EVAL_LEDToggle(LED2); 00188 } else { 00189 /* LED3 On */ 00190 STM_EVAL_LEDOn(LED3); 00191 /* LED2 Off */ 00192 STM_EVAL_LEDOff(LED2); 00193 } 00194 /* Reset RxBuffer index */ 00195 RxIndex = 0; 00196 } 00197 } 00198 #endif /* MODE_TRANSMITTER */ 00199 } 00200 00201 /** 00202 * @brief This function handles External lines 0 to 1 interrupt request. 00203 * @param None 00204 * @retval None 00205 */ 00206 #ifdef MODE_TRANSMITTER 00207 void EXTI0_1_IRQHandler(void) 00208 { 00209 /* To detect user action on JOY_SEL button */ 00210 if(EXTI_GetITStatus(SEL_BUTTON_EXTI_LINE) != RESET) 00211 { 00212 PressedButton = JOY_SEL; 00213 /* Clear the SEL Button EXTI line pending bit */ 00214 EXTI_ClearITPendingBit(SEL_BUTTON_EXTI_LINE); 00215 } 00216 } 00217 #endif /* MODE_TRANSMITTER */ 00218 00219 /******************************************************************************/ 00220 /* STM32F0xx Peripherals Interrupt Handlers */ 00221 /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ 00222 /* available peripheral interrupt handler's name please refer to the startup */ 00223 /* file (startup_stm32f0xx.s). */ 00224 /******************************************************************************/ 00225 00226 /** 00227 * @brief This function handles PPP interrupt request. 00228 * @param None 00229 * @retval None 00230 */ 00231 /*void PPP_IRQHandler(void) 00232 { 00233 }*/ 00234 00235 /** 00236 * @} 00237 */ 00238 00239 00240 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/