Testing keyboard poll
This commit is contained in:
17
firmware/Core/Inc/inputs.h
Normal file
17
firmware/Core/Inc/inputs.h
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* inputs.h
|
||||
*
|
||||
* Created on: Oct 29, 2022
|
||||
* Author: mcfly
|
||||
*/
|
||||
|
||||
#ifndef INC_INPUTS_H_
|
||||
#define INC_INPUTS_H_
|
||||
|
||||
|
||||
#include "stm32g0xx_hal.h"
|
||||
|
||||
//Timers interrupts
|
||||
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim);
|
||||
|
||||
#endif /* INC_INPUTS_H_ */
|
53
firmware/Core/Src/inputs.c
Normal file
53
firmware/Core/Src/inputs.c
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* inputs.c
|
||||
*
|
||||
* Created on: Oct 29, 2022
|
||||
* Author: mcfly
|
||||
*/
|
||||
#include "inputs.h"
|
||||
#include "st7789.h"
|
||||
|
||||
#define BTNPRT GPIOC
|
||||
#define ENCBTNPRT BGIOB
|
||||
#define ENCBTNPRTMASK 0b11001000
|
||||
#define SCRBTNPRT BGIOD
|
||||
#define SCRBTNPRTMASK 0b1110000
|
||||
|
||||
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
|
||||
static uint16_t btnbuff = 0xFFFF;
|
||||
static uint16_t btnprev = 0xFFFF;
|
||||
uint8_t i;
|
||||
uint16_t pin;
|
||||
GPIO_TypeDef *port;
|
||||
|
||||
//check if the interrupt comes from TIM6
|
||||
if(htim->Instance == TIM6) {
|
||||
btnbuff = BTNPRT->IDR;
|
||||
for (i=5; i>=2; i--) {
|
||||
if ( !((btnbuff>>i) & 1) && ((btnprev>>i) & 1) ) {
|
||||
switch (i) {
|
||||
case 5:
|
||||
port = CH1_EN_GPIO_Port;
|
||||
pin = CH1_EN_Pin;
|
||||
break;
|
||||
case 4:
|
||||
port = CH2_EN_GPIO_Port;
|
||||
pin = CH2_EN_Pin;
|
||||
break;
|
||||
case 3:
|
||||
port = PWM1_EN_GPIO_Port;
|
||||
pin = PWM1_EN_Pin;
|
||||
break;
|
||||
case 2:
|
||||
port = PWM2_EN_GPIO_Port;
|
||||
pin = PWM2_EN_Pin;
|
||||
break;
|
||||
}
|
||||
HAL_GPIO_TogglePin(port, pin);
|
||||
}
|
||||
}
|
||||
btnprev = btnbuff;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
#include "st7789.h"
|
||||
|
||||
#include "inputs.h"
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
@@ -110,6 +110,7 @@ int main(void)
|
||||
MX_USART3_UART_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
ST7789_Init();
|
||||
HAL_TIM_Base_Start_IT(&htim6);
|
||||
|
||||
/* USER CODE END 2 */
|
||||
|
||||
@@ -324,7 +325,7 @@ static void MX_TIM6_Init(void)
|
||||
htim6.Init.Prescaler = 64-1;
|
||||
htim6.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim6.Init.Period = 10000;
|
||||
htim6.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||
htim6.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
|
||||
if (HAL_TIM_Base_Init(&htim6) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
|
@@ -708,7 +708,7 @@ void ST7789_Test(void)
|
||||
ST7789_WriteString(10, 50, "Hello Steve!", Font_7x10, RED, WHITE);
|
||||
ST7789_WriteString(10, 75, "Hello Steve!", Font_11x18, YELLOW, WHITE);
|
||||
ST7789_WriteString(10, 100, "Hello Steve!", Font_16x26, MAGENTA, WHITE);
|
||||
HAL_Delay(1000);
|
||||
HAL_Delay(5000);
|
||||
|
||||
ST7789_Fill_Color(RED);
|
||||
ST7789_WriteString(10, 10, "Rect./Line.", Font_11x18, YELLOW, BLACK);
|
||||
@@ -740,8 +740,4 @@ void ST7789_Test(void)
|
||||
ST7789_DrawFilledTriangle(30, 30, 30, 70, 60, 40, WHITE);
|
||||
HAL_Delay(1000);
|
||||
|
||||
// If FLASH cannot storage anymore datas, please delete codes below.
|
||||
ST7789_Fill_Color(WHITE);
|
||||
ST7789_DrawImage(0, 0, 128, 128, (uint16_t *)saber);
|
||||
HAL_Delay(3000);
|
||||
}
|
||||
|
@@ -75,5 +75,6 @@
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="4"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><memoryBlockExpressionList context="reserved-for-future-use"/>"/>
|
||||
<stringAttribute key="process_factory_id" value="com.st.stm32cube.ide.mcu.debug.launch.HardwareDebugProcessFactory"/>
|
||||
</launchConfiguration>
|
||||
|
@@ -380,7 +380,8 @@ TIM17.Channel=TIM_CHANNEL_1
|
||||
TIM17.IPParameters=Channel
|
||||
TIM3.EncoderMode=TIM_ENCODERMODE_TI12
|
||||
TIM3.IPParameters=EncoderMode
|
||||
TIM6.IPParameters=Prescaler,Period
|
||||
TIM6.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_ENABLE
|
||||
TIM6.IPParameters=Prescaler,Period,AutoReloadPreload
|
||||
TIM6.Period=10000
|
||||
TIM6.Prescaler=64-1
|
||||
USART3.IPParameters=VirtualMode-Asynchronous
|
||||
|
Reference in New Issue
Block a user