dc32-peppercon9-addon/firmware/user/ch32v20x_it.c

92 lines
2.2 KiB
C
Raw Normal View History

/********************************** (C) COPYRIGHT *******************************
* File Name : ch32v20x_it.c
* Author : WCH
* Version : V1.0.0
* Date : 2023/12/29
* Description : Main Interrupt Service Routines.
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#include <stdint.h>
#include <ch32v20x.h>
#include "ch32v20x_it.h"
#include "src/adc.h"
#include "src/btn.h"
#include "src/led.h"
#include "src/ui.h"
void NMI_Handler(void); //__attribute__((interrupt("WCH-Interrupt-fast")));
void HardFault_Handler(void); //__attribute__((interrupt("WCH-Interrupt-fast")));
void SysTick_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
/*********************************************************************
* @fn NMI_Handler
*
* @brief This function handles NMI exception.
*
* @return none
*/
void NMI_Handler(void)
{
while (1);
}
/*********************************************************************
* @fn HardFault_Handler
*
* @brief This function handles Hard Fault exception.
*
* @return none
*/
void HardFault_Handler(void)
{
while (1);
}
volatile uint16_t ticnt;
volatile uint32_t uptime;
void SysTick_Handler(void)
{
if (++ticnt > 0x3ff) {
ticnt = 0;
uptime++;
}
// light sensor updates at ~1ms
adc_process_lsens();
// general processes update at 1/128 duty
switch (ticnt & 0x7) {
case 0: { // send new LEDs
led_rgb_update();
led_matrix_send();
break;
}
case 1: { // process buttons
btn_poll();
break;
}
}
// clear comparison flag
SysTick->SR = 0;
return;
}
// accelerometer interrupt handler
void EXTI15_10_IRQHandler(void)
{
// now what the fuck triggered this shit
// oh right something on the accelerometer. but what though?
}