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

96 lines
2.3 KiB
C

/********************************** (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 > 0x1ff) {
ticnt = 0;
uptime++;
}
// all processes update at 1/128 duty
switch (ticnt & 0x3) {
case 0: { // send new LEDs
led_rgb_update();
led_matrix_send();
break;
}
case 1: { // process / initialize light sensor
adc_process_lsens(0);
break;
}
case 2: { // convert light sensor
adc_process_lsens(1);
break;
}
case 3: { // process buttons
btn_poll();
}
}
// 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?
}