问题遇到的现象和发生背景
unsigned int speed_count=0;//ռ�ձȼ����� 50��һ����
char front_left_speed_duty=SPEED_DUTY;
char front_right_speed_duty=SPEED_DUTY;
char behind_left_speed_duty=SPEED_DUTY;
char behind_right_speed_duty=SPEED_DUTY;
unsigned char tick_5ms = 0;//5ms����������Ϊ�������Ļ�������
unsigned char tick_1ms = 0;//1ms����������Ϊ����Ļ���������
unsigned char tick_200ms = 0;//ˢ����ʾ
char ctrl_comm = COMM_STOP;//����ָ��
char ctrl_comm_last = COMM_STOP;//��һ�ε�ָ��
unsigned char continue_time=0;
unsigned char bt_rec_flag=0;//�������Ʊ�־λ
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
void SearchRun(void);
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
/* USER CODE BEGIN PFP */
//循迹函数
void SearchRun(void)
{
if(SEARCH_M_IO == BLACK_AREA && SEARCH_L_IO == BLACK_AREA && SEARCH_R_IO == BLACK_AREA)
{
ctrl_comm = COMM_UP;
return;
}
}
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/**
* @brief The application entry point.
* @retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_TIM2_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
KEIL5明明定义了函数,函数里定义好的变量好也有代码提示符,编译时却没定义
问题相关代码,请勿粘贴截图
打算在main.c前定义循迹函数,但是编译时却提示我没定义函数里的变量
在main.c while(1)循环体里面打函数的变量却有代码提示符,这是怎么回事
运行结果及报错内容
../Core/Src/main.c(71): error: #20: identifier "GPIO_Pin_6" is undefined
../Core/Src/main.c(71): error: #20: identifier "GPIO_Pin_4" is undefined
我的解答思路和尝试过的方法
定义的变量
#define SEARCH_M_PIN GPIO_Pin_8
#define SEARCH_M_GPIO GPIOG
#define SEARCH_M_IO HAL_GPIO_ReadPin(SEARCH_M_GPIO, SEARCH_M_PIN)
#define SEARCH_R_PIN GPIO_Pin_6
#define SEARCH_R_GPIO GPIOG
#define SEARCH_R_IO HAL_GPIO_ReadPin(SEARCH_R_GPIO, SEARCH_R_PIN)
#define SEARCH_L_PIN GPIO_Pin_4
#define SEARCH_L_GPIO GPIOG
#define SEARCH_L_IO HAL_GPIO_ReadPin(SEARCH_L_GPIO, SEARCH_L_PIN)
#define BLACK_AREA 1
#define WHITE_AREA 0