2024-08-03 03:21:08 -07:00
|
|
|
/********************************** (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)
|
|
|
|
{
|
2024-08-03 19:55:04 -07:00
|
|
|
if (++ticnt > 0x3ff) {
|
2024-08-03 03:21:08 -07:00
|
|
|
ticnt = 0;
|
|
|
|
uptime++;
|
|
|
|
}
|
|
|
|
|
2024-08-03 19:55:04 -07:00
|
|
|
// light sensor updates at ~1ms
|
|
|
|
adc_process_lsens();
|
|
|
|
|
|
|
|
// general processes update at 1/128 duty
|
|
|
|
switch (ticnt & 0x7) {
|
2024-08-03 03:21:08 -07:00
|
|
|
case 0: { // send new LEDs
|
|
|
|
led_rgb_update();
|
|
|
|
led_matrix_send();
|
|
|
|
break;
|
|
|
|
}
|
2024-08-03 19:55:04 -07:00
|
|
|
case 1: { // process buttons
|
2024-08-03 03:21:08 -07:00
|
|
|
btn_poll();
|
2024-08-03 19:55:04 -07:00
|
|
|
break;
|
2024-08-03 03:21:08 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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?
|
|
|
|
}
|