|
- /**
- ******************************************************************************
- * @file stm32f4xx_it.c
- * @author MCD Application Team
- * @version V1.0.0
- * @date Apr-2013
- * @brief Main Interrupt Service Routines.
- * This file provides template for all exceptions handler and
- * peripherals interrupt service routine.
- ******************************************************************************
- * @attention
- *
- * <h2><center>© COPYRIGHT 2013 STMicroelectronics</center></h2>
- *
- * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
- * You may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.st.com/software_license_agreement_liberty_v2
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************************
- */
-
- /* Includes ------------------------------------------------------------------*/
- #include "stm32f4xx_it.h"
- #include "ucos_ii.h"
- //#include "stm32f4xx_STLlib.h"
- //#include "stm32f4xx_STLclassBvar.h"
- #if defined STL_EVAL_MODE
- #if defined (USE_STM324xG_EVAL)
- #include "stm324xg_eval.h"
- #else /* USE_STM324x7I_EVAL */
- #include "stm324x7i_eval.h"
- #endif
- #endif /* STL_EVAL_MODE */
- #ifdef STL_VERBOSE
- #include <stdio.h>
- #endif /* STL_VERBOSE */
-
-
- /** @addtogroup STM32F4xx_IEC60335_Example
-
- * @{
- */
-
- /* Private typedef -----------------------------------------------------------*/
- /* Private define ------------------------------------------------------------*/
- /* Private macro -------------------------------------------------------------*/
- /* Private variables ---------------------------------------------------------*/
- uint32_t tmpCC4_last; /* keep last TIM5/Chn4 captured value */
- /* Private function prototypes -----------------------------------------------*/
- /* Private functions ---------------------------------------------------------*/
-
- /******************************************************************************/
- /* Cortex-M4 Processor Exceptions Handlers */
- /******************************************************************************/
-
- /**
- * @brief This function handles NMI exception.
- * @param : None
- * @retval : None
- */
- void NMI_Handler(void)
- {
- #ifdef STL_VERBOSE
- if (RCC_GetITStatus(RCC_IT_CSS) == SET)
- {
- while(USART_GetFlagStatus(EVAL_COM1, USART_FLAG_TC) == RESET)
- { /* Wait previous transmission completion */
- }
- /* Re-configure USART baud rate to have 115200 bds with HSI clock (8MHz) */
- EVAL_COM1->BRR = 0x45u;
- printf("\n\r Clock Source failure (Clock Security System)\n\r");
- }
- else
- {
- printf("\n\r NMI Exception\n\r");
- }
- #endif /* STL_VERBOSE */
-
- /* Go to infinite loop when NMI Exception occurs */
- while (1)
- {
- }
- }
-
- /******************************************************************************/
- /**
- * @brief This function handles Hard Fault exception.
- * @param : None
- * @retval : None
- */
- void HardFault_Handler(void)
- {
- #ifdef STL_VERBOSE
- printf("\n\r Hard fault Exception \n\r");
- #endif /* STL_VERBOSE */
- /* Go to infinite loop when Hard Fault exception occurs */
- while (1)
- {
- }
- }
-
- /******************************************************************************/
- /**
- * @brief This function handles Memory Manage exception.
- * @param : None
- * @retval : None
- */
- void MemManage_Handler(void)
- {
- #ifdef STL_VERBOSE
- printf("\n\r Mem manage Exception \n\r");
- #endif /* STL_VERBOSE */
- /* Go to infinite loop when Memory Manage exception occurs */
- while (1)
- {
- }
- }
-
- /******************************************************************************/
- /**
- * @brief This function handles Bus Fault exception.
- * @param : None
- * @retval : None
- */
- void BusFault_Handler(void)
- {
- #ifdef STL_VERBOSE
- printf("\n\r Bus fault Exception \n\r");
- #endif /* STL_VERBOSE */
- /* Go to infinite loop when Bus Fault exception occurs */
- while (1)
- {
- }
- }
-
- /******************************************************************************/
- /**
- * @brief This function handles Usage Fault exception.
- * @param : None
- * @retval : None
- */
- void UsageFault_Handler(void)
- {
- #ifdef STL_VERBOSE
- printf("\n\r Usage fault Exception \n\r");
- #endif /* STL_VERBOSE */
- /* Go to infinite loop when Usage Fault exception occurs */
- while (1)
- {
- }
- }
-
- /******************************************************************************/
- /**
- * @brief This function handles SVCall exception.
- * @param : None
- * @retval : None
- */
- void SVC_Handler(void)
- {
- #ifdef STL_VERBOSE
- printf("\n\r SVCall Exception \n\r");
- #endif /* STL_VERBOSE */
- }
-
- /******************************************************************************/
- /**
- * @brief This function handles Debug Monitor exception.
- * @param : None
- * @retval : None
- */
- void DebugMon_Handler(void)
- {
- #ifdef STL_VERBOSE
- printf("\n\r Debug Monitor Exception \n\r");
- #endif /* STL_VERBOSE */
- }
-
- /******************************************************************************/
- /**
- * @brief This function handles PendSVC exception.
- * @param : None
- * @retval : None
- */
- void PendSV_Handler(void)
- {
- #ifdef STL_VERBOSE
- printf("\n\r PendSVC Exception \n\r");
- #endif /* STL_VERBOSE */
- }
-
- /******************************************************************************/
- /**
- * @brief This function handles SysTick Handler.
- * @param : None
- * @retval : None
- */
- void SysTick_Handler(void)
- {
- // #if defined STL_EVAL_MODE
- // /* Toggle LED2 for debug purposes */
- // STM_EVAL_LEDToggle(LED2);
- // #endif /* STL_EVAL_MODE */
- OSIntEnter();
- OSTimeTick();
- OSIntExit();
-
- // /* Verify TickCounter integrity */
- // if ((TickCounter ^ TickCounterInv) == 0xFFFFFFFFuL)
- // {
- // TickCounter++;
- // TickCounterInv = ~TickCounter;
- //
- // if (TickCounter >= SYSTICK_10ms_TB)
- // {
- // uint32_t RamTestResult;
- //
- // /* Reset timebase counter */
- // TickCounter = 0u;
- // TickCounterInv = 0xFFFFFFFF;
- //
- // /* Set Flag read in main loop */
- // TimeBaseFlag = 0xAAAAAAAAu;
- // TimeBaseFlagInv = 0x55555555u;
- //
- // #ifndef USE_MARCHX_RAM_TEST
- // ISRCtrlFlowCnt += RAM_MARCHC_ISR_CALLER;
- // RamTestResult = STL_TranspMarchC();
- // ISRCtrlFlowCntInv -= RAM_MARCHC_ISR_CALLER;
- // #else
- // ISRCtrlFlowCnt += RAM_MARCHX_ISR_CALLER;
- // RamTestResult = STL_TranspMarchX();
- // ISRCtrlFlowCntInv -= RAM_MARCHX_ISR_CALLER;
- // #endif /* USE_MARCHX_RAM_TEST */
- //
- // switch ( RamTestResult )
- // {
- // case TEST_RUNNING:
- // break;
- // case TEST_OK:
- // #ifdef STL_VERBOSE
- // /* avoid any long string output here in the interrupt, '#' marks ram test completed ok */
- // putchar((int)'#');
- // #endif /* STL_VERBOSE */
- // #ifdef STL_EVAL_MODE
- // /* Toggle LED2 for debug purposes */
- // STM_EVAL_LEDToggle(LED2);
- // #endif /* STL_EVAL_MODE */
- // break;
- // case TEST_FAILURE:
- // case CLASS_B_DATA_FAIL:
- // default:
- // #ifdef STL_VERBOSE
- // printf("\n\r >>>>>>>>>>>>>>>>>>> RAM Error (March C- Run-time check)\n\r");
- // #endif /* STL_VERBOSE */
- // FailSafePOR();
- // break;
- // } /* End of the switch */
- //
- // /* Do we reached the end of RAM test? */
- // /* Verify 1st ISRCtrlFlowCnt integrity */
- // if ((ISRCtrlFlowCnt ^ ISRCtrlFlowCntInv) == 0xFFFFFFFFuL)
- // {
- // if (RamTestResult == TEST_OK)
- // {
- // /* ==============================================================================*/
- // /* MISRA violation of rule 17.4 - pointer arithmetic is used to check RAM test control flow */
- // #ifdef __IAR_SYSTEMS_ICC__ /* IAR Compiler */
- // #pragma diag_suppress=Pm088
- // #endif /* __IAR_SYSTEMS_ICC__ */
- // if (ISRCtrlFlowCnt != RAM_TEST_COMPLETED)
- // #ifdef __IAR_SYSTEMS_ICC__ /* IAR Compiler */
- // #pragma diag_default=Pm088
- // #endif /* __IAR_SYSTEMS_ICC__ */
- // /* ==============================================================================*/
- // {
- // #ifdef STL_VERBOSE
- // printf("\n\r Control Flow error (RAM test) \n\r");
- // #endif /* STL_VERBOSE */
- // FailSafePOR();
- // }
- // else /* Full RAM was scanned */
- // {
- // ISRCtrlFlowCnt = 0u;
- // ISRCtrlFlowCntInv = 0xFFFFFFFF;
- // }
- // } /* End of RAM completed if*/
- // } /* End of control flow monitoring */
- // else
- // {
- // #ifdef STL_VERBOSE
- // printf("\n\r Control Flow error in ISR \n\r");
- // #endif /* STL_VERBOSE */
- // FailSafePOR();
- // }
- // } /* End of the 10 ms timebase interrupt */
- // }
- // else /* Class B variable TickCounter integrity error */
- // {
- // #ifdef STL_VERBOSE
- // printf("\n\r Class B Error on TickCounter\n\r");
- // #endif /* STL_VERBOSE */
- // FailSafePOR();
- // }
- //
- // #if defined STL_EVAL_MODE
- // /* Toggle LED2 for debug purposes */
- // STM_EVAL_LEDToggle(LED2);
- // #endif /* STL_EVAL_MODE */
- }
-
- /******************************************************************************/
- /**
- * @brief This function handles TIM5 global interrupt request.
- * @param : None
- * @retval : None
- */
- //void TIM5_IRQHandler(void)
- //{
- // uint32_t tmpCC4_last_cpy;
- //
- // if ((TIM5->SR & TIM_SR_CC4IF) != 0u )
- // {
- // /* store previous captured value */
- // tmpCC4_last_cpy = tmpCC4_last;
- // /* get currently captured value */
- // tmpCC4_last = TIM5->CCR4;
- // /* The CC4IF flag is already cleared here be reading CCR4 register */
- //
- // /* overight results only in case the data is required */
- // if (LSIPeriodFlag == 0u)
- // {
- // /* take correct measurement only */
- // if ((TIM5->SR & TIM_SR_CC4OF) == 0u)
- // {
- // /* Compute period length */
- // PeriodValue = tmpCC4_last - tmpCC4_last_cpy;
- // PeriodValueInv = ~PeriodValue;
- //
- // /* Set Flag tested at main loop */
- // LSIPeriodFlag = 0xAAAAAAAAu;
- // LSIPeriodFlagInv = 0x55555555u;
- // }
- // else
- // {
- // /* ignore computation in case of IC overflow */
- // TIM5->SR &= (uint16_t)(~TIM_SR_CC4OF);
- // }
- // /* ignore computation in case data is not required */
- // }
- // }
- //}
-
- /**
- * @}
- */
-
-
- /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|