输入方式改成中断,开启了两个定时器

Signed-off-by: kevin <kevin@lmve.net>
This commit is contained in:
2022-05-01 11:46:10 +08:00
parent de69c38b1f
commit 6e8fd579b8
67 changed files with 2869 additions and 3022 deletions
-85
View File
@@ -10,88 +10,3 @@ TIM2->ARR = (uint32_t)((72000000/freq)-1);TIM2->CCR3 = (uint32_t)(((72000000/fr
void add_a_note(uint16_t freq,uint8_t duty,uint16_t deley)
{
struct notes* buff;
buff = (struct notes*)malloc(sizeof(struct notes));
if (buff != NULL)
{
buff->freq = freq;
buff->duty = duty;
buff->deley = deley;
buff->next_note = NULL;
if (notes == NULL)
{
notes = buff;
}
else
{
struct notes *t = notes;
while (t->next_note != NULL)
{
t = t->next_note;
}
t->next_note = buff;
}
}
}
void delhead()
{
if (notes == NULL)
{
return;
}
if (notes->next_note == NULL)
{
free(notes);
notes = NULL;
}
else
{
struct notes *t = notes;
notes = notes->next_note;
free(t);
}
}
char buzzer_play_server()
{
static char busy_flag=0;
static uint32_t play_delay;
if(notes == NULL)
{
play_ones(0,0);
}else
{
if(busy_flag==0)
{
busy_flag=1;
play_delay=HAL_GetTick()+notes->deley;
play_ones(notes->freq,notes->duty);
}
if(busy_flag==1)
{
if(HAL_GetTick()>play_delay)
{
busy_flag=0;
delhead();
}
}
}
return busy_flag;
}
+2 -9
View File
@@ -3,16 +3,9 @@
#include "main.h"
struct notes
{
uint16_t freq;
uint8_t duty;
uint16_t deley;
struct notes *next_note;
};
void play_ones(uint16_t freq,uint8_t dutya);
void add_a_note(uint16_t freq,uint8_t duty,uint16_t deley);
char buzzer_play_server();
#endif /* BUZZER_H_ */
+39 -16
View File
@@ -177,6 +177,8 @@ char sys_lan=0;
int encode_c=0;
int test_code=0;
menu menu_main=
{
"Back\nInput\nBuzzer\nOLED\nAuto\nType\nLanguage\nAbout",
@@ -194,10 +196,10 @@ void mymain()
OLED_Init();//屏幕初始化
HAL_TIM_PWM_Start(&htim2,TIM_CHANNEL_3);//启动n通道的pwm
MUTE(1);//静音
//add_a_note(1000,50,1000);//开机响一声
HAL_TIM_Base_Start_IT(&htim3);
MUTE(0);
//play_ones(1000,50);
while(1)
{
@@ -218,6 +220,9 @@ void mymain()
encode_c+=GET_ENCODE(&E1);
sprintf(str,"ENCODE:%d",encode_c);
OLED_Str(0,8,8,str,1);
sprintf(str,"testcode:%d",test_code);
OLED_Str(0,16,8,str,1);
fps_++;
sprintf(str,"FPS:%d",fps);
@@ -247,7 +252,7 @@ void mymain()
GEI_BUTTON_CODE(&B1);//循环更新按钮
OLED_Cache_to_hardware();//刷新屏幕
buzzer_play_server();
if(HAL_GetTick()>run_tick)
{
run_tick+=1000;
@@ -266,22 +271,40 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
switch (GPIO_Pin)
{
case en_a_Pin:
switch(HAL_GPIO_ReadPin(en_b_GPIO_Port,en_b_Pin))
{
case 1:
E1.code+=1;
E1.move_flag=1;
break;
case 0:
E1.code-=1;
E1.move_flag=1;
break;
}
switch(HAL_GPIO_ReadPin(en_b_GPIO_Port,en_b_Pin))
{
case 1:
E1.code+=1;
E1.move_flag=1;
break;
case 0:
E1.code-=1;
E1.move_flag=1;
break;
}
break;
case tack_a_Pin:
test_code++;
break;
case tack_b_Pin:
test_code--;
break;
default:
break;
//__HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin);
}
}
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)//1ms
{
if (htim == (&htim3))
{
}
}
+2
View File
@@ -20,6 +20,8 @@ struct morsecode
char letter;
};
extern TIM_HandleTypeDef htim3;
void mymain();
#endif /* MYMAIN_H_ */
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -21,30 +21,66 @@ Target DLL: STLink\ST-LINKIII-KEIL_SWO.dll V3.0.9.0
Dialog DLL: TCM.DLL V1.53.0.0
<h2>Project:</h2>
C:\Users\kevin\Desktop\morse_code_trainer\f103c8t6_keil\MDK-ARM\f103c8t6_KEIL.uvprojx
Project File Date: 04/28/2022
C:\Users\wuwen\morse_code_trainer\f103c8t6_keil\MDK-ARM\f103c8t6_KEIL.uvprojx
Project File Date: 04/30/2022
<h2>Output:</h2>
*** Using Compiler 'V5.06 update 7 (build 960)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
Build target 'f103c8t6_KEIL'
assembling startup_stm32f103xb.s...
compiling stm32f1xx_hal_msp.c...
compiling stm32f1xx_it.c...
compiling main.c...
./MYDEIVERS/oled.h(33): warning: #1295-D: Deprecated declaration OLED_Cache_to_hardware - give arg types
void OLED_Cache_to_hardware();
./MYDEIVERS/mymain.h(25): warning: #1295-D: Deprecated declaration mymain - give arg types
void mymain();
../Core/Src/main.c: 2 warnings, 0 errors
compiling stm32f1xx_hal_gpio_ex.c...
compiling stm32f1xx_hal.c...
compiling stm32f1xx_hal_i2c.c...
compiling stm32f1xx_hal_rcc_ex.c...
compiling stm32f1xx_hal_rcc.c...
compiling stm32f1xx_hal_gpio.c...
compiling stm32f1xx_hal_cortex.c...
compiling stm32f1xx_hal_dma.c...
compiling stm32f1xx_hal_pwr.c...
compiling stm32f1xx_hal_flash_ex.c...
compiling stm32f1xx_hal_flash.c...
compiling stm32f1xx_hal_exti.c...
compiling system_stm32f1xx.c...
compiling stm32f1xx_hal_tim_ex.c...
compiling stm32f1xx_hal_tim.c...
compiling hread_interface.c...
compiling mymain.c...
MYDEIVERS\oled.h(33): warning: #1295-D: Deprecated declaration OLED_Cache_to_hardware - give arg types
void OLED_Cache_to_hardware();
MYDEIVERS\buzzer.h(16): warning: #1295-D: Deprecated declaration buzzer_play_server - give arg types
char buzzer_play_server();
MYDEIVERS\mymain.h(23): warning: #1295-D: Deprecated declaration mymain - give arg types
MYDEIVERS\mymain.h(25): warning: #1295-D: Deprecated declaration mymain - give arg types
void mymain();
MYDEIVERS\mymain.c(197): warning: #188-D: enumerated type mixed with another type
MUTE(1);//é™éŸ³
MYDEIVERS\mymain.c(215): warning: #223-D: function "sprintf" declared implicitly
MYDEIVERS\mymain.c(200): warning: #188-D: enumerated type mixed with another type
MUTE(0);
MYDEIVERS\mymain.c(217): warning: #223-D: function "sprintf" declared implicitly
sprintf(str,"BUTTON:%d",B1.code);
MYDEIVERS\mymain.c(287): warning: #1-D: last line of file ends without a newline
MYDEIVERS\mymain.c(310): warning: #1-D: last line of file ends without a newline
}
MYDEIVERS\mymain.c: 6 warnings, 0 errors
MYDEIVERS\mymain.c: 5 warnings, 0 errors
compiling oled.c...
MYDEIVERS\oled.h(33): warning: #1295-D: Deprecated declaration OLED_Cache_to_hardware - give arg types
void OLED_Cache_to_hardware();
MYDEIVERS\oled.c(1036): warning: #550-D: variable "absx" was set but never used
int dx,dy,absx,absy;
MYDEIVERS\oled.c(1036): warning: #550-D: variable "absy" was set but never used
int dx,dy,absx,absy;
MYDEIVERS\oled.c: 3 warnings, 0 errors
compiling buzzer.c...
compiling encode.c...
MYDEIVERS\encode.c(62): warning: #1-D: last line of file ends without a newline
}
MYDEIVERS\encode.c: 1 warning, 0 errors
linking...
Program Size: Code=9832 RO-data=3768 RW-data=76 ZI-data=3876
Program Size: Code=8984 RO-data=3768 RW-data=68 ZI-data=3948
FromELF: creating hex file...
"f103c8t6_KEIL\f103c8t6_KEIL.axf" - 0 Error(s), 6 Warning(s).
"f103c8t6_KEIL\f103c8t6_KEIL.axf" - 0 Error(s), 11 Warning(s).
<h2>Software Packages used:</h2>
@@ -61,14 +97,14 @@ Package Vendor: Keil
<h2>Collection of Component include folders:</h2>
.\RTE\_f103c8t6_KEIL
C:\Users\kevin\AppData\Local\Arm\Packs\ARM\CMSIS\5.8.0\CMSIS\Core\Include
C:\Users\kevin\AppData\Local\Arm\Packs\Keil\STM32F1xx_DFP\2.4.0\Device\Include
C:\Users\wuwen\AppData\Local\Arm\Packs\ARM\CMSIS\5.8.0\CMSIS\Core\Include
C:\Users\wuwen\AppData\Local\Arm\Packs\Keil\STM32F1xx_DFP\2.4.0\Device\Include
<h2>Collection of Component Files used:</h2>
* Component: ARM::CMSIS:CORE:5.5.0
Include file: CMSIS\Core\Include\tz_context.h
Build Time Elapsed: 00:00:02
Build Time Elapsed: 00:00:12
</pre>
</body>
</html>
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -475,8 +475,8 @@ ARM Macro Assembler Page 8
00000000
Command Line: --debug --xref --diag_suppress=9931 --cpu=Cortex-M3 --apcs=interw
ork --depend=f103c8t6_keil\startup_stm32f103xb.d -of103c8t6_keil\startup_stm32f
103xb.o -I.\RTE\_f103c8t6_KEIL -IC:\Users\kevin\AppData\Local\Arm\Packs\ARM\CMS
IS\5.8.0\CMSIS\Core\Include -IC:\Users\kevin\AppData\Local\Arm\Packs\Keil\STM32
103xb.o -I.\RTE\_f103c8t6_KEIL -IC:\Users\wuwen\AppData\Local\Arm\Packs\ARM\CMS
IS\5.8.0\CMSIS\Core\Include -IC:\Users\wuwen\AppData\Local\Arm\Packs\Keil\STM32
F1xx_DFP\2.4.0\Device\Include --predefine="__EVAL SETA 1" --predefine="__UVISIO
N_VERSION SETA 536" --predefine="_RTE_ SETA 1" --predefine="STM32F10X_MD SETA 1
" --predefine="_RTE_ SETA 1" --list=startup_stm32f103xb.lst startup_stm32f103xb