STM8S/A Standard Peripherals Firmware Library
|
STM8S_StdPeriph_Examples/I2C/I2C_TwoBoards/I2C_DataExchange/Master/stm8s_it.c
Go to the documentation of this file.
00001 /** 00002 ****************************************************************************** 00003 * @file stm8s_it.c 00004 * @author MCD Application Team 00005 * @version V2.2.0 00006 * @date 30-September-2014 00007 * @brief Main Interrupt Service Routines. 00008 ****************************************************************************** 00009 * @attention 00010 * 00011 * <h2><center>© COPYRIGHT 2014 STMicroelectronics</center></h2> 00012 * 00013 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 00014 * You may not use this file except in compliance with the License. 00015 * You may obtain a copy of the License at: 00016 * 00017 * http://www.st.com/software_license_agreement_liberty_v2 00018 * 00019 * Unless required by applicable law or agreed to in writing, software 00020 * distributed under the License is distributed on an "AS IS" BASIS, 00021 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00022 * See the License for the specific language governing permissions and 00023 * limitations under the License. 00024 * 00025 ****************************************************************************** 00026 */ 00027 00028 /* Includes ------------------------------------------------------------------*/ 00029 #include "stm8s_it.h" 00030 #include "main.h" 00031 /** @addtogroup I2C_TwoBoards 00032 * @{ 00033 */ 00034 00035 /** @addtogroup I2C_DataExchange 00036 * @{ 00037 */ 00038 /* Private typedef -----------------------------------------------------------*/ 00039 /* Private define ------------------------------------------------------------*/ 00040 /* Private macro -------------------------------------------------------------*/ 00041 extern uint8_t HEADER_ADDRESS_Write = (((SLAVE_ADDRESS & 0xFF00) >> 7) | 0xF0); 00042 extern uint8_t HEADER_ADDRESS_Read; 00043 /* Private variables ---------------------------------------------------------*/ 00044 __IO uint8_t TxBuffer[BUFFERSIZE]; 00045 extern __IO uint8_t NumOfBytes; 00046 extern __IO uint8_t Tx_Idx; 00047 /* Private function prototypes -----------------------------------------------*/ 00048 /* Private functions ---------------------------------------------------------*/ 00049 /* Public functions ----------------------------------------------------------*/ 00050 00051 #ifdef _COSMIC_ 00052 /** 00053 * @brief Dummy interrupt routine 00054 * @param None 00055 * @retval None 00056 */ 00057 @far @interrupt void NonHandledInterrupt(void) 00058 { 00059 /* In order to detect unexpected events during development, 00060 it is recommended to set a breakpoint on the following instruction. 00061 */ 00062 } 00063 00064 /** 00065 * @brief TRAP interrupt routine 00066 * @param None 00067 * @retval None 00068 */ 00069 @far @interrupt void TRAP_IRQHandler(void) 00070 { 00071 /* In order to detect unexpected events during development, 00072 it is recommended to set a breakpoint on the following instruction. 00073 */ 00074 } 00075 #else /*_RAISONANCE_*/ 00076 00077 /** 00078 * @brief TRAP interrupt routine 00079 * @param None 00080 * @retval None 00081 */ 00082 INTERRUPT_HANDLER_TRAP(TRAP_IRQHandler) 00083 { 00084 /* In order to detect unexpected events during development, 00085 it is recommended to set a breakpoint on the following instruction. 00086 */ 00087 } 00088 #endif /*_COSMIC_*/ 00089 00090 /** 00091 * @brief Top Level Interrupt routine 00092 * @param None 00093 * @retval 00094 * None 00095 */ 00096 INTERRUPT_HANDLER(TLI_IRQHandler, 0) 00097 { 00098 /* In order to detect unexpected events during development, 00099 it is recommended to set a breakpoint on the following instruction. 00100 */ 00101 } 00102 00103 /** 00104 * @brief Auto Wake Up Interrupt routine 00105 * @param None 00106 * @retval 00107 * None 00108 */ 00109 INTERRUPT_HANDLER(AWU_IRQHandler, 1) 00110 { 00111 /* In order to detect unexpected events during development, 00112 it is recommended to set a breakpoint on the following instruction. 00113 */ 00114 } 00115 00116 /** 00117 * @brief Clock Controller Interrupt routine 00118 * @param None 00119 * @retval 00120 * None 00121 */ 00122 INTERRUPT_HANDLER(CLK_IRQHandler, 2) 00123 { 00124 /* In order to detect unexpected events during development, 00125 it is recommended to set a breakpoint on the following instruction. 00126 */ 00127 } 00128 00129 /** 00130 * @brief External Interrupt PORTA Interrupt routine 00131 * @param None 00132 * @retval 00133 * None 00134 */ 00135 INTERRUPT_HANDLER(EXTI_PORTA_IRQHandler, 3) 00136 { 00137 /* In order to detect unexpected events during development, 00138 it is recommended to set a breakpoint on the following instruction. 00139 */ 00140 } 00141 00142 /** 00143 * @brief External Interrupt PORTB Interrupt routine 00144 * @param None 00145 * @retval None 00146 */ 00147 INTERRUPT_HANDLER(EXTI_PORTB_IRQHandler, 4) 00148 { 00149 /* In order to detect unexpected events during development, 00150 it is recommended to set a breakpoint on the following instruction. 00151 */ 00152 } 00153 00154 /** 00155 * @brief External Interrupt PORTC Interrupt routine 00156 * @param None 00157 * @retval 00158 * None 00159 */ 00160 INTERRUPT_HANDLER(EXTI_PORTC_IRQHandler, 5) 00161 { 00162 /* In order to detect unexpected events during development, 00163 it is recommended to set a breakpoint on the following instruction. 00164 */ 00165 } 00166 00167 /** 00168 * @brief External Interrupt PORTD Interrupt routine 00169 * @param None 00170 * @retval 00171 * None 00172 */ 00173 INTERRUPT_HANDLER(EXTI_PORTD_IRQHandler, 6) 00174 { 00175 /* In order to detect unexpected events during development, 00176 it is recommended to set a breakpoint on the following instruction. 00177 */ 00178 } 00179 00180 /** 00181 * @brief External Interrupt PORTE Interrupt routine 00182 * @param None 00183 * @retval 00184 * None 00185 */ 00186 INTERRUPT_HANDLER(EXTI_PORTE_IRQHandler, 7) 00187 { 00188 /* In order to detect unexpected events during development, 00189 it is recommended to set a breakpoint on the following instruction. 00190 */ 00191 } 00192 #ifdef STM8S903 00193 /** 00194 * @brief External Interrupt PORTF Interrupt routine 00195 * @param None 00196 * @retval 00197 * None 00198 */ 00199 INTERRUPT_HANDLER(EXTI_PORTF_IRQHandler, 8) 00200 { 00201 /* In order to detect unexpected events during development, 00202 it is recommended to set a breakpoint on the following instruction. 00203 */ 00204 } 00205 #endif /*STM8S903*/ 00206 00207 #ifdef STM8S208 00208 /** 00209 * @brief CAN RX Interrupt routine 00210 * @param None 00211 * @retval 00212 * None 00213 */ 00214 INTERRUPT_HANDLER(CAN_RX_IRQHandler, 8) 00215 { 00216 /* In order to detect unexpected events during development, 00217 it is recommended to set a breakpoint on the following instruction. 00218 */ 00219 } 00220 00221 /** 00222 * @brief CAN TX Interrupt routine 00223 * @param None 00224 * @retval 00225 * None 00226 */ 00227 INTERRUPT_HANDLER(CAN_TX_IRQHandler, 9) 00228 { 00229 /* In order to detect unexpected events during development, 00230 it is recommended to set a breakpoint on the following instruction. 00231 */ 00232 } 00233 #endif /*STM8S208 || STM8AF52Ax */ 00234 00235 /** 00236 * @brief SPI Interrupt routine 00237 * @param None 00238 * @retval 00239 * None 00240 */ 00241 INTERRUPT_HANDLER(SPI_IRQHandler, 10) 00242 { 00243 /* In order to detect unexpected events during development, 00244 it is recommended to set a breakpoint on the following instruction. 00245 */ 00246 } 00247 00248 /** 00249 * @brief Timer1 Update/Overflow/Trigger/Break Interrupt routine 00250 * @param None 00251 * @retval 00252 * None 00253 */ 00254 INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11) 00255 { 00256 /* In order to detect unexpected events during development, 00257 it is recommended to set a breakpoint on the following instruction. 00258 */ 00259 } 00260 00261 /** 00262 * @brief Timer1 Capture/Compare Interrupt routine 00263 * @param None 00264 * @retval 00265 * None 00266 */ 00267 INTERRUPT_HANDLER(TIM1_CAP_COM_IRQHandler, 12) 00268 { 00269 /* In order to detect unexpected events during development, 00270 it is recommended to set a breakpoint on the following instruction. 00271 */ 00272 } 00273 00274 #ifdef STM8S903 00275 /** 00276 * @brief Timer5 Update/Overflow/Break/Trigger Interrupt routine 00277 * @param None 00278 * @retval 00279 * None 00280 */ 00281 INTERRUPT_HANDLER(TIM5_UPD_OVF_BRK_TRG_IRQHandler, 13) 00282 { 00283 /* In order to detect unexpected events during development, 00284 it is recommended to set a breakpoint on the following instruction. 00285 */ 00286 } 00287 /** 00288 * @brief Timer5 Capture/Compare Interrupt routine 00289 * @param None 00290 * @retval 00291 * None 00292 */ 00293 INTERRUPT_HANDLER(TIM5_CAP_COM_IRQHandler, 14) 00294 { 00295 /* In order to detect unexpected events during development, 00296 it is recommended to set a breakpoint on the following instruction. 00297 */ 00298 } 00299 00300 #else /*STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */ 00301 /** 00302 * @brief Timer2 Update/Overflow/Break Interrupt routine 00303 * @param None 00304 * @retval 00305 * None 00306 */ 00307 INTERRUPT_HANDLER(TIM2_UPD_OVF_BRK_IRQHandler, 13) 00308 { 00309 /* In order to detect unexpected events during development, 00310 it is recommended to set a breakpoint on the following instruction. 00311 */ 00312 } 00313 00314 /** 00315 * @brief Timer2 Capture/Compare Interrupt routine 00316 * @param None 00317 * @retval 00318 * None 00319 */ 00320 INTERRUPT_HANDLER(TIM2_CAP_COM_IRQHandler, 14) 00321 { 00322 /* In order to detect unexpected events during development, 00323 it is recommended to set a breakpoint on the following instruction. 00324 */ 00325 } 00326 #endif /*STM8S903*/ 00327 00328 #if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \ 00329 defined(STM8S005) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8AF626x) 00330 /** 00331 * @brief Timer3 Update/Overflow/Break Interrupt routine 00332 * @param None 00333 * @retval 00334 * None 00335 */ 00336 INTERRUPT_HANDLER(TIM3_UPD_OVF_BRK_IRQHandler, 15) 00337 { 00338 /* In order to detect unexpected events during development, 00339 it is recommended to set a breakpoint on the following instruction. 00340 */ 00341 } 00342 00343 /** 00344 * @brief Timer3 Capture/Compare Interrupt routine 00345 * @param None 00346 * @retval 00347 * None 00348 */ 00349 INTERRUPT_HANDLER(TIM3_CAP_COM_IRQHandler, 16) 00350 { 00351 /* In order to detect unexpected events during development, 00352 it is recommended to set a breakpoint on the following instruction. 00353 */ 00354 } 00355 #endif /*STM8S208, STM8S207 or STM8S105 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */ 00356 00357 #if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \ 00358 defined(STM8S003) || defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8S903) 00359 /** 00360 * @brief UART1 TX Interrupt routine 00361 * @param None 00362 * @retval 00363 * None 00364 */ 00365 INTERRUPT_HANDLER(UART1_TX_IRQHandler, 17) 00366 { 00367 /* In order to detect unexpected events during development, 00368 it is recommended to set a breakpoint on the following instruction. 00369 */ 00370 } 00371 00372 /** 00373 * @brief UART1 RX Interrupt routine 00374 * @param None 00375 * @retval 00376 * None 00377 */ 00378 INTERRUPT_HANDLER(UART1_RX_IRQHandler, 18) 00379 { 00380 /* In order to detect unexpected events during development, 00381 it is recommended to set a breakpoint on the following instruction. 00382 */ 00383 } 00384 #endif /*STM8S208, STM8S207 or STM8S103 or STM8AF62Ax or STM8AF52Ax or STM8S903 */ 00385 00386 /** 00387 * @brief I2C Interrupt routine 00388 * @param None 00389 * @retval 00390 * None 00391 */ 00392 INTERRUPT_HANDLER(I2C_IRQHandler, 19) 00393 { 00394 switch (I2C_GetLastEvent()) 00395 { 00396 /* EV5 */ 00397 case I2C_EVENT_MASTER_MODE_SELECT : 00398 00399 #ifdef TEN_BITS_ADDRESS 00400 /* Send Header to Slave for write */ 00401 I2C_SendData(HEADER_ADDRESS_Write); 00402 break; 00403 00404 /* EV9 */ 00405 case I2C_EVENT_MASTER_MODE_ADDRESS10: 00406 /* Send slave Address for write */ 00407 I2C_Send7bitAddress(SLAVE_ADDRESS, I2C_DIRECTION_TX); 00408 break; 00409 #else 00410 /* Send slave Address for write */ 00411 I2C_Send7bitAddress(SLAVE_ADDRESS, I2C_DIRECTION_TX); 00412 break; 00413 #endif 00414 /* EV6 */ 00415 case I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED: 00416 if (NumOfBytes != 0) 00417 { 00418 /* Send the first Data */ 00419 I2C_SendData(TxBuffer[Tx_Idx++]); 00420 00421 /* Decrement number of bytes */ 00422 NumOfBytes--; 00423 } 00424 if (NumOfBytes == 0) 00425 { 00426 I2C_ITConfig(I2C_IT_BUF, DISABLE); 00427 } 00428 break; 00429 00430 /* EV8 */ 00431 case I2C_EVENT_MASTER_BYTE_TRANSMITTING: 00432 /* Transmit Data */ 00433 I2C_SendData(TxBuffer[Tx_Idx++]); 00434 00435 /* Decrement number of bytes */ 00436 NumOfBytes--; 00437 00438 if (NumOfBytes == 0) 00439 { 00440 I2C_ITConfig(I2C_IT_BUF, DISABLE); 00441 } 00442 break; 00443 00444 /* EV8_2 */ 00445 case I2C_EVENT_MASTER_BYTE_TRANSMITTED: 00446 /* Send STOP condition */ 00447 I2C_GenerateSTOP(ENABLE); 00448 00449 I2C_ITConfig(I2C_IT_EVT, DISABLE); 00450 break; 00451 00452 default: 00453 break; 00454 } 00455 } 00456 00457 #if defined(STM8S105) || defined(STM8S005) || defined (STM8AF626x) 00458 /** 00459 * @brief UART2 TX interrupt routine. 00460 * @param None 00461 * @retval 00462 * None 00463 */ 00464 INTERRUPT_HANDLER(UART2_TX_IRQHandler, 20) 00465 { 00466 /* In order to detect unexpected events during development, 00467 it is recommended to set a breakpoint on the following instruction. 00468 */ 00469 } 00470 00471 /** 00472 * @brief UART2 RX interrupt routine. 00473 * @param None 00474 * @retval 00475 * None 00476 */ 00477 INTERRUPT_HANDLER(UART2_RX_IRQHandler, 21) 00478 { 00479 /* In order to detect unexpected events during development, 00480 it is recommended to set a breakpoint on the following instruction. 00481 */ 00482 } 00483 #endif /* STM8S105*/ 00484 00485 #if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) 00486 /** 00487 * @brief UART3 TX interrupt routine. 00488 * @param None 00489 * @retval 00490 * None 00491 */ 00492 INTERRUPT_HANDLER(UART3_TX_IRQHandler, 20) 00493 { 00494 /* In order to detect unexpected events during development, 00495 it is recommended to set a breakpoint on the following instruction. 00496 */ 00497 } 00498 00499 /** 00500 * @brief UART3 RX interrupt routine. 00501 * @param None 00502 * @retval 00503 * None 00504 */ 00505 INTERRUPT_HANDLER(UART3_RX_IRQHandler, 21) 00506 { 00507 /* In order to detect unexpected events during development, 00508 it is recommended to set a breakpoint on the following instruction. 00509 */ 00510 } 00511 #endif /*STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax */ 00512 00513 #if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax) 00514 /** 00515 * @brief ADC2 interrupt routine. 00516 * @param None 00517 * @retval 00518 * None 00519 */ 00520 INTERRUPT_HANDLER(ADC2_IRQHandler, 22) 00521 { 00522 /* In order to detect unexpected events during development, 00523 it is recommended to set a breakpoint on the following instruction. 00524 */ 00525 } 00526 #else /*STM8S105, STM8S103 or STM8S903 or STM8AF626x */ 00527 /** 00528 * @brief ADC1 interrupt routine. 00529 * @param None 00530 * @retval None 00531 */ 00532 INTERRUPT_HANDLER(ADC1_IRQHandler, 22) 00533 { 00534 /* In order to detect unexpected events during development, 00535 it is recommended to set a breakpoint on the following instruction. 00536 */ 00537 } 00538 #endif /*STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax */ 00539 00540 #ifdef STM8S903 00541 /** 00542 * @brief Timer6 Update/Overflow/Trigger Interrupt routine 00543 * @param None 00544 * @retval 00545 * None 00546 */ 00547 INTERRUPT_HANDLER(TIM6_UPD_OVF_TRG_IRQHandler, 23) 00548 { 00549 /* In order to detect unexpected events during development, 00550 it is recommended to set a breakpoint on the following instruction. 00551 */ 00552 } 00553 #else /*STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */ 00554 /** 00555 * @brief Timer4 Update/Overflow Interrupt routine 00556 * @param None 00557 * @retval 00558 * None 00559 */ 00560 INTERRUPT_HANDLER(TIM4_UPD_OVF_IRQHandler, 23) 00561 { 00562 /* In order to detect unexpected events during development, 00563 it is recommended to set a breakpoint on the following instruction. 00564 */ 00565 } 00566 #endif /*STM8S903*/ 00567 00568 /** 00569 * @brief Eeprom EEC Interrupt routine 00570 * @param None 00571 * @retval 00572 * None 00573 */ 00574 INTERRUPT_HANDLER(EEPROM_EEC_IRQHandler, 24) 00575 { 00576 /* In order to detect unexpected events during development, 00577 it is recommended to set a breakpoint on the following instruction. 00578 */ 00579 } 00580 00581 /** 00582 * @} 00583 */ 00584 00585 00586 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/