OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 4763|回复: 5

为什么添加了库文件 还会报错 说未定义那

[复制链接]

28

主题

74

帖子

0

精华

初级会员

Rank: 2

积分
158
金钱
158
注册时间
2016-1-18
在线时间
21 小时
发表于 2016-7-4 10:10:52 | 显示全部楼层 |阅读模式
1金钱
void I2C_Configuration(void)
{
        // Local variables
       
        I2C_InitTypeDef I2C_InitStructure;
        GPIO_InitTypeDef GPIO_InitStructure;                                                                                // GPIO Initialization structure
       
        RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1,ENABLE);
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
       
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;                                                                // Set mode
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;                                                        // Select pin
        GPIO_Init(GPIOB, &GPIO_InitStructure);
       
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;                                                        // Set mode
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;                                                                                //
        GPIO_Init(GPIOB, &GPIO_InitStructure);

       
        // Reset I2C busy bit
        I2C_SoftwareResetCmd(I2C1,ENABLE);

        I2C_SoftwareResetCmd(I2C1,DISABLE);
       
    I2C_DeInit(I2C1);

        I2C_Cmd(I2C1, ENABLE);

        I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;   
        I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
        I2C_InitStructure.I2C_OwnAddress1 = 0x30;
        I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
        I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
        I2C_InitStructure.I2C_ClockSpeed = I2C_100KHZ;

        I2C_Init(I2C1, &I2C_InitStructure);
       
        I2C_AcknowledgeConfig(I2C1, ENABLE);
       
        // Configure related GPIO
       
        }

最佳答案

查看完整内容[请看2#楼]

谢谢 大神 找到了 这句话没添加对造成的STM32F10X_HD,USE_STDPERIPH_DRIVER
正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

28

主题

74

帖子

0

精华

初级会员

Rank: 2

积分
158
金钱
158
注册时间
2016-1-18
在线时间
21 小时
 楼主| 发表于 2016-7-4 10:10:53 | 显示全部楼层
谢谢  大神  找到了   这句话没添加对造成的STM32F10X_HD,USE_STDPERIPH_DRIVER
回复

使用道具 举报

30

主题

1170

帖子

0

精华

金牌会员

Rank: 6Rank: 6

积分
1993
金钱
1993
注册时间
2016-2-16
在线时间
527 小时
发表于 2016-7-4 10:14:19 | 显示全部楼层
发这个做卵,你应该发报错那里是怎么说的,话说,你添加库文件后,在需要用的那里,包含了他的.H文件或者本身的C文件了吗
回复

使用道具 举报

28

主题

74

帖子

0

精华

初级会员

Rank: 2

积分
158
金钱
158
注册时间
2016-1-18
在线时间
21 小时
 楼主| 发表于 2016-7-4 10:16:46 | 显示全部楼层
包含了呀
回复

使用道具 举报

28

主题

74

帖子

0

精华

初级会员

Rank: 2

积分
158
金钱
158
注册时间
2016-1-18
在线时间
21 小时
 楼主| 发表于 2016-7-4 10:19:05 | 显示全部楼层
点H开头这样写的
#ifndef __HWCONFIG_H
#define __HWCONFIG_H
#include "sys.h"
点C这样写的
#include "hwconfig.h"
#include "System.h"
//#include "MIDI.h"
回复

使用道具 举报

28

主题

74

帖子

0

精华

初级会员

Rank: 2

积分
158
金钱
158
注册时间
2016-1-18
在线时间
21 小时
 楼主| 发表于 2016-7-4 10:23:09 | 显示全部楼层
        KEY_Init();                             //按键初始化            
src\hwconfig.c(45): error:  #20: identifier "I2C_InitTypeDef" is undefined
        I2C_InitTypeDef I2C_InitStructure;
src\hwconfig.c(46): error:  #20: identifier "GPIO_InitTypeDef" is undefined
        GPIO_InitTypeDef GPIO_InitStructure;                                                                            // GPIO Initialization structure
src\hwconfig.c(48): warning:  #223-D: function "RCC_APB1PeriphClockCmd" declared implicitly
        RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1,ENABLE);
src\hwconfig.c(48): error:  #20: identifier "RCC_APB1Periph_I2C1" is undefined
        RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1,ENABLE);
src\hwconfig.c(49): error:  #20: identifier "GPIO_Speed_50MHz" is undefined
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
src\hwconfig.c(51): error:  #20: identifier "GPIO_Mode_AF_OD" is undefined
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;                                                         // Set mode
src\hwconfig.c(52): error:  #20: identifier "GPIO_Pin_6" is undefined
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;                                                  // Select pin
src\hwconfig.c(52): error:  #20: identifier "GPIO_Pin_7" is undefined
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;                                                  // Select pin
src\hwconfig.c(53): warning:  #223-D: function "GPIO_Init" declared implicitly
        GPIO_Init(GPIOB, &GPIO_InitStructure);
src\hwconfig.c(55): error:  #20: identifier "GPIO_Mode_Out_PP" is undefined
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;                                                        // Set mode
src\hwconfig.c(56): error:  #20: identifier "GPIO_Pin_8" is undefined
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;                                                                               //
src\hwconfig.c(61): warning:  #223-D: function "I2C_SoftwareResetCmd" declared implicitly
        I2C_SoftwareResetCmd(I2C1,ENABLE);
src\hwconfig.c(65): warning:  #223-D: function "I2C_DeInit" declared implicitly
      I2C_DeInit(I2C1);
src\hwconfig.c(67): warning:  #223-D: function "I2C_Cmd" declared implicitly
        I2C_Cmd(I2C1, ENABLE);
src\hwconfig.c(69): error:  #20: identifier "I2C_Mode_I2C" is undefined
        I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;   
src\hwconfig.c(70): error:  #20: identifier "I2C_DutyCycle_2" is undefined
        I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
src\hwconfig.c(72): error:  #20: identifier "I2C_Ack_Enable" is undefined
        I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
src\hwconfig.c(73): error:  #20: identifier "I2C_AcknowledgedAddress_7bit" is undefined
        I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
src\hwconfig.c(76): warning:  #223-D: function "I2C_Init" declared implicitly
        I2C_Init(I2C1, &I2C_InitStructure);
src\hwconfig.c(78): warning:  #223-D: function "I2C_AcknowledgeConfig" declared implicitly
        I2C_AcknowledgeConfig(I2C1, ENABLE);
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-6-11 11:34

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表