keil4软件导入库_如何在Keil uVision4的软件下添加.h文件

回复【楼主位】tianyaxtujxlg

-----------------------------------------------------------------------

我的H文件:

/* Define to prevent recursive inclusion -------------------------------------*/

#ifndef __DV14432_H

#define __DV14432_H

/* Includes ------------------------------------------------------------------*/

#include "stm32f10x_lib.h"

void JPIO_Init(void);

void delay(int d);

void LCD_WriteLByte(u8 Byte);//写PC口的低8位,高8位不变

void wr_lcd(u8 data_comm,u8 content);         //写入LCD

void LcmInit( void );

void LcmClearTXT( void );

void LcmClearBMP( void ) ;

void Put_Str_chinese(u8 row,u8 col,u8 *puts);

void Put_One_Chinese(u8 row,u8 col,u16 c);

void Put_More_Chinese(u8 row,u8 col,u16 *puts);

#endif

我的C文件:

/*显示模块程序*/

#include "dv14432.h"

u8 AC_TABLE[16]={

0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,      //第一行汉字位置

0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,      //第二行汉字位置

};

#define  comm  0

#define  data  1

#define RW_0            GPIO_WriteBit(GPIOB, GPIO_Pin_14, Bit_RESET)    //R/W=0,LCD读允许

#define RW_1            GPIO_WriteBit(GPIOB, GPIO_Pin_14, Bit_SET)      //R/W=1,LCD写允许

#define RS_0            GPIO_WriteBit(GPIOB, GPIO_Pin_13, Bit_RESET)    //RS=0,向LCD写入指令

#define RS_1            GPIO_WriteBit(GPIOB, GPIO_Pin_13, Bit_SET)      //RS=1,向LCD输入数据

#define E_0             GPIO_WriteBit(GPIOB, GPIO_Pin_15, Bit_RESET)    //并联模式下使能

#define E_1             GPIO_WriteBit(GPIOB, GPIO_Pin_15, Bit_SET)      //并联模式下使能

#define PSB             GPIO_WriteBit(GPIOB, GPIO_Pin_12, Bit_SET)

void JPIO_Init(void)

{

GPIO_InitTypeDef GPIO_InitStructure;

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |

RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD |

RCC_APB2Periph_GPIOE | RCC_APB2Periph_GPIOF |

RCC_APB2Periph_GPIOG , ENABLE);

RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;                        //用作监控程序执行到哪一步来的显示灯

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

GPIO_Init(GPIOF, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;                        //用于PSB RS RW E

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

GPIO_Init(GPIOB, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;                    //用作DB0~DB7

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

GPIO_Init(GPIOC, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_8;          //PA0 PA8设置为输入

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;

GPIO_Init(GPIOA, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;                                  //PC13设置为输入

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;

GPIO_Init(GPIOC, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;                                          //PD3设置为输入

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;

GPIO_Init(GPIOD, &GPIO_InitStructure);

}

void delay(int d)

{

int count = 0;

for ( ;d;--d)

for (count = 0;count<720;count++);

}

void LCD_WriteLByte(u8 Byte)//写PC口的低8位,高8位不变

{

u16 Data_PCL,a;

Data_PCL = GPIO_ReadOutputData(GPIOC);

Data_PCL = Data_PCL&0xFF00;  //保留

a=(u16)Byte&0x00FF;

Data_PCL = Data_PCL | a;     //写入

GPIO_Write(GPIOC,Data_PCL );

}

void wr_lcd(u8 data_comm,u8 content)         //写入LCD

{

// CheckBusy();

PSB;

if(data_comm)

{

delay(1);

RS_1;

RW_0;

LCD_WriteLByte(content);

E_1;

E_0;

}

else

{

delay(1);

RS_0;

RW_0;

LCD_WriteLByte(content);

E_1;

E_0;

}

delay(2);

}

void LcmInit( void )

{

E_0;

wr_lcd(comm,0x0030);      //8BitMCU,基本指令集合

wr_lcd(comm,0x0003);      //AC 归0,不改变DDRAM内容

wr_lcd(comm,0x000C);      //显示 ON,游标OFF,游标位反白 OFF

wr_lcd(comm,0x0001);      //清屏,AC归 0

wr_lcd(comm,0x0006);      //写入时,游标右移动

}

//文本区清RAM函数

void LcmClearTXT( void )

{

unsigned char i;

wr_lcd(comm,0x0030);      //8BitMCU,基本指令集合

wr_lcd(comm,0x0080);      //AC 归起始位

for(i=0;i<64;i++)

wr_lcd(data,0x0020);

}

//图形区和文本区显示在两个不同的RAM区

//图形区清RAM函数

void LcmClearBMP( void )

{

unsigned char i,j;

wr_lcd(comm,0x0034);      //8Bit扩充指令集,即使是 36H也要写两次

wr_lcd(comm,0x0036);      //绘图ON,基本指令集里面 36H 不能开绘图

for(i=0;i<32;i++)            //12864 实际为 256x32

{

wr_lcd(comm,0x0080|i);    //行位置

wr_lcd(comm,0x0080);      //列位置

for(j=0;j<32;j++)           //256/8=32 byte

wr_lcd(data,0x0000);

}

}

/*用于显示直接的字符串*/

void Put_Str_chinese(u8 row,u8 col,u8 *puts)

{

wr_lcd(comm,0x0030);      //8BitMCU,基本指令集合

wr_lcd(comm,AC_TABLE[8*row+col]);      //起始位置

while(*puts != '\0')      //判断字符串是否显示完毕

{

if(col==8)         //判断换行

{                  //若不判断,则自动从第一行到第三行

col=0;

row++;

}

if(row==2) row=0;      //一屏显示完,回到屏左上角

wr_lcd(comm,AC_TABLE[8*row+col]);

wr_lcd(data,*puts);      //一个汉字要写两次

puts++;

wr_lcd(data,*puts);

puts++;

col++;

}

}

/*用于显示用编码表示的单个汉字*/

void Put_One_Chinese(u8 row,u8 col,u16 c)

{

u8 chinese[2];

chinese[0]=        (u8)((c & 0xFF00)>>8);

chinese[1]=        (u8)(c & 0x00FF);

wr_lcd(comm,0x0030);      //8BitMCU,基本指令集合

wr_lcd(comm,AC_TABLE[8*row+col]);      //起始位置

wr_lcd(comm,AC_TABLE[8*row+col]);

wr_lcd(data,chinese[0]);      //一个字符只要要写一次

wr_lcd(data,chinese[1]);

}

/*用于显示用编码表示的汉字*/

void Put_More_Chinese(u8 row,u8 col,u16 *puts)

{

u16 morechinese[1];

morechinese[0] = *puts ;

while(morechinese[0] != 0X5C30)      //判断字符串是否显示完毕

{

if(col==8)         //判断换行

{                  //若不判断,则自动从第一行到第三行

col=0;

row++;

}

if(row==2) row=0;      //一屏显示完,回到屏左上角

Put_One_Chinese(row,col,morechinese[0]);

puts++;

col++;

morechinese[0] = *puts ;

}

}

现在我要把这个文件添加到  【10】I2C主机:EEPROM存储器24C02 这个工程中以用于把存储的信息进行液晶显示,但是提示出错,错误代码是:

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(23): error:  #256: invalid redeclaration of type name "s32" (declared at line 205 of "..\..\..\Libraries\CMSIS\Core\CM3\stm32f10x.h")

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h:   typedef signed long  s32;

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h:                        ^

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(27): error:  #256: invalid redeclaration of type name "sc32" (declared at line 209 of "..\..\..\Libraries\CMSIS\Core\CM3\stm32f10x.h")

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h:   typedef signed long  const sc32;  // Read Only

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h:                              ^

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(31): error:  #256: invalid redeclaration of type name "vs32" (declared at line 213 of "..\..\..\Libraries\CMSIS\Core\CM3\stm32f10x.h")

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h:   typedef volatile signed long  vs32;

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h:                                 ^

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(35): error:  #256: invalid redeclaration of type name "vsc32" (declared at line 217 of "..\..\..\Libraries\CMSIS\Core\CM3\stm32f10x.h")

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h:   typedef volatile signed long  const vsc32;  // Read Only

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h:                                       ^

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(39): error:  #256: invalid redeclaration of type name "u32" (declared at line 221 of "..\..\..\Libraries\CMSIS\Core\CM3\stm32f10x.h")

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h:   typedef unsigned long  u32;

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h:                          ^

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(43): error:  #256: invalid redeclaration of type name "uc32" (declared at line 225 of "..\..\..\Libraries\CMSIS\Core\CM3\stm32f10x.h")

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h:   typedef unsigned long  const uc32;  // Read Only

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h:                                ^

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(47): error:  #256: invalid redeclaration of type name "vu32" (declared at line 229 of "..\..\..\Libraries\CMSIS\Core\CM3\stm32f10x.h")

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h:   typedef volatile unsigned long  vu32;

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h:                                   ^

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(51): error:  #256: invalid redeclaration of type name "vuc32" (declared at line 233 of "..\..\..\Libraries\CMSIS\Core\CM3\stm32f10x.h")

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h:   typedef volatile unsigned long  const vuc32;  // Read Only

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h:                                         ^

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(55): error:  #101: "FALSE" has already been declared in the current scope

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h:   typedef enum {FALSE = 0, TRUE = !FALSE} bool;

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h:                 ^

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(55): error:  #101: "TRUE" has already been declared in the current scope

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h:   typedef enum {FALSE = 0, TRUE = !FALSE} bool;

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h:                            ^

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(55): error:  #256: invalid redeclaration of type name "bool" (declared at line 237 of "..\..\..\Libraries\CMSIS\Core\CM3\stm32f10x.h")

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h:   typedef enum {FALSE = 0, TRUE = !FALSE} bool;

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h:                                           ^

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(57): error:  #101: "RESET" has already been declared in the current scope

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h:   typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus;

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h:                 ^

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(57): error:  #101: "SET" has already been declared in the current scope

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h:   typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus;

D:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h:                            ^

请各位大侠帮忙分析下问题出在哪里,谢谢了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值