大神 帮忙解决下c函数里代码的重用问题
求助 本人在使用一个软件编程时(51单片机) 想把程序模块化处理 结果总是各种重复定义 未定义 以及打开.c文件失败之类的错误请有经验的大神帮忙 我该怎么编写底层函数 .h和.c 文件里如何编写 错误才最少呢
下面是我的函数:
运行结果总是各种未定义 求大神帮帮忙 主函数我还没弄
//Timer.c 文件函数
#include <reg52.h>
#include "MACROANDCONST1.h"
#define LED P1
#define LED_ON() LED=0x00;
#define LED_OFF() LED=0xff;
#define LED_PWM_LIMIT_MAX 99
#define LED_PWM_LIMIT_MIN 0
static uint8 s_u8TimCounter=0;
static uint8 s_u8LedDirection=0;
static int8 s_u8LedPWNCounter=0;
void Timer0Init(void)
{
TMOD&=0xf0;
TMOD|=0x01;
TH0=0xff;
TL0=0x47;
TR0=1;
ET0=1;
}
void Time0Isr(void) interrupt 1
{
static int8 s_s8PWMCounter=0;
TH0=0xf0;
TL0=0x47;
if(s_u8TimeCounter++>=100)
{
s_u8TimeCounter=0;
if((s_s8LedPWMCounter<=LED_PWM_LIMIT_MAX)&&(0==s_u8LedDirection))
{
s_s8LedPWMCounter++;
if(s_s8LedPWMCounter>LED_PWM_LIMIT_MAX)
{
s_u8LedDirection=1;
s_s8LedPWMCounter=LED_PWM_LIMIT_MAX;
}
}
if((s_s8LedPWMCounter>=LED_PWM_LIMIT_MIN)&&(1==s_u8LedDirection))
{
s_s8LedPWMCounter--;
if(s_s8LedPWMCounter<LED_PWM_LIMIT_MIN)
{
s_u8LedDirection=0;
s_s8LedPWMCounter=LED_PWM_LILMIT_MIN;
}
}
s_s8PWMCounter=s_s8LedPWMCounter;
}
if(s_s8PWMCounter>0)
{
LED_ON();
s_s8PWMCounter--;
}
else
{
LED_OFF();
}
}
//MacroAndConst.h文件函数:
#ifndef _MACRO_AND_CONST_H_
#define _MACRO_AND_CONST_H_
typedef unsigned int uint16;
typedef unsigned int UINT;
typedef unsigned int uint;
typedef unsigned int UINT16;
typedef unsigned int word;
typedef unsigned int WORD;
typedef int int16;
typedef int INT16;
typedef unsigned long uint32;
typedef unsigned long UINT32;
typedef unsigned long DWORD;
typedef unsigned long dword;
typedef long int32;
typedef long INT32;
typedef signed char int8;
typedef signed char INT8;
typedef unsigned char byte;
typedef unsigned char BYTE;
typedef unsigned char uchar;
typedef unsigned char UINT8;
typedef unsigned char uint8;
typedef unsigned char BOOL;
#endif
[ 本帖最后由 雷江 于 2013-4-8 00:04 编辑 ]