text: /* USER CODE BEGIN Header */
  /**
    ******************************************************************************
    * @file    stm32l0xx_it.c
    * @brief   Interrupt Service Routines.
    ******************************************************************************
    * @attention
    *
    * <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
    * All rights reserved.</center></h2>
    *
    * This software component is licensed by ST under Ultimate Liberty license
    * SLA0044, the "License"; You may not use this file except in compliance with
    * the License. You may obtain a copy of the License at:
    *                             www.st.com/SLA0044
    *
    ******************************************************************************
    */
  /* USER CODE END Header */
  
  /* Includes ------------------------------------------------------------------*/
  #include "generic_hal.h"
  #include "stm32l0xx_it.h"
  #include "amk_printf.h"
  /* Private includes ----------------------------------------------------------*/
  /* USER CODE BEGIN Includes */
  /* USER CODE END Includes */
  
  /* Private typedef -----------------------------------------------------------*/
  /* USER CODE BEGIN TD */
  
  /* USER CODE END TD */
  
  /* Private define ------------------------------------------------------------*/
  /* USER CODE BEGIN PD */
  
  /* USER CODE END PD */
  
  /* Private macro -------------------------------------------------------------*/
  /* USER CODE BEGIN PM */
  
  /* USER CODE END PM */
  
  /* Private variables ---------------------------------------------------------*/
  /* USER CODE BEGIN PV */
  
  /* USER CODE END PV */
  
  /* Private function prototypes -----------------------------------------------*/
  /* USER CODE BEGIN PFP */
  
  /* USER CODE END PFP */
  
  /* Private user code ---------------------------------------------------------*/
  /* USER CODE BEGIN 0 */
  
  /* USER CODE END 0 */
  
  /* External variables --------------------------------------------------------*/
  extern PCD_HandleTypeDef hpcd_USB_FS;
  extern DMA_HandleTypeDef hdma_usart1_rx;
  extern DMA_HandleTypeDef hdma_usart1_tx;
  extern UART_HandleTypeDef huart1;
  /* USER CODE BEGIN EV */
  
  /* USER CODE END EV */
  
  /******************************************************************************/
  /*           Cortex-M0+ Processor Interruption and Exception Handlers          */
  /******************************************************************************/
  
  /**
    * @brief This function handles System service call via SWI instruction.
    */
  void SVC_Handler(void)
  {
    /* USER CODE BEGIN SVC_IRQn 0 */
  
    /* USER CODE END SVC_IRQn 0 */
    /* USER CODE BEGIN SVC_IRQn 1 */
  
    /* USER CODE END SVC_IRQn 1 */
  }
  
  /**
    * @brief This function handles Pendable request for system service.
    */
  void PendSV_Handler(void)
  {
    /* USER CODE BEGIN PendSV_IRQn 0 */
  
    /* USER CODE END PendSV_IRQn 0 */
    /* USER CODE BEGIN PendSV_IRQn 1 */
  
    /* USER CODE END PendSV_IRQn 1 */
  }
  
  /**
    * @brief This function handles System tick timer.
    */
  //void SysTick_Handler(void)
  //{
    /* USER CODE BEGIN SysTick_IRQn 0 */
  
    /* USER CODE END SysTick_IRQn 0 */
  //  HAL_IncTick();
    /* USER CODE BEGIN SysTick_IRQn 1 */
  
    /* USER CODE END SysTick_IRQn 1 */
  //}
  
  /******************************************************************************/
  /* STM32L0xx 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 (startup_stm32l0xx.s).                    */
  /******************************************************************************/
  
  __attribute__((weak)) void uart_recv_char(uint8_t c){}
  
  void uart_error_process(UART_HandleTypeDef * huart, uint32_t isr)
  {
      amk_printf("UART ERROR: 0x%x\n", isr);
      /* UART frame error interrupt occurred --------------------------------------*/
      if ((isr & USART_ISR_FE) != 0U) {
          __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_FEF);
      }
  
      /* UART noise error interrupt occurred --------------------------------------*/
      if ((isr & USART_ISR_NE) != 0U) {
          __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_NEF);
      }
  
      /* UART Over-Run interrupt occurred -----------------------------------------*/
      if ((isr & USART_ISR_ORE) != 0U) {
          __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_OREF);
      }
  }
  
  void USART1_IRQHandler(void)
  {
    uint32_t isr = huart1.Instance->ISR;
    uint32_t cr1 = huart1.Instance->CR1;
    if (((isr & USART_ISR_RXNE) != 0) && ((cr1 & USART_CR1_RXNEIE) != 0))
    {// received one char
      uint8_t d = huart1.Instance->RDR & 0x000000FF;
      uart_recv_char(d);
    }
  
    if (isr & (uint32_t)( USART_ISR_FE | USART_ISR_ORE | USART_ISR_NE )) {
      uart_error_process(&huart1, isr);
    }
   // HAL_UART_IRQHandler(&huart1);
  }
  
  
  /**
    * @brief This function handles USB event interrupt / USB wake-up interrupt through EXTI line 18.
    */
  //void USB_IRQHandler(void)
  //{
    /* USER CODE BEGIN USB_IRQn 0 */
  
    /* USER CODE END USB_IRQn 0 */
  //  HAL_PCD_IRQHandler(&hpcd_USB_FS);
    /* USER CODE BEGIN USB_IRQn 1 */
  
    /* USER CODE END USB_IRQn 1 */
  //}
  
  /* USER CODE BEGIN 1 */
  
  /* USER CODE END 1 */
  /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
  