2024-04-11 17:32:58 +08:00
|
|
|
/* add user code begin Header */
|
|
|
|
|
/**
|
2024-04-19 17:16:24 +08:00
|
|
|
**************************************************************************
|
|
|
|
|
* @file at32f413_int.c
|
|
|
|
|
* @brief main interrupt service routines.
|
|
|
|
|
**************************************************************************
|
|
|
|
|
* Copyright notice & Disclaimer
|
|
|
|
|
*
|
|
|
|
|
* The software Board Support Package (BSP) that is made available to
|
|
|
|
|
* download from Artery official website is the copyrighted work of Artery.
|
|
|
|
|
* Artery authorizes customers to use, copy, and distribute the BSP
|
|
|
|
|
* software and its related documentation for the purpose of design and
|
|
|
|
|
* development in conjunction with Artery microcontrollers. Use of the
|
|
|
|
|
* software is governed by this copyright notice and the following disclaimer.
|
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
|
|
|
|
* GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
|
|
|
|
|
* TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
|
|
|
|
|
* STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
|
|
|
|
|
* INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
|
|
|
|
*
|
|
|
|
|
**************************************************************************
|
|
|
|
|
*/
|
2024-04-11 17:32:58 +08:00
|
|
|
/* add user code end Header */
|
|
|
|
|
|
|
|
|
|
/* includes ------------------------------------------------------------------*/
|
|
|
|
|
#include "at32f413_int.h"
|
|
|
|
|
|
|
|
|
|
/* private includes ----------------------------------------------------------*/
|
|
|
|
|
/* add user code begin private includes */
|
2024-04-19 17:16:24 +08:00
|
|
|
#include "by_motion.h"
|
2024-04-11 17:32:58 +08:00
|
|
|
/* add user code end private includes */
|
|
|
|
|
|
|
|
|
|
/* private typedef -----------------------------------------------------------*/
|
|
|
|
|
/* add user code begin private typedef */
|
|
|
|
|
|
|
|
|
|
/* add user code end private typedef */
|
|
|
|
|
|
|
|
|
|
/* private define ------------------------------------------------------------*/
|
|
|
|
|
/* add user code begin private define */
|
|
|
|
|
|
|
|
|
|
/* add user code end private define */
|
|
|
|
|
|
|
|
|
|
/* private macro -------------------------------------------------------------*/
|
|
|
|
|
/* add user code begin private macro */
|
|
|
|
|
|
|
|
|
|
/* add user code end private macro */
|
|
|
|
|
|
|
|
|
|
/* private variables ---------------------------------------------------------*/
|
|
|
|
|
/* add user code begin private variables */
|
|
|
|
|
|
|
|
|
|
/* add user code end private variables */
|
|
|
|
|
|
|
|
|
|
/* private function prototypes --------------------------------------------*/
|
|
|
|
|
/* add user code begin function prototypes */
|
|
|
|
|
|
|
|
|
|
/* add user code end function prototypes */
|
|
|
|
|
|
|
|
|
|
/* private user code ---------------------------------------------------------*/
|
|
|
|
|
/* add user code begin 0 */
|
|
|
|
|
|
|
|
|
|
/* add user code end 0 */
|
|
|
|
|
|
|
|
|
|
/* external variables ---------------------------------------------------------*/
|
|
|
|
|
/* add user code begin external variables */
|
|
|
|
|
|
|
|
|
|
/* add user code end external variables */
|
|
|
|
|
|
|
|
|
|
/**
|
2024-04-19 17:16:24 +08:00
|
|
|
* @brief this function handles nmi exception.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
2024-04-11 17:32:58 +08:00
|
|
|
void NMI_Handler(void)
|
|
|
|
|
{
|
|
|
|
|
/* add user code begin NonMaskableInt_IRQ 0 */
|
|
|
|
|
|
|
|
|
|
/* add user code end NonMaskableInt_IRQ 0 */
|
|
|
|
|
|
|
|
|
|
/* add user code begin NonMaskableInt_IRQ 1 */
|
|
|
|
|
|
|
|
|
|
/* add user code end NonMaskableInt_IRQ 1 */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2024-04-19 17:16:24 +08:00
|
|
|
* @brief this function handles hard fault exception.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
2024-04-11 17:32:58 +08:00
|
|
|
void HardFault_Handler(void)
|
|
|
|
|
{
|
|
|
|
|
/* add user code begin HardFault_IRQ 0 */
|
|
|
|
|
|
|
|
|
|
/* add user code end HardFault_IRQ 0 */
|
|
|
|
|
/* go to infinite loop when hard fault exception occurs */
|
2024-04-19 17:16:24 +08:00
|
|
|
while (1) {
|
2024-04-11 17:32:58 +08:00
|
|
|
/* add user code begin W1_HardFault_IRQ 0 */
|
|
|
|
|
|
|
|
|
|
/* add user code end W1_HardFault_IRQ 0 */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2024-04-19 17:16:24 +08:00
|
|
|
* @brief this function handles memory manage exception.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
2024-04-11 17:32:58 +08:00
|
|
|
void MemManage_Handler(void)
|
|
|
|
|
{
|
|
|
|
|
/* add user code begin MemoryManagement_IRQ 0 */
|
|
|
|
|
|
|
|
|
|
/* add user code end MemoryManagement_IRQ 0 */
|
|
|
|
|
/* go to infinite loop when memory manage exception occurs */
|
2024-04-19 17:16:24 +08:00
|
|
|
while (1) {
|
2024-04-11 17:32:58 +08:00
|
|
|
/* add user code begin W1_MemoryManagement_IRQ 0 */
|
|
|
|
|
|
|
|
|
|
/* add user code end W1_MemoryManagement_IRQ 0 */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2024-04-19 17:16:24 +08:00
|
|
|
* @brief this function handles bus fault exception.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
2024-04-11 17:32:58 +08:00
|
|
|
void BusFault_Handler(void)
|
|
|
|
|
{
|
|
|
|
|
/* add user code begin BusFault_IRQ 0 */
|
|
|
|
|
|
|
|
|
|
/* add user code end BusFault_IRQ 0 */
|
|
|
|
|
/* go to infinite loop when bus fault exception occurs */
|
2024-04-19 17:16:24 +08:00
|
|
|
while (1) {
|
2024-04-11 17:32:58 +08:00
|
|
|
/* add user code begin W1_BusFault_IRQ 0 */
|
|
|
|
|
|
|
|
|
|
/* add user code end W1_BusFault_IRQ 0 */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2024-04-19 17:16:24 +08:00
|
|
|
* @brief this function handles usage fault exception.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
2024-04-11 17:32:58 +08:00
|
|
|
void UsageFault_Handler(void)
|
|
|
|
|
{
|
|
|
|
|
/* add user code begin UsageFault_IRQ 0 */
|
|
|
|
|
|
|
|
|
|
/* add user code end UsageFault_IRQ 0 */
|
|
|
|
|
/* go to infinite loop when usage fault exception occurs */
|
2024-04-19 17:16:24 +08:00
|
|
|
while (1) {
|
2024-04-11 17:32:58 +08:00
|
|
|
/* add user code begin W1_UsageFault_IRQ 0 */
|
|
|
|
|
|
|
|
|
|
/* add user code end W1_UsageFault_IRQ 0 */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2024-04-19 17:16:24 +08:00
|
|
|
* @brief this function handles svcall exception.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
2024-04-11 17:32:58 +08:00
|
|
|
void SVC_Handler(void)
|
|
|
|
|
{
|
|
|
|
|
/* add user code begin SVCall_IRQ 0 */
|
|
|
|
|
|
|
|
|
|
/* add user code end SVCall_IRQ 0 */
|
|
|
|
|
/* add user code begin SVCall_IRQ 1 */
|
|
|
|
|
|
|
|
|
|
/* add user code end SVCall_IRQ 1 */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2024-04-19 17:16:24 +08:00
|
|
|
* @brief this function handles debug monitor exception.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
2024-04-11 17:32:58 +08:00
|
|
|
void DebugMon_Handler(void)
|
|
|
|
|
{
|
|
|
|
|
/* add user code begin DebugMonitor_IRQ 0 */
|
|
|
|
|
|
|
|
|
|
/* add user code end DebugMonitor_IRQ 0 */
|
|
|
|
|
/* add user code begin DebugMonitor_IRQ 1 */
|
|
|
|
|
|
|
|
|
|
/* add user code end DebugMonitor_IRQ 1 */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2024-04-19 17:16:24 +08:00
|
|
|
* @brief this function handles pendsv_handler exception.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
2024-04-11 17:32:58 +08:00
|
|
|
void PendSV_Handler(void)
|
|
|
|
|
{
|
|
|
|
|
/* add user code begin PendSV_IRQ 0 */
|
|
|
|
|
|
|
|
|
|
/* add user code end PendSV_IRQ 0 */
|
|
|
|
|
/* add user code begin PendSV_IRQ 1 */
|
|
|
|
|
|
|
|
|
|
/* add user code end PendSV_IRQ 1 */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2024-04-19 17:16:24 +08:00
|
|
|
* @brief this function handles TMR4 handler.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
2024-04-11 17:32:58 +08:00
|
|
|
void TMR4_GLOBAL_IRQHandler(void)
|
|
|
|
|
{
|
|
|
|
|
/* add user code begin TMR4_GLOBAL_IRQ 0 */
|
2024-04-19 17:16:24 +08:00
|
|
|
if (SET == tmr_interrupt_flag_get(TMR4, TMR_OVF_FLAG)) {
|
|
|
|
|
by_motion_get_speed_m1();
|
|
|
|
|
by_motion_get_speed_m2();
|
|
|
|
|
tmr_flag_clear(TMR4, TMR_OVF_FLAG);
|
|
|
|
|
}
|
2024-04-11 17:32:58 +08:00
|
|
|
/* add user code end TMR4_GLOBAL_IRQ 0 */
|
|
|
|
|
/* add user code begin TMR4_GLOBAL_IRQ 1 */
|
|
|
|
|
|
|
|
|
|
/* add user code end TMR4_GLOBAL_IRQ 1 */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* add user code begin 1 */
|
|
|
|
|
|
|
|
|
|
/* add user code end 1 */
|