定时器写了一点
This commit is contained in:
1
BSP/Timer.c
Normal file
1
BSP/Timer.c
Normal file
@@ -0,0 +1 @@
|
||||
#include "stm32f10x.h"
|
||||
4
BSP/Timer.h
Normal file
4
BSP/Timer.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#ifndef __TIMER_H
|
||||
#define __TIMER_H
|
||||
|
||||
#endif
|
||||
@@ -43,7 +43,9 @@ add_executable(${CMAKE_PROJECT_NAME}
|
||||
BSP/CountSensor.h
|
||||
BSP/Encoder.c
|
||||
BSP/Encoder.h
|
||||
)
|
||||
BSP/Timer.c
|
||||
BSP/Timer.h
|
||||
)
|
||||
|
||||
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE
|
||||
CMSIS # stm32f10x.h, core_cm3.h, system_stm32f10x.h
|
||||
|
||||
@@ -7,15 +7,9 @@ int16_t Num = 0;
|
||||
|
||||
int main(void) {
|
||||
OLED_Init();
|
||||
Encoder_Init();
|
||||
OLED_ShowString(1, 1, "Num:");
|
||||
|
||||
OLED_ShowString(1, 1, "Hello World");
|
||||
|
||||
while (1) {
|
||||
OLED_ShowNum(2, 1, GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0), 1); // 显示 PB0 电平
|
||||
OLED_ShowNum(3, 1, GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_1), 1); // 显示 PB1 电平
|
||||
|
||||
Num += GetEncoder_Counter();
|
||||
OLED_ShowSignedNum(1, 5, Num, 5);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user