打印

Keil编译通不过,提示D12WriteByte()定义错,找不出来原因

[复制链接]
1507|9
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
hceng|  楼主 | 2013-11-29 13:15 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 hceng 于 2013-11-29 14:10 编辑

UsbCored.c文件
#include <AT89x52.H>
#include "UsbCored.h"
#include "MyType.h"
#include "PDIUSBD12.h"
#include "UART.h"

/********************************************************************
函数功能:延迟Xms
入口参数:X,X是延迟时间
返    回:
备    注:
********************************************************************/
void DelayXms (uint16 x)
{
uint16 i;
uchar8 j;
for(i=0;i<x;i++)
        for(j=0;j<227;j++);
}
////////////////////////End of function//////////////////////////////

/********************************************************************
函数功能:usb断开链接函数
入口参数:
返    回:
备    注:
********************************************************************/
void UsbDisconnect(void)
{

#ifdef DEBUG0
Prints("usb链接断开。\r\n");
#endif
D12WriteCommand(D12_SET_MODE);
D12writeByte(0x16);
D12WriteByte(0x47);
DelayXms(1000);
}
////////////////////////End of function//////////////////////////////

/********************************************************************
函数功能:usb链接上函数
入口参数:无
返    回:无
备    注:无
********************************************************************/
void UsbConnect(void)
{
#ifdef DEBUG0
Prints("usb链接上。\r\n");
#endif
D12WriteCommand(D12_SET_MODE);
D12WriteByte(0x06);
D12WriteByte(0x47);
}
////////////////////////End of function//////////////////////////////

/********************************************************************
函数功能:总线挂起中断服务程序
入口参数:
返    回:
备    注:
********************************************************************/
void UsbBusSuspend(void)
{
#ifdef DEBUG0
Prints("总线挂起");
#endif
}
////////////////////////End of function//////////////////////////////

/********************************************************************
函数功能:总线复位中断服务程序
入口参数:
返    回:
备    注:
********************************************************************/
void UsbBusReset(void)
{
#ifdef DEBUG0
Prints("总线复位");
#endif
}
////////////////////////End of function//////////////////////////////

/********************************************************************
函数功能:端点0输出中断服务程序
入口参数:
返    回:
备    注:
********************************************************************/
void UsbEp0Out(void)
{
#ifdef DEBUG0
Prints("端点0输出(PC向端点0写入数据)");
#endif
}
////////////////////////End of function//////////////////////////////

/********************************************************************
函数功能:端点0输入断服务程序
入口参数:
返    回:
备    注:
********************************************************************/
void UsbEp0In(void)
{
#ifdef DEBUG0
Prints("端点0输入(PC接收端点0数据)");
#endif
}
////////////////////////End of function//////////////////////////////

/********************************************************************
函数功能:端点1输出中断服务程序
入口参数:
返    回:
备    注:
********************************************************************/
void UsbEp1Out(void)
{
#ifdef DEBUG0
Prints("端点1输出(PC向端点1写入数据)");
#endif
}
////////////////////////End of function//////////////////////////////

/********************************************************************
函数功能:端点1输入中断服务程序
入口参数:
返    回:
备    注:
********************************************************************/
void UsbEp1In(void)
{
#ifdef DEBUG0
Prints("端点1输入(PC接收端点1数据)");
#endif
}
////////////////////////End of function//////////////////////////////

/********************************************************************
函数功能:端点2输出中断服务程序
入口参数:
返    回:
备    注:
********************************************************************/
void UsbEp2Out(void)
{
#ifdef DEBUG0
Prints("端点2输出(PC向端点2写入数据)");
#endif
}
////////////////////////End of function//////////////////////////////

/********************************************************************
函数功能:端点2输入中断服务程序
入口参数:
返    回:
备    注:
********************************************************************/
void UsbEp2In(void)
{
#ifdef DEBUG0
Prints("端点2输入(PC接收端点1数据)");
#endif
}
////////////////////////End of function//////////////////////////////
PDIUSBD12.h文件
/********************************************************************

硬件说明:C51和PDIUSBD12连接定义

********************************************************************/

#ifndef __PDIUSBD12_H__
#define __PDIUSBD12_H__

#include <at89x52.h>
#include "MyType.h"
//PDIUSBD12芯片连接引脚
#define D12_DATA                  P0
#define D12_A0                    P3_5
#define D12_WR                    P3_6
#define D12_RD                    P3_7
#define D12_INT                   P3_2
#define D12_COMMAND_ADD           1        //命令地址和数据地址
#define D12_DATA_ADD              0
#define D12SetCommandAddr() D12_A0=D12_COMMAND_ADD//选择命令或数据地址
#define D12SetDataAddr()    D12_A0=D12_DATA_ADD
#define D12SetWr() D12_WR=0//WR控制
#define D12ClrWr() D12_WR=1
#define D12SetRd() D12_RD=0//RD控制
#define D12ClrRd() D12_RD=1
#define D12GetIntPing()  D12_INT//获取中断状态
#define D12GetData() D12_DATA//读写数据
#define D12SendData(Value) D12_DATA=(Value)
#define D12SetPortRead() D12_DATA=0xFF//将数据口设置为输入状态,51单片机端口写1就是为输入状态
#define D12SetPortWrite()//将数据口设置为输出状态,由于51单片机是准双向IO口,所以不用切换,为空宏
#define Read_ID                  0xFD//D12的读ID命令

void D12WriteCommand(uchar8);//给D12写入命令字符//函数声明
uchar8 D12ReadByte(void);//从D12读入一个字节的数据
void D12WriteByte(uchar8);//给D12写入一个数据
uint16 D12ReadID(void);//从D12读16位ID(用ID号判断D12芯片是否正常工作)
#endif
PDIUSBD12.c文件

#include <AT89x52.H>
#include "MyType.h"
#include "PDIUSBD12.H"


/********************************************************************
函数功能:D12写命令。
入口参数:Command:一字节命令。
返    回:无。
备    注:无。
********************************************************************/
void D12WriteCommand(uchar8 Command)
{
D12SetCommandAddr();  //设置为命令地址
D12SetWr(); //WR置低
D12SetPortWrite(); //将数据口设置为输出状态(注意这里为空宏,移植时可能有用)
D12SendData(Command);  //输出命令到数据口上
D12ClrWr(); //WR置高
D12SetPortRead(); //将数据口设置为输入状态,以备后面输入使用
}
////////////////////////End of function//////////////////////////////

/********************************************************************
函数功能:读一字节D12数据到MCU。
入口参数:无。
返    回:读回的一字节。
备    注:无。
********************************************************************/
uchar8 D12ReadByte(void)
{
uchar8 temp;
D12SetDataAddr(); //设置为数据地址
D12SetRd(); //RD置低
temp=D12GetData(); //读回数据
D12ClrRd(); //RD置高
return temp; //返回读到数据
}
////////////////////////End of function//////////////////////////////

/********************************************************************
函数功能:读D12的ID。
入口参数:无。
返    回:D12的ID。
备    注:无。
********************************************************************/
uint16 D12ReadID(void)
{
uint16 id;
D12WriteCommand(Read_ID); //写读ID命令
id=D12ReadByte(); //读回ID号低字节
id|=((uint16)D12ReadByte())<<8; //读回ID号高字节
return id;
}
////////////////////////End of function//////////////////////////////

/********************************************************************
函数功能:从MCU写1字节数据到D12
入口参数:value 1字节数据
返    回:
备    注:
********************************************************************/
void D12WriteByte(uchar8 temp)
{
D12SetDataAddr();
D12SetWr();
D12SetPortWrite();
D12SendData(temp);
D12ClrWr();
D12SetPortRead();
}
////////////////////////End of function//////////////////////////////

Keil给出的提示
Build target 'Target 1'
assembling STARTUP.A51...
compiling Key.c...
compiling PDIUSBD12.c...
compiling UART.c...
compiling System.c...
compiling UsbCored.c...
USBCORED.C(33): warning C206: 'D12writeByte': missing function-prototype
USBCORED.C(33): error C267: 'D12writeByte': requires ANSI-style prototype
Target not created

相关帖子

沙发
hceng|  楼主 | 2013-11-29 13:18 | 只看该作者
本帖最后由 hceng 于 2013-11-29 13:27 编辑

在UsbCored.c文件里添加extern void D12WriteByet(uchar8 temp)也没用

使用特权

评论回复
板凳
么么沫沫| | 2013-11-29 13:29 | 只看该作者
在UsbCored.h文件里添加extern void D12WriteByet(uchar8)试试

使用特权

评论回复
地板
么么沫沫| | 2013-11-29 13:31 | 只看该作者
在PDIUSBD12.h文件里添加extern void D12WriteByet(uchar8);然后UsbCored.c文件里#include PDIUSBD12.h

使用特权

评论回复
5
hceng|  楼主 | 2013-11-29 13:50 | 只看该作者
没有用,我发现Project windows里面的UsbCored.c下面的头文件都没有加载进来

使用特权

评论回复
6
hceng|  楼主 | 2013-11-29 13:56 | 只看该作者

adg.jpg (35.33 KB )

adg.jpg

使用特权

评论回复
7
hceng|  楼主 | 2013-11-29 13:59 | 只看该作者
郁闷啊

使用特权

评论回复
8
黄小俊| | 2013-11-29 16:03 | 只看该作者

使用特权

评论回复
9
hceng|  楼主 | 2013-11-29 16:15 | 只看该作者
问题找到了,郁闷,一个大小写的问题

使用特权

评论回复
10
dirtwillfly| | 2013-11-29 21:48 | 只看该作者
hceng 发表于 2013-11-29 16:15
问题找到了,郁闷,一个大小写的问题

问题解决了就好,谢谢分享

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

17

主题

48

帖子

0

粉丝