/** ****************************************************************************** * @file py32f002b_it.c * @author MCU Application Team * @brief Interrupt Service Routines. ****************************************************************************** * @attention * *

© Copyright (c) 2023 Puya Semiconductor Co. * All rights reserved.

* * This software component is licensed by Puya under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** * @attention * *

© Copyright (c) 2016 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "py32f002b_it.h" /* Private includes ----------------------------------------------------------*/ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ extern unsigned int ADC_RE[]; extern unsigned char flag; extern unsigned int ADC_CH1_RE; extern unsigned int ADC_CH2_RE; extern unsigned int ADC_CH3_RE; extern unsigned int ADC_CH4_RE; extern unsigned int State; unsigned char i = 0; unsigned char j = 0; unsigned char *pBuffPtr = 0; unsigned short int XferCount = 0; /* Private function prototypes -----------------------------------------------*/ /* Private user code ---------------------------------------------------------*/ /* External variables --------------------------------------------------------*/ /******************************************************************************/ /* Cortex-M0+ Processor Interruption and Exception Handlers */ /******************************************************************************/ void ADC_COMP_IRQHandler(void) { /* Clear ADC EOC IT flag */ LL_ADC_ClearFlag_EOC(ADC1); ADC_RE[i++]=ADC1->DR; if(i >= 4){ i = 0; } } /** * @brief This function handles Non maskable interrupt. */ void NMI_Handler(void) { } /** * @brief This function handles Hard fault interrupt. */ void HardFault_Handler(void) { while (1) { } } /** * @brief This function handles System service call via SWI instruction. */ void SVC_Handler(void) { } /** * @brief This function handles Pendable request for system service. */ void PendSV_Handler(void) { } /** * @brief This function handles System tick timer. */ void SysTick_Handler(void) { } /******************************************************************************/ /* PY32F002B Peripheral Interrupt Handlers */ /* Add here the Interrupt Handlers for the used peripherals. */ /* For the available peripheral interrupt handler names, */ /* please refer to the startup file. */ /******************************************************************************/ /************************ (C) COPYRIGHT Puya *****END OF FILE******************/ /******************************************************************************/ /* PY32F002B Peripheral Interrupt Handlers */ /* Add here the Interrupt Handlers for the used peripherals. */ /* For the available peripheral interrupt handler names, */ /* please refer to the startup file. */ /******************************************************************************/ /** * @brief This function handles SPI1. */ void SPI1_IRQHandler(void) { /* Check RXNE bit if is set */ if(LL_SPI_IsActiveFlag_RXNE(SPI1)) { /* Call receive callback */ APP_SpiRxCallback(); } /* Check TxE bit if is set */ else if(LL_SPI_IsActiveFlag_TXE(SPI1)) { /* Call send callback */ APP_SpiTxCallback(); } /* Check OVR bit if is set */ else if(LL_SPI_IsActiveFlag_OVR(SPI1)) { /* Call error callback */ APP_SpiTransferErrorCallback(); } } /******************************************************************************/ /* PY32F002B Peripheral Interrupt Handlers */ /* Add here the Interrupt Handlers for the used peripherals. */ /* For the available peripheral interrupt handler names, */ /* please refer to the startup file. */ /******************************************************************************/ /** * @brief This function handles EXTI4_15 interrupt. // */ void EXTI0_1_IRQHandler(void) { /* Handle EXTI interrupt request */ if(LL_EXTI_IsActiveFlag(LL_EXTI_LINE_1)) { LL_EXTI_ClearFlag(LL_EXTI_LINE_1); if(LL_GPIO_IsInputPinSet(GPIOB, LL_GPIO_PIN_1)){ LL_SPI_Disable(SPI1); APP_Spi_CS_EN(0); }else{ LL_SPI_Enable(SPI1); APP_Spi_CS_EN(1); } } }