mini版,我按照LED灯的格式编写了一个motor程序,因为是子程序,所以没有加stm32F10x.h头文件,但是程序一直报错,程序如下:
motor.c
#include "motor.h"
void Motor_L_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_4|GPIO_Pin_5;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOA,&GPIO_InitSTructure);
}
void Motor_R_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE);
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_11|GPIO_Pin_12;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_InitStructrue.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOC,&GPIO_InitStructure);
}
motor.h
#ifndef __MOTOR_H
#define __MOTOR_H
#define MOTOR_L_IN1_LOW (GPIO_ResetBits(GPIOA, GPIO_Pin_4))
#define MOTOR_L_IN1_HIGH (GPIO_SetBits(GPIOA, GPIO_Pin_4))
#define MOTOR_L_IN2_LOW (GPIO_ResetBits(GPIOA, GPIO_Pin_5))
#define MOTOR_L_IN2_HIGH (GPIO_SetBits(GPIOA, GPIO_Pin_5))
#define MOTOR_R_IN1_LOW (GPIO_ResetBits(GPIOC, GPIO_Pin_11))
#define MOTOR_R_IN1_HIGH (GPIO_SetBits(GPIOC, GPIO_Pin_11))
#define MOTOR_R_IN2_LOW (GPIO_ResetBits(GPIOC, GPIO_Pin_12))
#define MOTOR_R_IN2_HIGH (GPIO_SetBits(GPIOC, GPIO_Pin_12))
void Motor_L_Init(void);
void Motor_R_Init(void);
#endif
报错代码如下:
..HARDWAREMOTORmotor.c(9): error: #20: identifier "GPIO_InitTypeDef" is undefined
..HARDWAREMOTORmotor.c(10): warning: #223-D: function "RCC_APB2PeriphClockCmd" declared implicitly
..HARDWAREMOTORmotor.c(10): error: #20: identifier "RCC_APB2Periph_GPIOA" is undefined
..HARDWAREMOTORmotor.c(10): error: #20: identifier "ENABLE" is undefined
..HARDWAREMOTORmotor.c(12): error: #20: identifier "GPIO_Pin_4" is undefined
..HARDWAREMOTORmotor.c(12): error: #20: identifier "GPIO_Pin_5" is undefined
..HARDWAREMOTORmotor.c(13): error: #20: identifier "GPIO_Mode_Out_PP" is undefined
..HARDWAREMOTORmotor.c(14): error: #20: identifier "GPIO_Speed_50MHz" is undefined
..HARDWAREMOTORmotor.c(15): warning: #223-D: function "GPIO_Init" declared implicitly
..HARDWAREMOTORmotor.c(15): error: #20: identifier "GPIOA" is undefined
..HARDWAREMOTORmotor.c(15): error: #20: identifier "GPIO_InitSTructure" is undefined
..HARDWAREMOTORmotor.c(19): error: #20: identifier "GPIO_InitTypeDef" is undefined
..HARDWAREMOTORmotor.c(20): warning: #223-D: function "RCC_APB2PeriphClockCmd" declared implicitly
..HARDWAREMOTORmotor.c(20): error: #20: identifier "RCC_APB2Periph_GPIOC" is undefined
..HARDWAREMOTORmotor.c(20): error: #20: identifier "ENABLE" is undefined
..HARDWAREMOTORmotor.c(22): error: #20: identifier "GPIO_Pin_11" is undefined
..HARDWAREMOTORmotor.c(22): error: #20: identifier "GPIO_Pin_12" is undefined
..HARDWAREMOTORmotor.c(23): error: #20: identifier "GPIO_Mode_Out_PP" is undefined
..HARDWAREMOTORmotor.c(24): error: #20: identifier "GPIO_InitStructrue" is undefined
..HARDWAREMOTORmotor.c(24): error: #20: identifier "GPIO_Speed_50MHz" is undefined
..HARDWAREMOTORmotor.c(25): warning: #223-D: function "GPIO_Init" declared implicitly
..HARDWAREMOTORmotor.c(25): error: #20: identifier "GPIOC" is undefined
还请帮忙分析一下原因,感谢!!!
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>