basic button handler routines added, hard buttons tested
touch sensors were also preliminary tested but not all have been analyzed yet.
This commit is contained in:
@@ -26,6 +26,8 @@
|
||||
#include "led/matrix.h"
|
||||
#include "led/ledprog.h"
|
||||
|
||||
#include "ui/btn.h"
|
||||
|
||||
/*
|
||||
*@Note
|
||||
***Only PA0--PA15 and PC16--PC17 support input pull-down.
|
||||
@@ -39,13 +41,13 @@ volatile uint8_t lp_render = 0;
|
||||
|
||||
|
||||
|
||||
void clk_init()
|
||||
inline void clk_init()
|
||||
{
|
||||
SystemCoreClockUpdate();
|
||||
}
|
||||
|
||||
|
||||
void periphclk_init()
|
||||
static inline void periphclk_init()
|
||||
{
|
||||
// needed for GPIO, remap, ADC, SPI
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |
|
||||
@@ -59,7 +61,7 @@ void periphclk_init()
|
||||
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1 | RCC_AHBPeriph_USBPD, ENABLE);
|
||||
}
|
||||
|
||||
void gpio_init()
|
||||
static inline void gpio_init()
|
||||
{
|
||||
GPIO_InitTypeDef gpio = {0};
|
||||
|
||||
@@ -90,7 +92,7 @@ void gpio_init()
|
||||
gpio.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_11 | GPIO_Pin_12;
|
||||
GPIO_Init(GPIOB, &gpio);
|
||||
|
||||
// PC10 USB DP (btn2), PC11 USB DM (unused)
|
||||
// PC16 USB DM (unused), PC17 USB DP (btn2)
|
||||
gpio.GPIO_Mode = GPIO_Mode_IPD;
|
||||
gpio.GPIO_Pin = GPIO_Pin_16 | GPIO_Pin_17;
|
||||
GPIO_Init(GPIOC, &gpio);
|
||||
@@ -105,7 +107,7 @@ void gpio_init()
|
||||
// todo later
|
||||
}
|
||||
|
||||
void awu_init()
|
||||
static inline void awu_init()
|
||||
{
|
||||
NVIC_InitTypeDef nvic;
|
||||
EXTI_InitTypeDef exti = {0};
|
||||
@@ -174,12 +176,13 @@ int main(void)
|
||||
|
||||
// stay a while
|
||||
// __WFI();
|
||||
PWR_EnterSTANDBYMode();
|
||||
// PWR_EnterSTANDBYMode();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AWU_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
|
||||
|
||||
void AWU_IRQHandler(void)
|
||||
{
|
||||
// clear interrupt flag
|
||||
@@ -204,5 +207,6 @@ void AWU_IRQHandler(void)
|
||||
// handle ADC
|
||||
adc_next();
|
||||
|
||||
// handle buttons
|
||||
// handle buttons and touch sensors
|
||||
btn_process();
|
||||
}
|
||||
Reference in New Issue
Block a user