www.pudn.com > vcprj.rar > main.c
/* 交流电机测试程序 main.c MCU:at90s2313 时钟:4MHz 芯艺 2004-09-25 */ #include#include #define uchar unsigned char #define uint unsigned int #define SET_RED_LED PORTD|=_BV(5) //PD5接红色发光管 #define CLR_RED_LED PORTD&=~_BV(5) #define SET_GRN_LED PORTD|=_BV(4) //PD4接绿色发光管 #define CLR_GRN_LED PORTD&=~_BV(4) class CControl { public: CControl(); public: uchar m_bCounter; void DelayMs(uint ms); void RunMotor(uchar direction); }; CControl::CControl() { m_bCounter=0; } void CControl::RunMotor(uchar direction) { if(direction==1) { SET_GRN_LED; CLR_RED_LED; } else if(direction==2) { CLR_GRN_LED; SET_RED_LED; } else { CLR_GRN_LED; CLR_RED_LED; } for(uchar i=0;i