Compare commits

..

2 Commits

Author SHA1 Message Date
3af55aae9d Merge branch 'feat-csj' into dev 2024-07-14 21:04:05 +08:00
5722248576 feat: 初创巡线模块+重构 2024-07-14 21:03:50 +08:00
13 changed files with 389 additions and 322 deletions

6
App/Inc/app_line_seek.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef __APP_LINE_SEEK_H
#define __APP_LINE_SEEK_H
void App_LineSeek(void);
#endif

47
App/Src/app_line_seek.c Normal file
View File

@ -0,0 +1,47 @@
#include "app_line_seek.h"
#include "line_seek.h"
#include "main.h"
#include "motor.h"
#include "syscalls.h"
void App_LineSeek(void)
{
int LineL1 = 1, LineL2 = 1, LineR1 = 1, LineR2 = 1;
LineSeek_Get(&LineL1, &LineL2, &LineR1, &LineR2); // 获取黑线检测状态
if ((LineL1 == LOW || LineL2 == LOW) && LineR2 == LOW) // 左大弯
{
MOTOR_SetDuty(-30, 30); // 左旋
HAL_Delay(80);
}
else if (LineL1 == LOW && (LineR1 == LOW || LineR2 == LOW)) // 右大弯
{
MOTOR_SetDuty(30, -30); // 右旋
HAL_Delay(80);
}
else if (LineL1 == LOW) // 左最外侧检测
{
MOTOR_SetDuty(-50, 50); // 左旋
HAL_Delay(10);
}
else if (LineR2 == LOW) // 右最外侧检测
{
MOTOR_SetDuty(50, -50); // 右旋
HAL_Delay(10);
}
else if (LineL2 == LOW && LineR1 == HIGH) // 中间黑线上的传感器微调车左转
{
MOTOR_SetDuty(0, 50); // 左转
}
else if (LineL2 == HIGH && LineR1 == LOW) // 中间黑线上的传感器微调车右转
{
MOTOR_SetDuty(50, 0); // 右转
}
else if (LineL2 == LOW && LineR1 == LOW) // 都是黑色, 加速前进
{
MOTOR_SetDuty(50, 50); // 直走
}
}

87
CAR.ioc
View File

@ -31,34 +31,38 @@ Mcu.IP9=USART2
Mcu.IPNb=10 Mcu.IPNb=10
Mcu.Name=STM32F103C(8-B)Tx Mcu.Name=STM32F103C(8-B)Tx
Mcu.Package=LQFP48 Mcu.Package=LQFP48
Mcu.Pin0=PD0-OSC_IN Mcu.Pin0=PC13-TAMPER-RTC
Mcu.Pin1=PD1-OSC_OUT Mcu.Pin1=PC14-OSC32_IN
Mcu.Pin10=PB11 Mcu.Pin10=PB0
Mcu.Pin11=PA9 Mcu.Pin11=PB1
Mcu.Pin12=PA10 Mcu.Pin12=PB10
Mcu.Pin13=PA12 Mcu.Pin13=PB11
Mcu.Pin14=PA13 Mcu.Pin14=PB12
Mcu.Pin15=PA14 Mcu.Pin15=PA9
Mcu.Pin16=PA15 Mcu.Pin16=PA10
Mcu.Pin17=PB4 Mcu.Pin17=PA12
Mcu.Pin18=PB5 Mcu.Pin18=PA13
Mcu.Pin19=PB6 Mcu.Pin19=PA14
Mcu.Pin2=PA0-WKUP Mcu.Pin2=PC15-OSC32_OUT
Mcu.Pin20=PB7 Mcu.Pin20=PA15
Mcu.Pin21=PB8 Mcu.Pin21=PB4
Mcu.Pin22=PB9 Mcu.Pin22=PB5
Mcu.Pin23=VP_SYS_VS_Systick Mcu.Pin23=PB6
Mcu.Pin24=VP_TIM2_VS_ClockSourceINT Mcu.Pin24=PB7
Mcu.Pin25=VP_TIM3_VS_ClockSourceINT Mcu.Pin25=PB8
Mcu.Pin26=VP_TIM4_VS_ClockSourceINT Mcu.Pin26=PB9
Mcu.Pin3=PA1 Mcu.Pin27=VP_SYS_VS_Systick
Mcu.Pin4=PA2 Mcu.Pin28=VP_TIM2_VS_ClockSourceINT
Mcu.Pin5=PA3 Mcu.Pin29=VP_TIM3_VS_ClockSourceINT
Mcu.Pin6=PA7 Mcu.Pin3=PD0-OSC_IN
Mcu.Pin7=PB0 Mcu.Pin30=VP_TIM4_VS_ClockSourceINT
Mcu.Pin8=PB1 Mcu.Pin4=PD1-OSC_OUT
Mcu.Pin9=PB10 Mcu.Pin5=PA0-WKUP
Mcu.PinsNb=27 Mcu.Pin6=PA1
Mcu.Pin7=PA2
Mcu.Pin8=PA3
Mcu.Pin9=PA7
Mcu.PinsNb=31
Mcu.ThirdPartyNb=0 Mcu.ThirdPartyNb=0
Mcu.UserConstants= Mcu.UserConstants=
Mcu.UserName=STM32F103C8Tx Mcu.UserName=STM32F103C8Tx
@ -134,6 +138,11 @@ PB11.GPIO_Label=MPU6050_SDA
PB11.Locked=true PB11.Locked=true
PB11.Mode=I2C PB11.Mode=I2C
PB11.Signal=I2C2_SDA PB11.Signal=I2C2_SDA
PB12.GPIOParameters=GPIO_PuPd,GPIO_Label
PB12.GPIO_Label=LineSeek_R2
PB12.GPIO_PuPd=GPIO_PULLUP
PB12.Locked=true
PB12.Signal=GPIO_Input
PB4.GPIOParameters=GPIO_Label PB4.GPIOParameters=GPIO_Label
PB4.GPIO_Label=R_FORWARD PB4.GPIO_Label=R_FORWARD
PB4.Locked=true PB4.Locked=true
@ -157,6 +166,21 @@ PB9.GPIOParameters=GPIO_Label
PB9.GPIO_Label=L_FORWARD PB9.GPIO_Label=L_FORWARD
PB9.Locked=true PB9.Locked=true
PB9.Signal=GPIO_Output PB9.Signal=GPIO_Output
PC13-TAMPER-RTC.GPIOParameters=GPIO_PuPd,GPIO_Label
PC13-TAMPER-RTC.GPIO_Label=LineSeek_L2
PC13-TAMPER-RTC.GPIO_PuPd=GPIO_PULLUP
PC13-TAMPER-RTC.Locked=true
PC13-TAMPER-RTC.Signal=GPIO_Input
PC14-OSC32_IN.GPIOParameters=GPIO_PuPd,GPIO_Label
PC14-OSC32_IN.GPIO_Label=LineSeek_L1
PC14-OSC32_IN.GPIO_PuPd=GPIO_PULLUP
PC14-OSC32_IN.Locked=true
PC14-OSC32_IN.Signal=GPIO_Input
PC15-OSC32_OUT.GPIOParameters=GPIO_PuPd,GPIO_Label
PC15-OSC32_OUT.GPIO_Label=LineSeek_R1
PC15-OSC32_OUT.GPIO_PuPd=GPIO_PULLUP
PC15-OSC32_OUT.Locked=true
PC15-OSC32_OUT.Signal=GPIO_Input
PD0-OSC_IN.Mode=HSE-External-Oscillator PD0-OSC_IN.Mode=HSE-External-Oscillator
PD0-OSC_IN.Signal=RCC_OSC_IN PD0-OSC_IN.Signal=RCC_OSC_IN
PD1-OSC_OUT.Mode=HSE-External-Oscillator PD1-OSC_OUT.Mode=HSE-External-Oscillator
@ -185,7 +209,7 @@ ProjectManager.ProjectBuild=false
ProjectManager.ProjectFileName=CAR.ioc ProjectManager.ProjectFileName=CAR.ioc
ProjectManager.ProjectName=CAR ProjectManager.ProjectName=CAR
ProjectManager.ProjectStructure= ProjectManager.ProjectStructure=
ProjectManager.RegisterCallBack=TIM ProjectManager.RegisterCallBack=TIM,USART
ProjectManager.StackSize=0x400 ProjectManager.StackSize=0x400
ProjectManager.TargetToolchain=Makefile ProjectManager.TargetToolchain=Makefile
ProjectManager.ToolChainLocation= ProjectManager.ToolChainLocation=
@ -247,12 +271,13 @@ TIM4.Period=100
TIM4.Prescaler=720 - 1 TIM4.Prescaler=720 - 1
TIM4.Pulse-PWM\ Generation1\ CH1=100 TIM4.Pulse-PWM\ Generation1\ CH1=100
TIM4.Pulse-PWM\ Generation2\ CH2=100 TIM4.Pulse-PWM\ Generation2\ CH2=100
USART1.BaudRate=115200 USART1.BaudRate=9600
USART1.IPParameters=VirtualMode,BaudRate,Parity,WordLength USART1.IPParameters=VirtualMode,BaudRate,Parity,WordLength
USART1.Parity=PARITY_NONE USART1.Parity=PARITY_NONE
USART1.VirtualMode=VM_ASYNC USART1.VirtualMode=VM_ASYNC
USART1.WordLength=WORDLENGTH_8B USART1.WordLength=WORDLENGTH_8B
USART2.IPParameters=VirtualMode USART2.BaudRate=9600
USART2.IPParameters=VirtualMode,BaudRate
USART2.VirtualMode=VM_ASYNC USART2.VirtualMode=VM_ASYNC
VP_SYS_VS_Systick.Mode=SysTick VP_SYS_VS_Systick.Mode=SysTick
VP_SYS_VS_Systick.Signal=SYS_VS_Systick VP_SYS_VS_Systick.Signal=SYS_VS_Systick

View File

@ -57,6 +57,12 @@ void Error_Handler(void);
/* USER CODE END EFP */ /* USER CODE END EFP */
/* Private defines -----------------------------------------------------------*/ /* Private defines -----------------------------------------------------------*/
#define LineSeek_L2_Pin GPIO_PIN_13
#define LineSeek_L2_GPIO_Port GPIOC
#define LineSeek_L1_Pin GPIO_PIN_14
#define LineSeek_L1_GPIO_Port GPIOC
#define LineSeek_R1_Pin GPIO_PIN_15
#define LineSeek_R1_GPIO_Port GPIOC
#define FM_K2_POWERC_Pin GPIO_PIN_0 #define FM_K2_POWERC_Pin GPIO_PIN_0
#define FM_K2_POWERC_GPIO_Port GPIOA #define FM_K2_POWERC_GPIO_Port GPIOA
#define FAN_GS_Pin GPIO_PIN_1 #define FAN_GS_Pin GPIO_PIN_1
@ -71,6 +77,8 @@ void Error_Handler(void);
#define MPU6050_SCL_GPIO_Port GPIOB #define MPU6050_SCL_GPIO_Port GPIOB
#define MPU6050_SDA_Pin GPIO_PIN_11 #define MPU6050_SDA_Pin GPIO_PIN_11
#define MPU6050_SDA_GPIO_Port GPIOB #define MPU6050_SDA_GPIO_Port GPIOB
#define LineSeek_R2_Pin GPIO_PIN_12
#define LineSeek_R2_GPIO_Port GPIOB
#define Echo_Pin GPIO_PIN_12 #define Echo_Pin GPIO_PIN_12
#define Echo_GPIO_Port GPIOA #define Echo_GPIO_Port GPIOA
#define Echo_EXTI_IRQn EXTI15_10_IRQn #define Echo_EXTI_IRQn EXTI15_10_IRQn
@ -90,7 +98,8 @@ void Error_Handler(void);
#define L_FORWARD_GPIO_Port GPIOB #define L_FORWARD_GPIO_Port GPIOB
/* USER CODE BEGIN Private defines */ /* USER CODE BEGIN Private defines */
#define LOW (0)
#define HIGH (1)
/* USER CODE END Private defines */ /* USER CODE END Private defines */
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -6,44 +6,14 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stm32f1xx_hal_uart.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include "usart.h"
#define HUART1 (&huart1) #define HUART1 (&huart1)
#define HUART2 (&huart2) #define HUART2 (&huart2)
extern UART_HandleTypeDef huart1; // 条件编译,适配不同平台 (GNU, GCC)
extern int __io_putchar(int ch) __attribute__((weak));
extern int __io_getchar(void) __attribute__((weak));
__attribute__((weak)) int _read(int file, char *ptr, int len)
{
(void)file;
int DataIdx;
for (DataIdx = 0; DataIdx < len; DataIdx++)
{
*ptr++ = __io_getchar();
}
return len;
}
__attribute__((weak)) int _write(int file, char *ptr, int len)
{
(void)file;
int DataIdx;
for (DataIdx = 0; DataIdx < len; DataIdx++)
{
__io_putchar(*ptr++);
}
return len;
}
// 条件编译
#ifdef __GNUC__ #ifdef __GNUC__
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch) #define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#define GETCHAR_PROTOTYPE int __io_getchar(void) #define GETCHAR_PROTOTYPE int __io_getchar(void)
@ -52,58 +22,13 @@ __attribute__((weak)) int _write(int file, char *ptr, int len)
#define GETCHAR_PROTOTYPE int fgetc(FILE *f) #define GETCHAR_PROTOTYPE int fgetc(FILE *f)
#endif /* __GNUC__ */ #endif /* __GNUC__ */
/** int _read(int file, char *ptr, int len);
* @brief C printf huart1 int _write(int file, char *ptr, int len);
* @author Suroy
* @param ch
* @param f
* @return int
*
* @usage printf("USART1_Target:\r\n");
*/
PUTCHAR_PROTOTYPE
{
HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, HAL_MAX_DELAY); // 阻塞式无限等待
return ch;
}
/** PUTCHAR_PROTOTYPE;
* @brief c库函数 getchar,scanf到 DEBUG_USARTx GETCHAR_PROTOTYPE;
* C scanf huart1
*
* @param f
* @return int
*
* @usage scanf("%c", &RecData);
*/
GETCHAR_PROTOTYPE
{
uint8_t ch = 0;
HAL_UART_Receive(&huart1, (uint8_t *)&ch, 1, HAL_MAX_DELAY);
return ch;
}
void delay_us(uint16_t us) void delay_us(uint16_t us);
{ void my_printf(UART_HandleTypeDef *huart, const char *buf, ...);
uint32_t delay = (HAL_RCC_GetHCLKFreq() / 4000000 * us);
while (delay--);
}
/**
* @brief printf
* @param huart, buf
* @return void
*
* @usage my_printf(HUART1, "USART1_Target:\r\n");
*/
void my_printf(UART_HandleTypeDef *huart, const char *buf, ...)
{
char str[255] = {0};
va_list v;
va_start(v, buf);
vsprintf(str, buf, v);
HAL_UART_Transmit(huart, (const uint8_t *)str, strlen(str), 0xff);
va_end(v);
}
#endif #endif

View File

@ -27,6 +27,7 @@
/* Private includes ----------------------------------------------------------*/ /* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */ /* USER CODE BEGIN Includes */
#include "bluetooth.h"
#include "hcsr04.h" #include "hcsr04.h"
#include "led.h" #include "led.h"
#include "motor.h" #include "motor.h"
@ -72,7 +73,8 @@ void SystemClock_Config(void);
* @brief The application entry point. * @brief The application entry point.
* @retval int * @retval int
*/ */
int main(void) { int main(void)
{
/* USER CODE BEGIN 1 */ /* USER CODE BEGIN 1 */
/* USER CODE END 1 */ /* USER CODE END 1 */
@ -102,9 +104,9 @@ int main(void) {
MX_TIM4_Init(); MX_TIM4_Init();
MX_USART2_UART_Init(); MX_USART2_UART_Init();
MX_USART1_UART_Init(); MX_USART1_UART_Init();
/* USER CODE BEGIN 2 */ /* USER CODE BEGIN 2 */
HC_SR04_Init(); HC_SR04_Init();
BLUETOOTH_Init();
/* USER CODE BEGIN 2 */ /* USER CODE BEGIN 2 */
@ -112,14 +114,14 @@ int main(void) {
/* Infinite loop */ /* Infinite loop */
/* USER CODE BEGIN WHILE */ /* USER CODE BEGIN WHILE */
while (1) { while (1)
printf("test\n"); {
my_printf(HUART1, "test huart1 \r\n");
my_printf(HUART2, "test huart2\r\n");
if (sonor_state == 0) { // App_LineSeek();
sonar_mm();
}
HAL_Delay(300); // 延时300毫秒 // HAL_Delay(300); // 延时300毫秒
/* USER CODE END WHILE */ /* USER CODE END WHILE */
@ -132,7 +134,8 @@ int main(void) {
* @brief System Clock Configuration * @brief System Clock Configuration
* @retval None * @retval None
*/ */
void SystemClock_Config(void) { void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
@ -146,7 +149,8 @@ void SystemClock_Config(void) {
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler(); Error_Handler();
} }
@ -158,7 +162,8 @@ void SystemClock_Config(void) {
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) { if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
{
Error_Handler(); Error_Handler();
} }
} }
@ -171,11 +176,13 @@ void SystemClock_Config(void) {
* @brief This function is executed in case of error occurrence. * @brief This function is executed in case of error occurrence.
* @retval None * @retval None
*/ */
void Error_Handler(void) { void Error_Handler(void)
{
/* USER CODE BEGIN Error_Handler_Debug */ /* USER CODE BEGIN Error_Handler_Debug */
/* User can add his own implementation to report the HAL error return state */ /* User can add his own implementation to report the HAL error return state */
__disable_irq(); __disable_irq();
while (1) { while (1)
{
} }
/* USER CODE END Error_Handler_Debug */ /* USER CODE END Error_Handler_Debug */
} }
@ -188,7 +195,8 @@ void Error_Handler(void) {
* @param line: assert_param error line source number * @param line: assert_param error line source number
* @retval None * @retval None
*/ */
void assert_failed(uint8_t *file, uint32_t line) { void assert_failed(uint8_t *file, uint32_t line)
{
/* USER CODE BEGIN 6 */ /* USER CODE BEGIN 6 */
/* User can add his own implementation to report the file name and line number, /* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

View File

@ -1,69 +1,10 @@
/**
******************************************************************************
* @file syscalls.c
* @author Auto-generated by STM32CubeMX
* @brief Minimal System calls file
*
* For more information about which c-functions
* need which of these lowlevel functions
* please consult the Newlib libc-manual
******************************************************************************
* @attention
*
* Copyright (c) 2020-2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* Includes */ #include "syscalls.h"
#include <sys/stat.h>
#include <stdlib.h>
#include <errno.h>
#include <stdio.h>
#include <signal.h>
#include <time.h>
#include <sys/time.h>
#include <sys/times.h>
extern UART_HandleTypeDef huart1;
/* Variables */ // 条件编译,适配不同平台 (GNU, GCC)
extern int __io_putchar(int ch) __attribute__((weak)); #ifdef __GNUC__
extern int __io_getchar(void) __attribute__((weak));
char *__env[1] = { 0 };
char **environ = __env;
/* Functions */
void initialise_monitor_handles()
{
}
int _getpid(void)
{
return 1;
}
int _kill(int pid, int sig)
{
(void)pid;
(void)sig;
errno = EINVAL;
return -1;
}
void _exit (int status)
{
_kill(status, -1);
while (1) {} /* Make sure we hang here */
}
__attribute__((weak)) int _read(int file, char *ptr, int len) __attribute__((weak)) int _read(int file, char *ptr, int len)
{ {
(void)file; (void)file;
@ -88,89 +29,58 @@ __attribute__((weak)) int _write(int file, char *ptr, int len)
} }
return len; return len;
} }
#endif
int _close(int file) /**
* @brief C printf huart1
* @author Suroy
* @param ch
* @param f
* @return int
*
* @usage printf("USART1_Target:\r\n");
*/
PUTCHAR_PROTOTYPE
{ {
(void)file; HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, HAL_MAX_DELAY); // 阻塞式无限等待
return -1; return ch;
} }
/**
int _fstat(int file, struct stat *st) * @brief c库函数 getchar,scanf到 DEBUG_USARTx
* C scanf huart1
*
* @param f
* @return int
*
* @usage scanf("%c", &RecData);
*/
GETCHAR_PROTOTYPE
{ {
(void)file; uint8_t ch = 0;
st->st_mode = S_IFCHR; HAL_UART_Receive(&huart1, (uint8_t *)&ch, 1, HAL_MAX_DELAY);
return 0; return ch;
} }
int _isatty(int file) void delay_us(uint16_t us)
{ {
(void)file; uint32_t delay = (HAL_RCC_GetHCLKFreq() / 4000000 * us);
return 1; while (delay--);
} }
int _lseek(int file, int ptr, int dir) /**
* @brief printf
* @param huart, buf
* @return void
*
* @usage my_printf(HUART1, "USART1_Target:\r\n");
*/
void my_printf(UART_HandleTypeDef *huart, const char *buf, ...)
{ {
(void)file; char str[255] = {0};
(void)ptr; va_list v;
(void)dir; va_start(v, buf);
return 0; vsprintf(str, buf, v);
} HAL_UART_Transmit(huart, (const uint8_t *)str, strlen(str), 0xff);
va_end(v);
int _open(char *path, int flags, ...)
{
(void)path;
(void)flags;
/* Pretend like we always fail */
return -1;
}
int _wait(int *status)
{
(void)status;
errno = ECHILD;
return -1;
}
int _unlink(char *name)
{
(void)name;
errno = ENOENT;
return -1;
}
int _times(struct tms *buf)
{
(void)buf;
return -1;
}
int _stat(char *file, struct stat *st)
{
(void)file;
st->st_mode = S_IFCHR;
return 0;
}
int _link(char *old, char *new)
{
(void)old;
(void)new;
errno = EMLINK;
return -1;
}
int _fork(void)
{
errno = EAGAIN;
return -1;
}
int _execve(char *name, char **argv, char **env)
{
(void)name;
(void)argv;
(void)env;
errno = ENOMEM;
return -1;
} }

File diff suppressed because one or more lines are too long

View File

@ -344,7 +344,7 @@
</Group> </Group>
<Group> <Group>
<GroupName>Application/User/Core</GroupName> <GroupName>Core</GroupName>
<tvExp>1</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel> <cbSel>0</cbSel>
@ -445,6 +445,18 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<bShared>0</bShared> <bShared>0</bShared>
</File> </File>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>10</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>
</Group> </Group>
<Group> <Group>
@ -455,7 +467,7 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>10</FileNumber> <FileNumber>11</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -467,7 +479,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>11</FileNumber> <FileNumber>12</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -479,7 +491,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>12</FileNumber> <FileNumber>13</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -491,7 +503,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>13</FileNumber> <FileNumber>14</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -503,7 +515,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>14</FileNumber> <FileNumber>15</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -515,7 +527,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>15</FileNumber> <FileNumber>16</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -527,7 +539,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>16</FileNumber> <FileNumber>17</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -539,7 +551,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>17</FileNumber> <FileNumber>18</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -551,7 +563,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>18</FileNumber> <FileNumber>19</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -563,7 +575,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>19</FileNumber> <FileNumber>20</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -575,7 +587,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>20</FileNumber> <FileNumber>21</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -587,7 +599,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>21</FileNumber> <FileNumber>22</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -599,7 +611,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>22</FileNumber> <FileNumber>23</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -611,7 +623,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>23</FileNumber> <FileNumber>24</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -623,7 +635,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>24</FileNumber> <FileNumber>25</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -643,7 +655,7 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<File> <File>
<GroupNumber>4</GroupNumber> <GroupNumber>4</GroupNumber>
<FileNumber>25</FileNumber> <FileNumber>26</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -656,14 +668,14 @@
</Group> </Group>
<Group> <Group>
<GroupName>Application/User/Service</GroupName> <GroupName>User</GroupName>
<tvExp>1</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel> <cbSel>0</cbSel>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<File> <File>
<GroupNumber>5</GroupNumber> <GroupNumber>5</GroupNumber>
<FileNumber>26</FileNumber> <FileNumber>27</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -675,7 +687,7 @@
</File> </File>
<File> <File>
<GroupNumber>5</GroupNumber> <GroupNumber>5</GroupNumber>
<FileNumber>27</FileNumber> <FileNumber>28</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -687,7 +699,7 @@
</File> </File>
<File> <File>
<GroupNumber>5</GroupNumber> <GroupNumber>5</GroupNumber>
<FileNumber>28</FileNumber> <FileNumber>29</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -699,7 +711,7 @@
</File> </File>
<File> <File>
<GroupNumber>5</GroupNumber> <GroupNumber>5</GroupNumber>
<FileNumber>29</FileNumber> <FileNumber>30</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -711,7 +723,7 @@
</File> </File>
<File> <File>
<GroupNumber>5</GroupNumber> <GroupNumber>5</GroupNumber>
<FileNumber>30</FileNumber> <FileNumber>31</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -721,6 +733,38 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<bShared>0</bShared> <bShared>0</bShared>
</File> </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>
<Group> <Group>

View File

@ -339,7 +339,7 @@
<MiscControls></MiscControls> <MiscControls></MiscControls>
<Define>USE_HAL_DRIVER,STM32F103xB</Define> <Define>USE_HAL_DRIVER,STM32F103xB</Define>
<Undefine></Undefine> <Undefine></Undefine>
<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</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> </VariousControls>
</Cads> </Cads>
<Aads> <Aads>
@ -391,7 +391,7 @@
</Files> </Files>
</Group> </Group>
<Group> <Group>
<GroupName>Application/User/Core</GroupName> <GroupName>Core</GroupName>
<Files> <Files>
<File> <File>
<FileName>main.c</FileName> <FileName>main.c</FileName>
@ -484,6 +484,11 @@
<FileType>1</FileType> <FileType>1</FileType>
<FilePath>../Core/Src/stm32f1xx_hal_msp.c</FilePath> <FilePath>../Core/Src/stm32f1xx_hal_msp.c</FilePath>
</File> </File>
<File>
<FileName>syscalls.c</FileName>
<FileType>1</FileType>
<FilePath>..\Core\Src\syscalls.c</FilePath>
</File>
</Files> </Files>
</Group> </Group>
<Group> <Group>
@ -577,7 +582,7 @@
</Files> </Files>
</Group> </Group>
<Group> <Group>
<GroupName>Application/User/Service</GroupName> <GroupName>User</GroupName>
<Files> <Files>
<File> <File>
<FileName>bluetooth.c</FileName> <FileName>bluetooth.c</FileName>
@ -604,6 +609,21 @@
<FileType>1</FileType> <FileType>1</FileType>
<FilePath>..\User\Src\motor.c</FilePath> <FilePath>..\User\Src\motor.c</FilePath>
</File> </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> </Files>
</Group> </Group>
<Group> <Group>

View File

@ -39,6 +39,7 @@ C_SOURCES = \
Core/Src/main.c \ Core/Src/main.c \
Core/Src/gpio.c \ Core/Src/gpio.c \
Core/Src/i2c.c \ Core/Src/i2c.c \
Core/Src/syscalls.c \
Core/Src/tim.c \ Core/Src/tim.c \
Core/Src/dma.c \ Core/Src/dma.c \
Core/Src/usart.c \ Core/Src/usart.c \
@ -61,12 +62,13 @@ Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c \ Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c \
Core/Src/system_stm32f1xx.c \ Core/Src/system_stm32f1xx.c \
Core/Src/sysmem.c \ Core/Src/sysmem.c \
Core/Src/hcsr04.c \ User/Src/hcsr04.c \
Core/Src/motor.c \ User/Src/motor.c \
Core/Src/led.c \ User/Src/led.c \
Core/Src/syscalls.c \ User/Src/bluetooth.c \
Core/Src/bluetooth.c \ User/Src/control.c \
Core/Src/control.c User/Src/line_seek.c \
App/Src/app_line_seek.c
# ASM sources # ASM sources
ASM_SOURCES = \ ASM_SOURCES = \
@ -127,6 +129,8 @@ AS_INCLUDES =
# C includes # C includes
C_INCLUDES = \ C_INCLUDES = \
-ICore/Inc \ -ICore/Inc \
-IUser/Inc \
-IApp/Inc \
-IDrivers/STM32F1xx_HAL_Driver/Inc \ -IDrivers/STM32F1xx_HAL_Driver/Inc \
-IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy \ -IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy \
-IDrivers/CMSIS/Device/ST/STM32F1xx/Include \ -IDrivers/CMSIS/Device/ST/STM32F1xx/Include \

7
User/Inc/line_seek.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef __LINE_SEEK_H__
#define __LINE_SEEK_H__
// 获取巡线状态
void LineSeek_Get(int *p_iL1, int *p_iL2, int *p_iR1, int *p_iR2);
#endif

17
User/Src/line_seek.c Normal file
View File

@ -0,0 +1,17 @@
#include "line_seek.h"
#include "main.h"
/**
* @brief 线
* @param[in] int *p_iL1, int *p_iL2, int *p_iR1, int *p_iR2 线
* @retval void
*/
void LineSeek_Get(int *p_iL1, int *p_iL2, int *p_iR1, int *p_iR2)
{
*p_iL1 = HAL_GPIO_ReadPin(LineSeek_L1_GPIO_Port, LineSeek_L1_Pin);
*p_iL2 = HAL_GPIO_ReadPin(LineSeek_L2_GPIO_Port, LineSeek_L2_Pin);
*p_iR1 = HAL_GPIO_ReadPin(LineSeek_R1_GPIO_Port, LineSeek_R1_Pin);
*p_iR2 = HAL_GPIO_ReadPin(LineSeek_R2_GPIO_Port, LineSeek_R2_Pin);
}