Compare commits
No commits in common. "df647f2cc7a5f02c657e7c77261001df2d548435" and "a88ab88eb56d94baba339f893835937d7bbe1dc9" have entirely different histories.
df647f2cc7
...
a88ab88eb5
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -5,6 +5,10 @@ MDK-ARM/DebugConfig
|
|||
MDK-ARM/CAR.uvguix.*
|
||||
MDK-ARM/startup_stm32f103xb.lst
|
||||
MDK-ARM/RTE
|
||||
MDK-ARM/CAR.uvguix.Admin
|
||||
MDK-ARM/car.uvguix.Administrator
|
||||
MDK-ARM/CAR.uvguix.lenovo
|
||||
|
||||
build/
|
||||
cmake/
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ LibFiles=Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_i2c.h;Drivers\STM32F1xx_
|
|||
|
||||
[PreviousUsedKeilFiles]
|
||||
SourceFiles=..\Core\Src\main.c;..\Core\Src\gpio.c;..\Core\Src\dma.c;..\Core\Src\i2c.c;..\Core\Src\tim.c;..\Core\Src\usart.c;..\Core\Src\stm32f1xx_it.c;..\Core\Src\stm32f1xx_hal_msp.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio_ex.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_i2c.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc_ex.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_dma.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_cortex.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pwr.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash_ex.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_exti.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_tim.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_tim_ex.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_uart.c;..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c;..\Core\Src\system_stm32f1xx.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio_ex.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_i2c.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc_ex.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_dma.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_cortex.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pwr.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash_ex.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_exti.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_tim.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_tim_ex.c;..\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_uart.c;..\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c;..\Core\Src\system_stm32f1xx.c;;;
|
||||
HeaderPath=..\Drivers\STM32F1xx_HAL_Driver\Inc;..\Drivers\STM32F1xx_HAL_Driver\Inc\Legacy;..\Drivers\CMSIS\Device\ST\STM32F1xx\Include;..\Drivers\CMSIS\Include;..\Core\Inc;
|
||||
HeaderPath=..\Drivers\STM32F1xx_HAL_Driver\Inc;..\Drivers\STM32F1xx_HAL_Driver\Inc\Legacy;..\Drivers\CMSIS\Device\ST\STM32F1xx\Include;..\Core\Inc;
|
||||
CDefines=USE_HAL_DRIVER;STM32F103xB;USE_HAL_DRIVER;USE_HAL_DRIVER;
|
||||
|
||||
[PreviousUsedMakefileFiles]
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
#ifndef __APP_ULTRASONIC_H
|
||||
#define __APP_ULTRASONIC_H
|
||||
|
||||
int APP_Find_Direction(void);
|
||||
|
||||
#endif
|
|
@ -44,7 +44,7 @@ void LINESEEK_HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef* htim)
|
|||
|
||||
if (beep_time++ > 100)
|
||||
{
|
||||
HAL_GPIO_WritePin(FM_K2_POWERC_GPIO_Port, FM_K2_POWERC_Pin, GPIO_PIN_SET);
|
||||
buzzer(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -255,7 +255,7 @@ void Hanlde_Crossroad(void)
|
|||
}
|
||||
|
||||
beep_time = 0;
|
||||
HAL_GPIO_WritePin(FM_K2_POWERC_GPIO_Port, FM_K2_POWERC_Pin, GPIO_PIN_RESET);
|
||||
buzzer(1);
|
||||
// state = MOVE_STRAIGHT;
|
||||
// buzzer(1);
|
||||
// HAL_Delay(50);
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
#include "app_ultrasonic.h"
|
||||
#include "servo.h"
|
||||
#include "hcsr04.h"
|
||||
#include "main.h"
|
||||
#include "led.h"
|
||||
#include "path_plan.h"
|
||||
|
||||
#define BLOCK_DISTANCE 150
|
||||
|
||||
int APP_Find_Direction(void)
|
||||
{
|
||||
uint32_t left_block,right_block,straight_block;
|
||||
|
||||
// 测定左侧障碍物距离
|
||||
SERVO_Rotate(50);
|
||||
HAL_Delay(300);
|
||||
left_block = sonar_mm();
|
||||
|
||||
// 测定正前侧障碍物距离
|
||||
SERVO_Rotate(90);
|
||||
HAL_Delay(300);
|
||||
straight_block = sonar_mm();
|
||||
|
||||
// 测定右侧障碍物距离
|
||||
SERVO_Rotate(150);
|
||||
HAL_Delay(300);
|
||||
right_block = sonar_mm();
|
||||
|
||||
LED_Start(7);
|
||||
|
||||
if(left_block > BLOCK_DISTANCE && right_block > BLOCK_DISTANCE && straight_block > BLOCK_DISTANCE)// 前左右均无障碍物,直行
|
||||
{
|
||||
return STRAIGHT;
|
||||
}
|
||||
else if(left_block < BLOCK_DISTANCE && right_block < BLOCK_DISTANCE && straight_block < BLOCK_DISTANCE)// 前左右均有障碍物,停止并鸣笛
|
||||
{
|
||||
LED_SetDuty(255,0,0);
|
||||
return STOP;
|
||||
}
|
||||
else if(straight_block < BLOCK_DISTANCE && left_block < BLOCK_DISTANCE)// 前左有障碍物,右转
|
||||
{
|
||||
return RIGHT;
|
||||
}
|
||||
else if (straight_block < BLOCK_DISTANCE && right_block < BLOCK_DISTANCE)// 前右有障碍物,左转
|
||||
{
|
||||
return LEFT;
|
||||
}
|
||||
else
|
||||
{
|
||||
return STRAIGHT;
|
||||
}
|
||||
}
|
104
CAR.ioc
104
CAR.ioc
|
@ -20,61 +20,56 @@ Mcu.CPN=STM32F103C8T6
|
|||
Mcu.Family=STM32F1
|
||||
Mcu.IP0=DMA
|
||||
Mcu.IP1=I2C2
|
||||
Mcu.IP10=USART2
|
||||
Mcu.IP2=NVIC
|
||||
Mcu.IP3=RCC
|
||||
Mcu.IP4=SYS
|
||||
Mcu.IP5=TIM1
|
||||
Mcu.IP6=TIM2
|
||||
Mcu.IP7=TIM3
|
||||
Mcu.IP8=TIM4
|
||||
Mcu.IP9=USART1
|
||||
Mcu.IPNb=11
|
||||
Mcu.IP5=TIM2
|
||||
Mcu.IP6=TIM3
|
||||
Mcu.IP7=TIM4
|
||||
Mcu.IP8=USART1
|
||||
Mcu.IP9=USART2
|
||||
Mcu.IPNb=10
|
||||
Mcu.Name=STM32F103C(8-B)Tx
|
||||
Mcu.Package=LQFP48
|
||||
Mcu.Pin0=PC13-TAMPER-RTC
|
||||
Mcu.Pin1=PC14-OSC32_IN
|
||||
Mcu.Pin10=PA6
|
||||
Mcu.Pin11=PA7
|
||||
Mcu.Pin12=PB0
|
||||
Mcu.Pin13=PB1
|
||||
Mcu.Pin14=PB10
|
||||
Mcu.Pin15=PB11
|
||||
Mcu.Pin16=PB12
|
||||
Mcu.Pin17=PA9
|
||||
Mcu.Pin18=PA10
|
||||
Mcu.Pin19=PA11
|
||||
Mcu.Pin10=PB0
|
||||
Mcu.Pin11=PB1
|
||||
Mcu.Pin12=PB10
|
||||
Mcu.Pin13=PB11
|
||||
Mcu.Pin14=PB12
|
||||
Mcu.Pin15=PA9
|
||||
Mcu.Pin16=PA10
|
||||
Mcu.Pin17=PA12
|
||||
Mcu.Pin18=PA13
|
||||
Mcu.Pin19=PA14
|
||||
Mcu.Pin2=PC15-OSC32_OUT
|
||||
Mcu.Pin20=PA12
|
||||
Mcu.Pin21=PA13
|
||||
Mcu.Pin22=PA14
|
||||
Mcu.Pin23=PA15
|
||||
Mcu.Pin24=PB4
|
||||
Mcu.Pin25=PB5
|
||||
Mcu.Pin26=PB6
|
||||
Mcu.Pin27=PB7
|
||||
Mcu.Pin28=PB8
|
||||
Mcu.Pin29=PB9
|
||||
Mcu.Pin20=PA15
|
||||
Mcu.Pin21=PB4
|
||||
Mcu.Pin22=PB5
|
||||
Mcu.Pin23=PB6
|
||||
Mcu.Pin24=PB7
|
||||
Mcu.Pin25=PB8
|
||||
Mcu.Pin26=PB9
|
||||
Mcu.Pin27=VP_SYS_VS_Systick
|
||||
Mcu.Pin28=VP_TIM2_VS_ClockSourceINT
|
||||
Mcu.Pin29=VP_TIM3_VS_ClockSourceINT
|
||||
Mcu.Pin3=PD0-OSC_IN
|
||||
Mcu.Pin30=VP_SYS_VS_Systick
|
||||
Mcu.Pin31=VP_TIM1_VS_ClockSourceINT
|
||||
Mcu.Pin32=VP_TIM2_VS_ClockSourceINT
|
||||
Mcu.Pin33=VP_TIM3_VS_ClockSourceINT
|
||||
Mcu.Pin34=VP_TIM4_VS_ClockSourceINT
|
||||
Mcu.Pin30=VP_TIM4_VS_ClockSourceINT
|
||||
Mcu.Pin4=PD1-OSC_OUT
|
||||
Mcu.Pin5=PA0-WKUP
|
||||
Mcu.Pin6=PA1
|
||||
Mcu.Pin7=PA2
|
||||
Mcu.Pin8=PA3
|
||||
Mcu.Pin9=PA4
|
||||
Mcu.PinsNb=35
|
||||
Mcu.Pin9=PA7
|
||||
Mcu.PinsNb=31
|
||||
Mcu.ThirdPartyNb=0
|
||||
Mcu.UserConstants=
|
||||
Mcu.UserName=STM32F103C8Tx
|
||||
MxCube.Version=6.12.0
|
||||
MxDb.Version=DB.6.0.120
|
||||
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
NVIC.DMA1_Channel6_IRQn=true\:0\:0\:true\:false\:true\:true\:true\:true
|
||||
NVIC.DMA1_Channel6_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
NVIC.EXTI15_10_IRQn=true\:1\:0\:true\:false\:true\:true\:true\:true
|
||||
NVIC.ForceEnableDMAVector=false
|
||||
|
@ -84,12 +79,11 @@ NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
|||
NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_2
|
||||
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
NVIC.SysTick_IRQn=true\:2\:0\:true\:false\:true\:false\:true\:false
|
||||
NVIC.SysTick_IRQn=true\:3\:0\:true\:false\:true\:false\:true\:false
|
||||
NVIC.TIM2_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||
NVIC.TIM3_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||
NVIC.TIM4_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||
NVIC.USART1_IRQn=true\:3\:1\:true\:false\:true\:true\:true\:true
|
||||
NVIC.USART2_IRQn=true\:3\:0\:true\:false\:true\:true\:true\:true
|
||||
NVIC.USART2_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
PA0-WKUP.GPIOParameters=PinState,GPIO_Label
|
||||
PA0-WKUP.GPIO_Label=FM_K2_POWERC
|
||||
|
@ -103,12 +97,8 @@ PA1.PinState=GPIO_PIN_SET
|
|||
PA1.Signal=GPIO_Output
|
||||
PA10.Mode=Asynchronous
|
||||
PA10.Signal=USART1_RX
|
||||
PA11.GPIOParameters=GPIO_Label
|
||||
PA11.GPIO_Label=SERVO
|
||||
PA11.Locked=true
|
||||
PA11.Signal=S_TIM1_CH4
|
||||
PA12.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI
|
||||
PA12.GPIO_Label=ECHO
|
||||
PA12.GPIO_Label=Echo
|
||||
PA12.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING
|
||||
PA12.GPIO_PuPd=GPIO_PULLDOWN
|
||||
PA12.Locked=true
|
||||
|
@ -118,7 +108,7 @@ PA13.Signal=SYS_JTMS-SWDIO
|
|||
PA14.Mode=Serial_Wire
|
||||
PA14.Signal=SYS_JTCK-SWCLK
|
||||
PA15.GPIOParameters=GPIO_Speed,GPIO_Label
|
||||
PA15.GPIO_Label=TRIG
|
||||
PA15.GPIO_Label=Trig
|
||||
PA15.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
|
||||
PA15.Locked=true
|
||||
PA15.Signal=GPIO_Output
|
||||
|
@ -126,14 +116,6 @@ PA2.Mode=Asynchronous
|
|||
PA2.Signal=USART2_TX
|
||||
PA3.Mode=Asynchronous
|
||||
PA3.Signal=USART2_RX
|
||||
PA4.GPIOParameters=GPIO_Label
|
||||
PA4.GPIO_Label=HWR
|
||||
PA4.Locked=true
|
||||
PA4.Signal=GPIO_Input
|
||||
PA6.GPIOParameters=GPIO_Label
|
||||
PA6.GPIO_Label=HWL
|
||||
PA6.Locked=true
|
||||
PA6.Signal=GPIO_Input
|
||||
PA7.GPIOParameters=GPIO_Label
|
||||
PA7.GPIO_Label=LED_B_TIM3CH2
|
||||
PA7.Locked=true
|
||||
|
@ -220,7 +202,7 @@ ProjectManager.FreePins=false
|
|||
ProjectManager.HalAssertFull=false
|
||||
ProjectManager.HeapSize=0x200
|
||||
ProjectManager.KeepUserCode=true
|
||||
ProjectManager.LastFirmware=true
|
||||
ProjectManager.LastFirmware=false
|
||||
ProjectManager.LibraryCopy=1
|
||||
ProjectManager.MainLocation=Core/Src
|
||||
ProjectManager.NoMain=false
|
||||
|
@ -229,14 +211,14 @@ ProjectManager.ProjectBuild=false
|
|||
ProjectManager.ProjectFileName=CAR.ioc
|
||||
ProjectManager.ProjectName=CAR
|
||||
ProjectManager.ProjectStructure=
|
||||
ProjectManager.RegisterCallBack=TIM
|
||||
ProjectManager.RegisterCallBack=TIM,USART
|
||||
ProjectManager.StackSize=0x400
|
||||
ProjectManager.TargetToolchain=MDK-ARM V5.32
|
||||
ProjectManager.TargetToolchain=Makefile
|
||||
ProjectManager.ToolChainLocation=
|
||||
ProjectManager.UAScriptAfterPath=
|
||||
ProjectManager.UAScriptBeforePath=
|
||||
ProjectManager.UnderRoot=false
|
||||
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_I2C2_Init-I2C2-false-HAL-true,5-MX_TIM1_Init-TIM1-false-HAL-true,6-MX_TIM2_Init-TIM2-false-HAL-true,7-MX_TIM3_Init-TIM3-false-HAL-true,8-MX_TIM4_Init-TIM4-false-HAL-true,9-MX_USART1_UART_Init-USART1-false-HAL-true,10-MX_USART2_UART_Init-USART2-false-HAL-true
|
||||
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_I2C2_Init-I2C2-false-HAL-true,5-MX_TIM2_Init-TIM2-false-HAL-true,6-MX_TIM3_Init-TIM3-false-HAL-true,7-MX_TIM4_Init-TIM4-false-HAL-true,8-MX_USART2_UART_Init-USART2-false-HAL-true,9-MX_USART1_UART_Init-USART1-false-HAL-true
|
||||
RCC.ADCFreqValue=36000000
|
||||
RCC.AHBFreq_Value=72000000
|
||||
RCC.APB1CLKDivider=RCC_HCLK_DIV2
|
||||
|
@ -260,8 +242,6 @@ RCC.USBFreq_Value=72000000
|
|||
RCC.VCOOutput2Freq_Value=8000000
|
||||
SH.GPXTI12.0=GPIO_EXTI12
|
||||
SH.GPXTI12.ConfNb=1
|
||||
SH.S_TIM1_CH4.0=TIM1_CH4,PWM Generation4 CH4
|
||||
SH.S_TIM1_CH4.ConfNb=1
|
||||
SH.S_TIM3_CH2.0=TIM3_CH2,PWM Generation2 CH2
|
||||
SH.S_TIM3_CH2.ConfNb=1
|
||||
SH.S_TIM3_CH3.0=TIM3_CH3,PWM Generation3 CH3
|
||||
|
@ -272,10 +252,6 @@ SH.S_TIM4_CH1.0=TIM4_CH1,PWM Generation1 CH1
|
|||
SH.S_TIM4_CH1.ConfNb=1
|
||||
SH.S_TIM4_CH2.0=TIM4_CH2,PWM Generation2 CH2
|
||||
SH.S_TIM4_CH2.ConfNb=1
|
||||
TIM1.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4
|
||||
TIM1.IPParameters=Prescaler,Period,Channel-PWM Generation4 CH4
|
||||
TIM1.Period=2000 - 1
|
||||
TIM1.Prescaler=720 - 1
|
||||
TIM2.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_DISABLE
|
||||
TIM2.IPParameters=Prescaler,Period,AutoReloadPreload
|
||||
TIM2.Period=72 - 1
|
||||
|
@ -299,7 +275,7 @@ TIM4.Period=100
|
|||
TIM4.Prescaler=720 - 1
|
||||
TIM4.Pulse-PWM\ Generation1\ CH1=100
|
||||
TIM4.Pulse-PWM\ Generation2\ CH2=100
|
||||
USART1.BaudRate=115200
|
||||
USART1.BaudRate=9600
|
||||
USART1.IPParameters=VirtualMode,BaudRate,Parity,WordLength
|
||||
USART1.Parity=PARITY_NONE
|
||||
USART1.VirtualMode=VM_ASYNC
|
||||
|
@ -309,8 +285,6 @@ USART2.IPParameters=VirtualMode,BaudRate
|
|||
USART2.VirtualMode=VM_ASYNC
|
||||
VP_SYS_VS_Systick.Mode=SysTick
|
||||
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
|
||||
VP_TIM1_VS_ClockSourceINT.Mode=Internal
|
||||
VP_TIM1_VS_ClockSourceINT.Signal=TIM1_VS_ClockSourceINT
|
||||
VP_TIM2_VS_ClockSourceINT.Mode=Internal
|
||||
VP_TIM2_VS_ClockSourceINT.Signal=TIM2_VS_ClockSourceINT
|
||||
VP_TIM3_VS_ClockSourceINT.Mode=Internal
|
||||
|
|
|
@ -67,10 +67,6 @@ void Error_Handler(void);
|
|||
#define FM_K2_POWERC_GPIO_Port GPIOA
|
||||
#define FAN_GS_Pin GPIO_PIN_1
|
||||
#define FAN_GS_GPIO_Port GPIOA
|
||||
#define HWR_Pin GPIO_PIN_4
|
||||
#define HWR_GPIO_Port GPIOA
|
||||
#define HWL_Pin GPIO_PIN_6
|
||||
#define HWL_GPIO_Port GPIOA
|
||||
#define LED_B_TIM3CH2_Pin GPIO_PIN_7
|
||||
#define LED_B_TIM3CH2_GPIO_Port GPIOA
|
||||
#define LED_G_TIM3CH3_Pin GPIO_PIN_0
|
||||
|
@ -83,13 +79,11 @@ void Error_Handler(void);
|
|||
#define MPU6050_SDA_GPIO_Port GPIOB
|
||||
#define LineSeek_R2_Pin GPIO_PIN_12
|
||||
#define LineSeek_R2_GPIO_Port GPIOB
|
||||
#define SERVO_Pin GPIO_PIN_11
|
||||
#define SERVO_GPIO_Port GPIOA
|
||||
#define ECHO_Pin GPIO_PIN_12
|
||||
#define ECHO_GPIO_Port GPIOA
|
||||
#define ECHO_EXTI_IRQn EXTI15_10_IRQn
|
||||
#define TRIG_Pin GPIO_PIN_15
|
||||
#define TRIG_GPIO_Port GPIOA
|
||||
#define Echo_Pin GPIO_PIN_12
|
||||
#define Echo_GPIO_Port GPIOA
|
||||
#define Echo_EXTI_IRQn EXTI15_10_IRQn
|
||||
#define Trig_Pin GPIO_PIN_15
|
||||
#define Trig_GPIO_Port GPIOA
|
||||
#define R_FORWARD_Pin GPIO_PIN_4
|
||||
#define R_FORWARD_GPIO_Port GPIOB
|
||||
#define R_BACKWARD_Pin GPIO_PIN_5
|
||||
|
|
|
@ -129,7 +129,7 @@
|
|||
* @brief This is the HAL system configuration section
|
||||
*/
|
||||
#define VDD_VALUE 3300U /*!< Value of VDD in mv */
|
||||
#define TICK_INT_PRIORITY 2U /*!< tick interrupt priority (lowest by default) */
|
||||
#define TICK_INT_PRIORITY 3U /*!< tick interrupt priority (lowest by default) */
|
||||
#define USE_RTOS 0U
|
||||
#define PREFETCH_ENABLE 1U
|
||||
|
||||
|
@ -154,7 +154,7 @@
|
|||
#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
|
||||
#define USE_HAL_TIM_REGISTER_CALLBACKS 1U /* TIM register callback enabled */
|
||||
#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
|
||||
#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
|
||||
#define USE_HAL_USART_REGISTER_CALLBACKS 1U /* USART register callback enabled */
|
||||
#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
|
||||
|
||||
/* ########################## Assert Selection ############################## */
|
||||
|
|
|
@ -59,7 +59,6 @@ void DMA1_Channel6_IRQHandler(void);
|
|||
void TIM2_IRQHandler(void);
|
||||
void TIM3_IRQHandler(void);
|
||||
void TIM4_IRQHandler(void);
|
||||
void USART1_IRQHandler(void);
|
||||
void USART2_IRQHandler(void);
|
||||
void EXTI15_10_IRQHandler(void);
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
|
|
@ -32,8 +32,6 @@ extern "C" {
|
|||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
extern TIM_HandleTypeDef htim1;
|
||||
|
||||
extern TIM_HandleTypeDef htim2;
|
||||
|
||||
extern TIM_HandleTypeDef htim3;
|
||||
|
@ -44,7 +42,6 @@ extern TIM_HandleTypeDef htim4;
|
|||
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
void MX_TIM1_Init(void);
|
||||
void MX_TIM2_Init(void);
|
||||
void MX_TIM3_Init(void);
|
||||
void MX_TIM4_Init(void);
|
||||
|
|
|
@ -54,7 +54,7 @@ void MX_GPIO_Init(void)
|
|||
HAL_GPIO_WritePin(GPIOA, FM_K2_POWERC_Pin|FAN_GS_Pin, GPIO_PIN_SET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(TRIG_GPIO_Port, TRIG_Pin, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(Trig_GPIO_Port, Trig_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(GPIOB, R_FORWARD_Pin|R_BACKWARD_Pin|L_BACKWARD_Pin|L_FORWARD_Pin, GPIO_PIN_RESET);
|
||||
|
@ -72,12 +72,6 @@ void MX_GPIO_Init(void)
|
|||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PAPin PAPin */
|
||||
GPIO_InitStruct.Pin = HWR_Pin|HWL_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pin : PtPin */
|
||||
GPIO_InitStruct.Pin = LineSeek_R2_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
|
@ -85,17 +79,17 @@ void MX_GPIO_Init(void)
|
|||
HAL_GPIO_Init(LineSeek_R2_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pin : PtPin */
|
||||
GPIO_InitStruct.Pin = ECHO_Pin;
|
||||
GPIO_InitStruct.Pin = Echo_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
|
||||
HAL_GPIO_Init(ECHO_GPIO_Port, &GPIO_InitStruct);
|
||||
HAL_GPIO_Init(Echo_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pin : PtPin */
|
||||
GPIO_InitStruct.Pin = TRIG_Pin;
|
||||
GPIO_InitStruct.Pin = Trig_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
HAL_GPIO_Init(TRIG_GPIO_Port, &GPIO_InitStruct);
|
||||
HAL_GPIO_Init(Trig_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PBPin PBPin PBPin PBPin */
|
||||
GPIO_InitStruct.Pin = R_FORWARD_Pin|R_BACKWARD_Pin|L_BACKWARD_Pin|L_FORWARD_Pin;
|
||||
|
|
|
@ -102,12 +102,11 @@ int main(void)
|
|||
MX_GPIO_Init();
|
||||
MX_DMA_Init();
|
||||
MX_I2C2_Init();
|
||||
MX_TIM1_Init();
|
||||
MX_TIM2_Init();
|
||||
MX_TIM3_Init();
|
||||
MX_TIM4_Init();
|
||||
MX_USART1_UART_Init();
|
||||
// MX_USART2_UART_Init();
|
||||
MX_USART1_UART_Init();
|
||||
|
||||
/* USER CODE BEGIN 2 */
|
||||
HC_SR04_Init();
|
||||
|
|
|
@ -59,7 +59,6 @@ extern TIM_HandleTypeDef htim2;
|
|||
extern TIM_HandleTypeDef htim3;
|
||||
extern TIM_HandleTypeDef htim4;
|
||||
extern DMA_HandleTypeDef hdma_usart2_rx;
|
||||
extern UART_HandleTypeDef huart1;
|
||||
extern UART_HandleTypeDef huart2;
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
|
@ -259,20 +258,6 @@ void TIM4_IRQHandler(void)
|
|||
/* USER CODE END TIM4_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles USART1 global interrupt.
|
||||
*/
|
||||
void USART1_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN USART1_IRQn 0 */
|
||||
|
||||
/* USER CODE END USART1_IRQn 0 */
|
||||
HAL_UART_IRQHandler(&huart1);
|
||||
/* USER CODE BEGIN USART1_IRQn 1 */
|
||||
|
||||
/* USER CODE END USART1_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles USART2 global interrupt.
|
||||
*/
|
||||
|
@ -295,7 +280,7 @@ void EXTI15_10_IRQHandler(void)
|
|||
/* USER CODE BEGIN EXTI15_10_IRQn 0 */
|
||||
|
||||
/* USER CODE END EXTI15_10_IRQn 0 */
|
||||
HAL_GPIO_EXTI_IRQHandler(ECHO_Pin);
|
||||
HAL_GPIO_EXTI_IRQHandler(Echo_Pin);
|
||||
/* USER CODE BEGIN EXTI15_10_IRQn 1 */
|
||||
|
||||
/* USER CODE END EXTI15_10_IRQn 1 */
|
||||
|
|
117
Core/Src/tim.c
117
Core/Src/tim.c
|
@ -24,80 +24,10 @@
|
|||
|
||||
/* USER CODE END 0 */
|
||||
|
||||
TIM_HandleTypeDef htim1;
|
||||
TIM_HandleTypeDef htim2;
|
||||
TIM_HandleTypeDef htim3;
|
||||
TIM_HandleTypeDef htim4;
|
||||
|
||||
/* TIM1 init function */
|
||||
void MX_TIM1_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN TIM1_Init 0 */
|
||||
|
||||
/* USER CODE END TIM1_Init 0 */
|
||||
|
||||
TIM_ClockConfigTypeDef sClockSourceConfig = {0};
|
||||
TIM_MasterConfigTypeDef sMasterConfig = {0};
|
||||
TIM_OC_InitTypeDef sConfigOC = {0};
|
||||
TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig = {0};
|
||||
|
||||
/* USER CODE BEGIN TIM1_Init 1 */
|
||||
|
||||
/* USER CODE END TIM1_Init 1 */
|
||||
htim1.Instance = TIM1;
|
||||
htim1.Init.Prescaler = 720 - 1;
|
||||
htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim1.Init.Period = 2000 - 1;
|
||||
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
htim1.Init.RepetitionCounter = 0;
|
||||
htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||
if (HAL_TIM_Base_Init(&htim1) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
|
||||
if (HAL_TIM_ConfigClockSource(&htim1, &sClockSourceConfig) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
if (HAL_TIM_PWM_Init(&htim1) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
||||
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
||||
if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
sConfigOC.OCMode = TIM_OCMODE_PWM1;
|
||||
sConfigOC.Pulse = 0;
|
||||
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
|
||||
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
|
||||
sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;
|
||||
sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET;
|
||||
if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_4) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE;
|
||||
sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE;
|
||||
sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF;
|
||||
sBreakDeadTimeConfig.DeadTime = 0;
|
||||
sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE;
|
||||
sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH;
|
||||
sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE;
|
||||
if (HAL_TIMEx_ConfigBreakDeadTime(&htim1, &sBreakDeadTimeConfig) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN TIM1_Init 2 */
|
||||
|
||||
/* USER CODE END TIM1_Init 2 */
|
||||
HAL_TIM_MspPostInit(&htim1);
|
||||
|
||||
}
|
||||
/* TIM2 init function */
|
||||
void MX_TIM2_Init(void)
|
||||
{
|
||||
|
@ -262,18 +192,7 @@ void MX_TIM4_Init(void)
|
|||
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
|
||||
{
|
||||
|
||||
if(tim_baseHandle->Instance==TIM1)
|
||||
{
|
||||
/* USER CODE BEGIN TIM1_MspInit 0 */
|
||||
|
||||
/* USER CODE END TIM1_MspInit 0 */
|
||||
/* TIM1 clock enable */
|
||||
__HAL_RCC_TIM1_CLK_ENABLE();
|
||||
/* USER CODE BEGIN TIM1_MspInit 1 */
|
||||
|
||||
/* USER CODE END TIM1_MspInit 1 */
|
||||
}
|
||||
else if(tim_baseHandle->Instance==TIM2)
|
||||
if(tim_baseHandle->Instance==TIM2)
|
||||
{
|
||||
/* USER CODE BEGIN TIM2_MspInit 0 */
|
||||
|
||||
|
@ -323,30 +242,11 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* timHandle)
|
|||
{
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
if(timHandle->Instance==TIM1)
|
||||
{
|
||||
/* USER CODE BEGIN TIM1_MspPostInit 0 */
|
||||
|
||||
/* USER CODE END TIM1_MspPostInit 0 */
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
/**TIM1 GPIO Configuration
|
||||
PA11 ------> TIM1_CH4
|
||||
*/
|
||||
GPIO_InitStruct.Pin = SERVO_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(SERVO_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/* USER CODE BEGIN TIM1_MspPostInit 1 */
|
||||
|
||||
/* USER CODE END TIM1_MspPostInit 1 */
|
||||
}
|
||||
else if(timHandle->Instance==TIM3)
|
||||
if(timHandle->Instance==TIM3)
|
||||
{
|
||||
/* USER CODE BEGIN TIM3_MspPostInit 0 */
|
||||
|
||||
/* USER CODE END TIM3_MspPostInit 0 */
|
||||
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
/**TIM3 GPIO Configuration
|
||||
|
@ -394,18 +294,7 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* timHandle)
|
|||
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle)
|
||||
{
|
||||
|
||||
if(tim_baseHandle->Instance==TIM1)
|
||||
{
|
||||
/* USER CODE BEGIN TIM1_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END TIM1_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_TIM1_CLK_DISABLE();
|
||||
/* USER CODE BEGIN TIM1_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END TIM1_MspDeInit 1 */
|
||||
}
|
||||
else if(tim_baseHandle->Instance==TIM2)
|
||||
if(tim_baseHandle->Instance==TIM2)
|
||||
{
|
||||
/* USER CODE BEGIN TIM2_MspDeInit 0 */
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ void MX_USART1_UART_Init(void)
|
|||
|
||||
/* USER CODE END USART1_Init 1 */
|
||||
huart1.Instance = USART1;
|
||||
huart1.Init.BaudRate = 115200;
|
||||
huart1.Init.BaudRate = 9600;
|
||||
huart1.Init.WordLength = UART_WORDLENGTH_8B;
|
||||
huart1.Init.StopBits = UART_STOPBITS_1;
|
||||
huart1.Init.Parity = UART_PARITY_NONE;
|
||||
|
@ -114,9 +114,6 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
|
|||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/* USART1 interrupt Init */
|
||||
HAL_NVIC_SetPriority(USART1_IRQn, 3, 1);
|
||||
HAL_NVIC_EnableIRQ(USART1_IRQn);
|
||||
/* USER CODE BEGIN USART1_MspInit 1 */
|
||||
|
||||
/* USER CODE END USART1_MspInit 1 */
|
||||
|
@ -162,7 +159,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
|
|||
__HAL_LINKDMA(uartHandle,hdmarx,hdma_usart2_rx);
|
||||
|
||||
/* USART2 interrupt Init */
|
||||
HAL_NVIC_SetPriority(USART2_IRQn, 3, 0);
|
||||
HAL_NVIC_SetPriority(USART2_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(USART2_IRQn);
|
||||
/* USER CODE BEGIN USART2_MspInit 1 */
|
||||
|
||||
|
@ -187,8 +184,6 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
|
|||
*/
|
||||
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10);
|
||||
|
||||
/* USART1 interrupt Deinit */
|
||||
HAL_NVIC_DisableIRQ(USART1_IRQn);
|
||||
/* USER CODE BEGIN USART1_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END USART1_MspDeInit 1 */
|
||||
|
@ -220,5 +215,4 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
|
|||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
|
|
@ -157,54 +157,70 @@
|
|||
<Bp>
|
||||
<Number>0</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>34</LineNumber>
|
||||
<LineNumber>39</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>134226582</Address>
|
||||
<Address>134225148</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>1</BreakIfRCount>
|
||||
<Filename>..\Peripheral\Src\bluetooth.c</Filename>
|
||||
<Filename>D:\OneDrive\OneDrive - my.swjtu.edu.cn\Data\program code\Projects\Car\Core\Src\hcsr04.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression>\\CAR\../Peripheral/Src/bluetooth.c\34</Expression>
|
||||
<Expression>\\car\../Core/Src/hcsr04.c\39</Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>1</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>32</LineNumber>
|
||||
<LineNumber>98</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>134221102</Address>
|
||||
<Address>134229854</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>1</BreakIfRCount>
|
||||
<Filename>..\Peripheral\Src\control.c</Filename>
|
||||
<Filename>../Core/Src/main.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression>\\CAR\../Peripheral/Src/control.c\32</Expression>
|
||||
<Expression>\\car\../Core/Src/main.c\98</Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>2</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>24</LineNumber>
|
||||
<LineNumber>45</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>0</Address>
|
||||
<Address>134220846</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>0</BreakIfRCount>
|
||||
<Filename>..\Peripheral\Src\bluetooth.c</Filename>
|
||||
<BreakIfRCount>1</BreakIfRCount>
|
||||
<Filename>D:\OneDrive\OneDrive - my.swjtu.edu.cn\Data\program code\Projects\Car\Core\Src\hcsr04.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression></Expression>
|
||||
<Expression>\\car\../Core/Src/hcsr04.c\45</Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>3</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>32</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>134229764</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>1</BreakIfRCount>
|
||||
<Filename>D:\OneDrive\OneDrive - my.swjtu.edu.cn\Data\program code\Projects\Car\Core\Src\hcsr04.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression>\\car\../Core/Src/hcsr04.c\32</Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>4</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>99</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>0</Address>
|
||||
|
@ -219,7 +235,7 @@
|
|||
<Expression></Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>4</Number>
|
||||
<Number>5</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>97</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
|
@ -239,25 +255,22 @@
|
|||
<Ww>
|
||||
<count>0</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>num,0x0A</ItemText>
|
||||
<ItemText>time</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>1</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>distance</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow1>
|
||||
<MemoryWindow1>
|
||||
<Mm>
|
||||
<WinNumber>1</WinNumber>
|
||||
<SubType>8</SubType>
|
||||
<ItemText>rxBuffer</ItemText>
|
||||
<SubType>0</SubType>
|
||||
<ItemText>&rxSize</ItemText>
|
||||
<AccSizeX>0</AccSizeX>
|
||||
</Mm>
|
||||
</MemoryWindow1>
|
||||
<MemoryWindow2>
|
||||
<Mm>
|
||||
<WinNumber>2</WinNumber>
|
||||
<SubType>0</SubType>
|
||||
<ItemText>num</ItemText>
|
||||
<AccSizeX>0</AccSizeX>
|
||||
</Mm>
|
||||
</MemoryWindow2>
|
||||
<Tracepoint>
|
||||
<THDelay>0</THDelay>
|
||||
</Tracepoint>
|
||||
|
@ -302,7 +315,7 @@
|
|||
<pMultCmdsp></pMultCmdsp>
|
||||
<DebugDescription>
|
||||
<Enable>1</Enable>
|
||||
<EnableFlashSeq>1</EnableFlashSeq>
|
||||
<EnableFlashSeq>0</EnableFlashSeq>
|
||||
<EnableLog>0</EnableLog>
|
||||
<Protocol>2</Protocol>
|
||||
<DbgClock>10000000</DbgClock>
|
||||
|
@ -331,7 +344,7 @@
|
|||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>Application/User/App</GroupName>
|
||||
<GroupName>Core</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
|
@ -343,8 +356,8 @@
|
|||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\App\Src\app_line_seek.c</PathWithFileName>
|
||||
<FilenameWithoutPath>app_line_seek.c</FilenameWithoutPath>
|
||||
<PathWithFileName>../Core/Src/main.c</PathWithFileName>
|
||||
<FilenameWithoutPath>main.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
|
@ -355,58 +368,14 @@
|
|||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\App\Src\app_ultrasonic.c</PathWithFileName>
|
||||
<FilenameWithoutPath>app_ultrasonic.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>Application/User/Core</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>4</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\Core\Src\syscalls.c</PathWithFileName>
|
||||
<FilenameWithoutPath>syscalls.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>5</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>../Core/Src/main.c</PathWithFileName>
|
||||
<FilenameWithoutPath>main.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>6</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>../Core/Src/gpio.c</PathWithFileName>
|
||||
<FilenameWithoutPath>gpio.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>7</FileNumber>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>4</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -417,8 +386,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>8</FileNumber>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>5</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -429,8 +398,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>9</FileNumber>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>6</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -441,8 +410,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>10</FileNumber>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>7</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -453,8 +422,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>11</FileNumber>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>8</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -465,8 +434,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>12</FileNumber>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>9</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -476,107 +445,15 @@
|
|||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>Application/User/Peripheral</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>13</FileNumber>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>10</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\Peripheral\Src\bluetooth.c</PathWithFileName>
|
||||
<FilenameWithoutPath>bluetooth.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>14</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\Peripheral\Src\control.c</PathWithFileName>
|
||||
<FilenameWithoutPath>control.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>15</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\Peripheral\Src\hcsr04.c</PathWithFileName>
|
||||
<FilenameWithoutPath>hcsr04.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>16</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\Peripheral\Src\infrared.c</PathWithFileName>
|
||||
<FilenameWithoutPath>infrared.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>17</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\Peripheral\Src\led.c</PathWithFileName>
|
||||
<FilenameWithoutPath>led.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>18</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\Peripheral\Src\line_seek.c</PathWithFileName>
|
||||
<FilenameWithoutPath>line_seek.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>19</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\Peripheral\Src\motor.c</PathWithFileName>
|
||||
<FilenameWithoutPath>motor.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>20</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\Peripheral\Src\servo.c</PathWithFileName>
|
||||
<FilenameWithoutPath>servo.c</FilenameWithoutPath>
|
||||
<PathWithFileName>..\Core\Src\syscalls.c</PathWithFileName>
|
||||
<FilenameWithoutPath>syscalls.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
|
@ -589,8 +466,8 @@
|
|||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>21</FileNumber>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>11</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -601,8 +478,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>22</FileNumber>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>12</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -613,8 +490,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>23</FileNumber>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>13</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -625,8 +502,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>24</FileNumber>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>14</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -637,8 +514,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>25</FileNumber>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>15</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -649,8 +526,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>26</FileNumber>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>16</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -661,8 +538,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>27</FileNumber>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>17</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -673,8 +550,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>28</FileNumber>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>18</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -685,8 +562,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>29</FileNumber>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>19</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -697,8 +574,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>30</FileNumber>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>20</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -709,8 +586,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>31</FileNumber>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>21</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -721,8 +598,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>32</FileNumber>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>22</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -733,8 +610,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>33</FileNumber>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>23</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -745,8 +622,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>34</FileNumber>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>24</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -757,8 +634,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>35</FileNumber>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>25</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -777,8 +654,8 @@
|
|||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>36</FileNumber>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>26</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -790,6 +667,106 @@
|
|||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>User</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>27</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\Src\bluetooth.c</PathWithFileName>
|
||||
<FilenameWithoutPath>bluetooth.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>28</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\Src\control.c</PathWithFileName>
|
||||
<FilenameWithoutPath>control.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>29</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\Src\hcsr04.c</PathWithFileName>
|
||||
<FilenameWithoutPath>hcsr04.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>30</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\Src\led.c</PathWithFileName>
|
||||
<FilenameWithoutPath>led.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>31</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\Src\motor.c</PathWithFileName>
|
||||
<FilenameWithoutPath>motor.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>32</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\Src\line_seek.c</PathWithFileName>
|
||||
<FilenameWithoutPath>line_seek.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>App</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>33</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\App\Src\app_line_seek.c</PathWithFileName>
|
||||
<FilenameWithoutPath>app_line_seek.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>::CMSIS</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
<TargetCommonOption>
|
||||
<Device>STM32F103C8</Device>
|
||||
<Vendor>STMicroelectronics</Vendor>
|
||||
<PackID>Keil.STM32F1xx_DFP.2.4.1</PackID>
|
||||
<PackURL>https://www.keil.com/pack/</PackURL>
|
||||
<PackID>Keil.STM32F1xx_DFP.2.2.0</PackID>
|
||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
||||
<Cpu>IRAM(0x20000000-0x20004FFF) IROM(0x8000000-0x800FFFF) CLOCK(8000000) CPUTYPE("Cortex-M3") TZ</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
<StartupFile></StartupFile>
|
||||
|
@ -48,8 +48,8 @@
|
|||
<NotGenerated>0</NotGenerated>
|
||||
<InvalidFlash>1</InvalidFlash>
|
||||
</TargetStatus>
|
||||
<OutputDirectory>CAR\</OutputDirectory>
|
||||
<OutputName>CAR</OutputName>
|
||||
<OutputDirectory>car\</OutputDirectory>
|
||||
<OutputName>car</OutputName>
|
||||
<CreateExecutable>1</CreateExecutable>
|
||||
<CreateLib>0</CreateLib>
|
||||
<CreateHexFile>1</CreateHexFile>
|
||||
|
@ -339,7 +339,7 @@
|
|||
<MiscControls></MiscControls>
|
||||
<Define>USE_HAL_DRIVER,STM32F103xB</Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>../App/Inc;../Core/Inc;../Peripheral/Inc;../Drivers/STM32F1xx_HAL_Driver/Inc;../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy;../Drivers/CMSIS/Device/ST/STM32F1xx/Include;../Drivers/CMSIS/Include</IncludePath>
|
||||
<IncludePath>../Core/Inc;../Drivers/STM32F1xx_HAL_Driver/Inc;../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy;../Drivers/CMSIS/Device/ST/STM32F1xx/Include;../Drivers/CMSIS/Include;../User/Inc;../App/Inc</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
|
@ -352,7 +352,7 @@
|
|||
<NoWarn>0</NoWarn>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<useXO>0</useXO>
|
||||
<ClangAsOpt>1</ClangAsOpt>
|
||||
<ClangAsOpt>4</ClangAsOpt>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
|
@ -391,28 +391,8 @@
|
|||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>Application/User/App</GroupName>
|
||||
<GroupName>Core</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>app_line_seek.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\App\Src\app_line_seek.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>app_ultrasonic.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\App\Src\app_ultrasonic.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>Application/User/Core</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>syscalls.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\Core\Src\syscalls.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>main.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
|
@ -427,6 +407,57 @@
|
|||
<FileName>dma.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>../Core/Src/dma.c</FilePath>
|
||||
<FileOption>
|
||||
<CommonProperty>
|
||||
<UseCPPCompiler>2</UseCPPCompiler>
|
||||
<RVCTCodeConst>0</RVCTCodeConst>
|
||||
<RVCTZI>0</RVCTZI>
|
||||
<RVCTOtherData>0</RVCTOtherData>
|
||||
<ModuleSelection>0</ModuleSelection>
|
||||
<IncludeInBuild>1</IncludeInBuild>
|
||||
<AlwaysBuild>2</AlwaysBuild>
|
||||
<GenerateAssemblyFile>2</GenerateAssemblyFile>
|
||||
<AssembleAssemblyFile>2</AssembleAssemblyFile>
|
||||
<PublicsOnly>2</PublicsOnly>
|
||||
<StopOnExitCode>11</StopOnExitCode>
|
||||
<CustomArgument></CustomArgument>
|
||||
<IncludeLibraryModules></IncludeLibraryModules>
|
||||
<ComprImg>1</ComprImg>
|
||||
</CommonProperty>
|
||||
<FileArmAds>
|
||||
<Cads>
|
||||
<interw>2</interw>
|
||||
<Optim>0</Optim>
|
||||
<oTime>2</oTime>
|
||||
<SplitLS>2</SplitLS>
|
||||
<OneElfS>2</OneElfS>
|
||||
<Strict>2</Strict>
|
||||
<EnumInt>2</EnumInt>
|
||||
<PlainCh>2</PlainCh>
|
||||
<Ropi>2</Ropi>
|
||||
<Rwpi>2</Rwpi>
|
||||
<wLevel>0</wLevel>
|
||||
<uThumb>2</uThumb>
|
||||
<uSurpInc>2</uSurpInc>
|
||||
<uC99>2</uC99>
|
||||
<uGnu>2</uGnu>
|
||||
<useXO>2</useXO>
|
||||
<v6Lang>0</v6Lang>
|
||||
<v6LangP>0</v6LangP>
|
||||
<vShortEn>2</vShortEn>
|
||||
<vShortWch>2</vShortWch>
|
||||
<v6Lto>2</v6Lto>
|
||||
<v6WtE>2</v6WtE>
|
||||
<v6Rtti>2</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
</FileArmAds>
|
||||
</FileOption>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>i2c.c</FileName>
|
||||
|
@ -453,50 +484,10 @@
|
|||
<FileType>1</FileType>
|
||||
<FilePath>../Core/Src/stm32f1xx_hal_msp.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>Application/User/Peripheral</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>bluetooth.c</FileName>
|
||||
<FileName>syscalls.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\Peripheral\Src\bluetooth.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>control.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\Peripheral\Src\control.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>hcsr04.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\Peripheral\Src\hcsr04.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>infrared.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\Peripheral\Src\infrared.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>led.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\Peripheral\Src\led.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>line_seek.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\Peripheral\Src\line_seek.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>motor.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\Peripheral\Src\motor.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>servo.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\Peripheral\Src\servo.c</FilePath>
|
||||
<FilePath>..\Core\Src\syscalls.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
|
@ -590,6 +581,51 @@
|
|||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>User</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>bluetooth.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\Src\bluetooth.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>control.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\Src\control.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>hcsr04.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\Src\hcsr04.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>led.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\Src\led.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>motor.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\Src\motor.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>line_seek.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\Src\line_seek.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>App</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>app_line_seek.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\App\Src\app_line_seek.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>::CMSIS</GroupName>
|
||||
</Group>
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<component_viewer schemaVersion="0.1" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="Component_Viewer.xsd">
|
||||
|
||||
<component name="EventRecorderStub" version="1.0.0"/> <!--name and version of the component-->
|
||||
<events>
|
||||
</events>
|
||||
|
||||
</component_viewer>
|
24
Makefile
24
Makefile
|
@ -1,5 +1,5 @@
|
|||
##########################################################################################################################
|
||||
# File automatically-generated by tool: [projectgenerator] version: [4.4.0-B60] date: [Wed Jul 17 21:44:09 CST 2024]
|
||||
# File automatically-generated by tool: [projectgenerator] version: [4.4.0-B60] date: [Tue Jul 16 20:05:56 CST 2024]
|
||||
##########################################################################################################################
|
||||
|
||||
# ------------------------------------------------
|
||||
|
@ -62,18 +62,14 @@ Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c \
|
|||
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c \
|
||||
Core/Src/system_stm32f1xx.c \
|
||||
Core/Src/sysmem.c \
|
||||
Peripheral/Src/hcsr04.c \
|
||||
Peripheral/Src/motor.c \
|
||||
Peripheral/Src/led.c \
|
||||
Peripheral/Src/bluetooth.c \
|
||||
Peripheral/Src/control.c \
|
||||
Peripheral/Src/line_seek.c \
|
||||
Peripheral/Src/path_plan.c \
|
||||
Peripheral/Src/servo.c \
|
||||
Peripheral/Src/infrared.c \
|
||||
App/Src/app_line_seek.c \
|
||||
App/Src/app_ultrasonic.c
|
||||
|
||||
User/Src/hcsr04.c \
|
||||
User/Src/motor.c \
|
||||
User/Src/led.c \
|
||||
User/Src/bluetooth.c \
|
||||
User/Src/control.c \
|
||||
User/Src/line_seek.c \
|
||||
User/Src/path_plan.c \
|
||||
App/Src/app_line_seek.c
|
||||
|
||||
# ASM sources
|
||||
ASM_SOURCES = \
|
||||
|
@ -134,7 +130,7 @@ AS_INCLUDES =
|
|||
# C includes
|
||||
C_INCLUDES = \
|
||||
-ICore/Inc \
|
||||
-IPeripheral/Inc \
|
||||
-IUser/Inc \
|
||||
-IApp/Inc \
|
||||
-IDrivers/STM32F1xx_HAL_Driver/Inc \
|
||||
-IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy \
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
#ifndef __CONTROL_H
|
||||
#define __CONTROL_H
|
||||
|
||||
#include "main.h"
|
||||
|
||||
#define MODE_STOP 0
|
||||
// 遥控模式
|
||||
#define MODE_REMOTE 1
|
||||
// 巡线模式
|
||||
#define MODE_PATROL 2
|
||||
// 避障模式
|
||||
#define MODE_AVOID 3
|
||||
|
||||
// 小车运行模式
|
||||
extern uint8_t mode;
|
||||
|
||||
void CONTROL_CommonCmd(uint8_t type, uint8_t state);
|
||||
void CONTROL_RGB(uint8_t r, uint8_t g, uint8_t b);
|
||||
void CONTROL_Mode(uint8_t new_mode, uint8_t state);
|
||||
|
||||
#endif
|
|
@ -1,21 +0,0 @@
|
|||
#ifndef __INFRARED_H
|
||||
#define __INFRARED_H
|
||||
|
||||
// 红外避障模块
|
||||
|
||||
#include "main.h"
|
||||
|
||||
// 有障碍
|
||||
#define INFRARED_MEET 0
|
||||
// 无障碍
|
||||
#define INFRARED_NONE 1
|
||||
|
||||
/// @brief 红外模块检测左前方20-30厘米(估计值)是否有障碍
|
||||
/// @return 有障碍:INFRARED_MEET 无障碍:INFRARED_NONE
|
||||
uint8_t INFRARED_GetL();
|
||||
|
||||
/// @brief 红外模块检测右前方20-30厘米(估计值)是否有障碍
|
||||
/// @return 有障碍:INFRARED_MEET 无障碍:INFRARED_NONE
|
||||
uint8_t INFRARED_GetR();
|
||||
|
||||
#endif
|
|
@ -1,12 +0,0 @@
|
|||
#ifndef __SERVO_H
|
||||
#define __SERVO_H
|
||||
|
||||
#include "main.h"
|
||||
|
||||
void SERVO_Init();
|
||||
|
||||
/// @brief 控制舵机转动
|
||||
/// @param degree 0-180
|
||||
void SERVO_Rotate(uint8_t degree);
|
||||
|
||||
#endif
|
|
@ -1,189 +0,0 @@
|
|||
#include "control.h"
|
||||
#include "hcsr04.h"
|
||||
#include "led.h"
|
||||
#include "motor.h"
|
||||
|
||||
#define CMD_MOVE 0
|
||||
#define CMD_ROTATE 1
|
||||
#define CMD_BUZZER 2
|
||||
#define CMD_SPEED 3
|
||||
// #define CMD_SHAKE 4
|
||||
// #define CMD_SING 5
|
||||
#define CMD_LED 6
|
||||
// #define CMD_FIRE 7
|
||||
// #define CMD_SERVO 8
|
||||
|
||||
// 小车默认速度
|
||||
static int8_t speed = 20;
|
||||
uint8_t mode = MODE_REMOTE;
|
||||
|
||||
void carMove(uint8_t state);
|
||||
void carSpin(uint8_t state);
|
||||
void callBuzzer(uint8_t state);
|
||||
void setSpeed(uint8_t state);
|
||||
// void shake(uint8_t state);
|
||||
// void sing(uint8_t state);
|
||||
void setLed(uint8_t state);
|
||||
// void fire(uint8_t state);
|
||||
// void servo(uint8_t state);
|
||||
|
||||
void CONTROL_CommonCmd(uint8_t type, uint8_t state)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case CMD_MOVE:
|
||||
carMove(state);
|
||||
break;
|
||||
case CMD_ROTATE:
|
||||
carSpin(state);
|
||||
break;
|
||||
case CMD_BUZZER:
|
||||
callBuzzer(state);
|
||||
break;
|
||||
case CMD_SPEED:
|
||||
setSpeed(state);
|
||||
break;
|
||||
// case CMD_SHAKE:
|
||||
// break;
|
||||
// case CMD_SING:
|
||||
// break;
|
||||
case CMD_LED:
|
||||
setLed(state);
|
||||
break;
|
||||
// case CMD_FIRE:
|
||||
// break;
|
||||
// case CMD_SERVO:
|
||||
// break;
|
||||
}
|
||||
}
|
||||
|
||||
void CONTROL_RGB(uint8_t r, uint8_t g, uint8_t b)
|
||||
{
|
||||
LED_Start(LED_ALL);
|
||||
LED_SetDuty(r, g, b);
|
||||
}
|
||||
|
||||
void CONTROL_Mode(uint8_t new_mode, uint8_t state)
|
||||
{
|
||||
if (state == 0)
|
||||
{
|
||||
mode = MODE_STOP;
|
||||
MOTOR_Stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
mode = new_mode;
|
||||
switch (new_mode)
|
||||
{
|
||||
case MODE_REMOTE:
|
||||
speed = 20;
|
||||
MOTOR_SetDuty(speed, speed);
|
||||
MOTOR_Init();
|
||||
break;
|
||||
case MODE_PATROL:
|
||||
break;
|
||||
case MODE_AVOID:
|
||||
break;
|
||||
default:
|
||||
mode = MODE_STOP;
|
||||
MOTOR_Stop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void carMove(uint8_t state)
|
||||
{
|
||||
if (state == 0)
|
||||
MOTOR_Stop();
|
||||
else
|
||||
{
|
||||
MOTOR_Init();
|
||||
switch (state)
|
||||
{
|
||||
// 前进
|
||||
case 1:
|
||||
MOTOR_SetDuty(speed, speed);
|
||||
break;
|
||||
// 后退
|
||||
case 2:
|
||||
MOTOR_SetDuty(-speed, -speed);
|
||||
break;
|
||||
// 左转
|
||||
case 3:
|
||||
MOTOR_SetDuty(0, speed);
|
||||
break;
|
||||
// 右转
|
||||
case 4:
|
||||
MOTOR_SetDuty(speed, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void carSpin(uint8_t state)
|
||||
{
|
||||
if (state == 1)
|
||||
MOTOR_SetDuty(speed, -speed);
|
||||
else if (state == 2)
|
||||
MOTOR_SetDuty(-speed, speed);
|
||||
}
|
||||
|
||||
void callBuzzer(uint8_t state)
|
||||
{
|
||||
HAL_GPIO_WritePin(FM_K2_POWERC_GPIO_Port, FM_K2_POWERC_Pin, GPIO_PIN_RESET);
|
||||
HAL_Delay(200);
|
||||
HAL_GPIO_WritePin(FM_K2_POWERC_GPIO_Port, FM_K2_POWERC_Pin, GPIO_PIN_SET);
|
||||
}
|
||||
|
||||
void setSpeed(uint8_t state)
|
||||
{
|
||||
if (state == 1)
|
||||
speed += 10;
|
||||
else if (state == 2)
|
||||
speed -= 10;
|
||||
if (speed > 100)
|
||||
speed = 100;
|
||||
else if (speed < 20)
|
||||
speed = 20;
|
||||
}
|
||||
|
||||
void setLed(uint8_t state)
|
||||
{
|
||||
LED_Start(LED_ALL);
|
||||
switch (state)
|
||||
{
|
||||
// 白
|
||||
case 1:
|
||||
LED_SetDuty(255, 255, 255);
|
||||
break;
|
||||
// 红
|
||||
case 2:
|
||||
LED_SetDuty(255, 0, 0);
|
||||
break;
|
||||
// 绿
|
||||
case 3:
|
||||
LED_SetDuty(0, 255, 0);
|
||||
break;
|
||||
// 蓝
|
||||
case 4:
|
||||
LED_SetDuty(0, 0, 255);
|
||||
break;
|
||||
// 青
|
||||
case 5:
|
||||
LED_SetDuty(0, 255, 255);
|
||||
break;
|
||||
// 品红
|
||||
case 6:
|
||||
LED_SetDuty(255, 0, 255);
|
||||
break;
|
||||
// 黄
|
||||
case 7:
|
||||
LED_SetDuty(255, 255, 0);
|
||||
break;
|
||||
// 关
|
||||
default:
|
||||
LED_SetDuty(0, 0, 0);
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
#include "infrared.h"
|
||||
|
||||
inline uint8_t INFRARED_GetL()
|
||||
{
|
||||
return HAL_GPIO_ReadPin(HWL_GPIO_Port, HWL_Pin);
|
||||
}
|
||||
|
||||
inline uint8_t INFRARED_GetR()
|
||||
{
|
||||
return HAL_GPIO_ReadPin(HWR_GPIO_Port, HWR_Pin);
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
#include "servo.h"
|
||||
#include "tim.h"
|
||||
|
||||
void SERVO_Init()
|
||||
{
|
||||
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_4);
|
||||
}
|
||||
|
||||
void SERVO_Rotate(uint8_t degree)
|
||||
{
|
||||
if (degree > 180)
|
||||
degree = 180;
|
||||
uint16_t compare = 200.0 / 180 * degree + 50;
|
||||
__HAL_TIM_SetCompare(&htim1, TIM_CHANNEL_4, compare);
|
||||
}
|
10
User/Inc/control.h
Normal file
10
User/Inc/control.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
#ifndef __CONTROL_H
|
||||
#define __CONTROL_H
|
||||
|
||||
#include "main.h"
|
||||
|
||||
void CONTROL_CommonCmd(uint8_t type, uint8_t state);
|
||||
void CONTROL_RGB(uint8_t r, uint8_t g, uint8_t b);
|
||||
void CONTROL_Mode(uint8_t mode, uint8_t state);
|
||||
|
||||
#endif
|
|
@ -10,6 +10,6 @@ void HC_SR04_Init(void);
|
|||
uint32_t sonar_mm(void);
|
||||
|
||||
// 测距完毕回调,执行完自定义任务后将sonor_state置0
|
||||
void Sonar_CP_Callback(void);
|
||||
void Sonar_CP_Callback(void);
|
||||
|
||||
#endif
|
|
@ -1,41 +1,29 @@
|
|||
#include "bluetooth.h"
|
||||
#include "usart.h"
|
||||
#include "control.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "syscalls.h"
|
||||
|
||||
#include "control.h"
|
||||
#include "usart.h"
|
||||
|
||||
#define BUFFER_SIZE 100
|
||||
#define MESSAGE_SIZE 19
|
||||
#define CMD_NUM 9
|
||||
|
||||
static int8_t rxBuffer[BUFFER_SIZE], txBuffer[10000];
|
||||
static uint16_t txLen;
|
||||
static int8_t rxBuffer[BUFFER_SIZE], txBuffer[BUFFER_SIZE];
|
||||
static uint8_t cmdIndex;
|
||||
|
||||
void BLUETOOTH_Init(void)
|
||||
{
|
||||
HAL_UARTEx_ReceiveToIdle_IT(&huart2, rxBuffer, 100);
|
||||
// HAL_UART_Receive_IT(&huart2, txBuffer + txLen, 1);
|
||||
HAL_UARTEx_ReceiveToIdle_DMA(&huart2, rxBuffer, 100);
|
||||
}
|
||||
|
||||
// void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
|
||||
// {
|
||||
// if (huart == &huart2)
|
||||
// {
|
||||
// ++txLen;
|
||||
// if (txLen == 10000)
|
||||
// txLen = 0;
|
||||
// }
|
||||
// }
|
||||
|
||||
void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)
|
||||
{
|
||||
if (huart == &huart2 && rxBuffer[0] == '$' && rxBuffer[Size - 1] == '#')
|
||||
{
|
||||
rxBuffer[Size] = '\0';
|
||||
// 通用协议
|
||||
if (mode == MODE_REMOTE && rxBuffer[2] == ',')
|
||||
if (rxBuffer[2] == ',')
|
||||
{
|
||||
cmdIndex = 0;
|
||||
for (uint8_t i = 1; i < MESSAGE_SIZE; i += 2)
|
||||
|
@ -45,19 +33,11 @@ void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)
|
|||
break;
|
||||
if (cmdIndex == CMD_NUM)
|
||||
cmdIndex = 0;
|
||||
CONTROL_CommonCmd(cmdIndex, rxBuffer[cmdIndex * 2 + 1] - '0');
|
||||
CONTROL_CommonCmd(cmdIndex, rxBuffer[cmdIndex * 2 + 1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
static uint16_t num[6];
|
||||
|
||||
// 模式选择
|
||||
if (rxBuffer[5] == 'M')
|
||||
{
|
||||
sscanf(rxBuffer + 5, "%*4s%c%c", num, num + 1);
|
||||
CONTROL_Mode(num[0] - '0', num[1] - '0');
|
||||
}
|
||||
else if (mode == MODE_REMOTE)
|
||||
switch (rxBuffer[5])
|
||||
{
|
||||
// 机械手
|
||||
|
@ -71,17 +51,17 @@ void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)
|
|||
sscanf(rxBuffer + 5, "%*3s%hu,%*3s%hu,%*3s%hu", num, num + 1, num + 2);
|
||||
CONTROL_RGB(num[0], num[1], num[2]);
|
||||
break;
|
||||
|
||||
// 模式选择
|
||||
case 'M':
|
||||
sscanf(rxBuffer + 5, "%*4s%c%c", num, num + 1);
|
||||
CONTROL_Mode(num[0] - '0', num[1] - '0');
|
||||
break;
|
||||
}
|
||||
}
|
||||
// my_printf(&huart2, rxBuffer);
|
||||
// strcpy(txBuffer + txLen, rxBuffer);
|
||||
// if (txLen + Size >= 9999)
|
||||
// txLen = 0;
|
||||
// else
|
||||
// txLen += Size;
|
||||
// txBuffer[txLen] = '\0';
|
||||
// if (strcmp(rxBuffer, "$send#") == 0)
|
||||
// my_printf(&huart2, txBuffer);
|
||||
memcpy(txBuffer, rxBuffer, Size);
|
||||
printf("%s", txBuffer);
|
||||
HAL_UART_Transmit_IT(&huart2, txBuffer, Size);
|
||||
BLUETOOTH_Init();
|
||||
}
|
||||
}
|
88
User/Src/control.c
Normal file
88
User/Src/control.c
Normal file
|
@ -0,0 +1,88 @@
|
|||
#include "control.h"
|
||||
#include "hcsr04.h"
|
||||
#include "led.h"
|
||||
#include "motor.h"
|
||||
|
||||
#define CMD_MOVE 0
|
||||
#define CMD_ROTATE 1
|
||||
#define CMD_BUZZER 2
|
||||
#define CMD_SPEED 3
|
||||
// #define CMD_SHAKE 4
|
||||
// #define CMD_SING 5
|
||||
#define CMD_LED 6
|
||||
// #define CMD_FIRE 7
|
||||
// #define CMD_SERVO 8
|
||||
|
||||
void move(uint8_t state);
|
||||
void rotate(uint8_t state);
|
||||
void buzzer(uint8_t state);
|
||||
void speed(uint8_t state);
|
||||
// void shake(uint8_t state);
|
||||
// void sing(uint8_t state);
|
||||
void led(uint8_t state);
|
||||
// void fire(uint8_t state);
|
||||
// void servo(uint8_t state);
|
||||
|
||||
void CONTROL_CommonCmd(uint8_t type, uint8_t state)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case CMD_MOVE:
|
||||
move(state);
|
||||
break;
|
||||
case CMD_ROTATE:
|
||||
rotate(state);
|
||||
break;
|
||||
case CMD_BUZZER:
|
||||
buzzer(state);
|
||||
break;
|
||||
case CMD_SPEED:
|
||||
speed(state);
|
||||
break;
|
||||
// case CMD_SHAKE:
|
||||
// break;
|
||||
// case CMD_SING:
|
||||
// break;
|
||||
case CMD_LED:
|
||||
led(state);
|
||||
break;
|
||||
// case CMD_FIRE:
|
||||
// break;
|
||||
// case CMD_SERVO:
|
||||
// break;
|
||||
}
|
||||
}
|
||||
|
||||
void CONTROL_RGB(uint8_t r, uint8_t g, uint8_t b)
|
||||
{
|
||||
LED_Start(LED_ALL);
|
||||
LED_SetDuty(r, g, b);
|
||||
}
|
||||
|
||||
void CONTROL_Mode(uint8_t mode, uint8_t state)
|
||||
{
|
||||
}
|
||||
|
||||
void move(uint8_t state)
|
||||
{
|
||||
}
|
||||
|
||||
void rotate(uint8_t state)
|
||||
{
|
||||
}
|
||||
|
||||
void buzzer(uint8_t state)
|
||||
{
|
||||
if (state)
|
||||
HAL_GPIO_WritePin(FM_K2_POWERC_GPIO_Port, FM_K2_POWERC_Pin, GPIO_PIN_RESET);
|
||||
else
|
||||
HAL_GPIO_WritePin(FM_K2_POWERC_GPIO_Port, FM_K2_POWERC_Pin, GPIO_PIN_SET);
|
||||
}
|
||||
|
||||
void speed(uint8_t state)
|
||||
{
|
||||
}
|
||||
|
||||
void led(uint8_t state)
|
||||
{
|
||||
}
|
|
@ -1,13 +1,14 @@
|
|||
#include "hcsr04.h"
|
||||
#include "tim.h"
|
||||
#include "syscalls.h"
|
||||
|
||||
static uint64_t time_start; // 声明变量,用来计时
|
||||
static uint64_t time_end; // 声明变量,存储回波信号时间
|
||||
uint8_t sonor_state; // 测距状态变量,0:未测量,1:正在测量,2:已测量
|
||||
#include "stm32f1xx_hal_tim.h"
|
||||
#include "tim.h"
|
||||
|
||||
uint64_t time; // 声明变量,用来计时
|
||||
uint64_t time_end; // 声明变量,存储回波信号时间
|
||||
uint8_t sonor_state = 1; // 测距状态变量,0:未测量,1:正在测量,2:已测量
|
||||
uint32_t sonor_distance; // 测量出的距离,单位mm
|
||||
|
||||
void HCSR04_HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim);
|
||||
void HCSR04_HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef* htim);
|
||||
|
||||
// 初始化超声波测距
|
||||
void HC_SR04_Init(void)
|
||||
|
@ -24,9 +25,9 @@ void HC_SR04_Init(void)
|
|||
uint32_t sonar_mm(void)
|
||||
{
|
||||
sonor_state = 1;
|
||||
HAL_GPIO_WritePin(TRIG_GPIO_Port, TRIG_Pin, GPIO_PIN_SET); // 输出高电平
|
||||
HAL_GPIO_WritePin(Trig_GPIO_Port, Trig_Pin, GPIO_PIN_SET); // 输出高电平
|
||||
delay_us(15); // 延时15微秒
|
||||
HAL_GPIO_WritePin(TRIG_GPIO_Port, TRIG_Pin, GPIO_PIN_RESET); // 输出低电平
|
||||
HAL_GPIO_WritePin(Trig_GPIO_Port, Trig_Pin, GPIO_PIN_RESET); // 输出低电平
|
||||
if (time_end / 100 < 38)
|
||||
{ // 判断是否小于38毫秒,大于38毫秒的就是超时,直接调到下面返回0
|
||||
sonor_distance = (time_end * 346) / 2; // 计算距离,25°C空气中的音速为346m/s
|
||||
|
@ -35,37 +36,36 @@ uint32_t sonar_mm(void)
|
|||
return sonor_distance;
|
||||
}
|
||||
|
||||
void HCSR04_HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
||||
void HCSR04_HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef* htim)
|
||||
{
|
||||
if (htim == &htim2)
|
||||
{
|
||||
// 每10us自增一
|
||||
++time_start;
|
||||
{ // 每10us自增一
|
||||
time++;
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
||||
{
|
||||
if (GPIO_Pin == ECHO_Pin)
|
||||
if (GPIO_Pin == Echo_Pin)
|
||||
{
|
||||
if (HAL_GPIO_ReadPin(ECHO_GPIO_Port, ECHO_Pin))
|
||||
if (HAL_GPIO_ReadPin(Echo_GPIO_Port, Echo_Pin))
|
||||
{
|
||||
time_start = 0;
|
||||
HAL_TIM_Base_Start_IT(&htim2);
|
||||
time = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
time_end = time_start;
|
||||
time_end = time;
|
||||
HAL_TIM_Base_Stop_IT(&htim2);
|
||||
sonor_state = 2;
|
||||
Sonar_CP_Callback();
|
||||
sonor_state = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 测距完毕回调,执行完自定义任务后将sonor_state置0
|
||||
__attribute__((weak)) void Sonar_CP_Callback()
|
||||
// 测距完毕回调,执行完自定义任务后将sonor_state置0void
|
||||
__attribute__((weak)) void Sonar_CP_Callback(void)
|
||||
{
|
||||
my_printf(HUART2, "distance = %d (mm)\n", sonor_distance);
|
||||
sonor_state = 0;
|
||||
printf("distance = %d (mm)\n", sonor_distance);
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
#include "line_seek.h"
|
||||
|
||||
#include "main.h"
|
Loading…
Reference in New Issue
Block a user