Chinaunix首页 | 论坛 | 博客
  • 博客访问: 15531151
  • 博文数量: 2005
  • 博客积分: 11986
  • 博客等级: 上将
  • 技术积分: 22535
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-17 13:56
文章分类

全部博文(2005)

文章存档

2014年(2)

2013年(2)

2012年(16)

2011年(66)

2010年(368)

2009年(743)

2008年(491)

2007年(317)

分类:

2008-08-07 22:44:23

ads1.2下c++测试源码

//main.cpp

#ifdef __cplusplus
extern "C"
{
#endif
int printf(const char *fmt,...);
int isdigit (char c);
#ifdef __cplusplus
}
#endif

class leith_cobject
{

    public:
 static    volatile int timer_count;
    public:
             leith_cobject(int argc);
        void ontimer(int timer_id);
 static int irq_handler(int irq);
         int get_timer_count(void);
         int set_timer_count(int count);
         int get_ltimer_count(void);
         int set_ltimer_count(int count);
     private:
         int ltimer_count;
 __inline void printf_name(void);
};
volatile int leith_cobject::timer_count = 666666;

leith_cobject::leith_cobject(int argc)
{
    int i;
    for(i = 0;i < argc;i++)
    {
        printf("%d, digit = %s\n", i, isdigit(i) ? "true":"false");
    }
    ltimer_count = argc;
    printf_name();
}

int leith_cobject::irq_handler(int irq)
{
    printf("irq = %d\n", irq);
    return 0;
}

void leith_cobject::ontimer(int timer_id)
{
    printf("timer_id = %d\n", timer_id);
}

int leith_cobject::get_timer_count(void)
{
    return timer_count;
}

int leith_cobject::set_timer_count(int count)
{
    return timer_count = count;
}

int leith_cobject::get_ltimer_count(void)
{
    return ltimer_count;
}

int leith_cobject::set_ltimer_count(int count)
{
    return ltimer_count = count;
}

void leith_cobject::printf_name(void)
{
    //int (*func)(void);
    //func = this->get_timer_count;
    printf("0x%x\n", this);
}

int main(void)
{
    leith_cobject leith(60);
    leith_cobject leith1(20);
    leith.ontimer(80);
    leith.ontimer(180);
    leith.ontimer(280);
    leith.ontimer(380);
    leith.irq_handler(8);
    leith_cobject::irq_handler(9);
    leith_cobject::irq_handler(10);
    printf("leith.timer = %d\n", leith.get_timer_count());
    printf("leith.ltimer = %d\n", leith.get_ltimer_count());
    leith.set_timer_count(5);
    leith.set_ltimer_count(6);
    printf("leith.timer = %d\n", leith.get_timer_count());
    printf("leith.ltimer = %d\n", leith.get_ltimer_count());
    printf("leith1.timer = %d\n", leith1.get_timer_count());
    printf("leith1.ltimer = %d\n", leith1.get_ltimer_count());
    leith1.set_timer_count(7);
    leith1.set_ltimer_count(8);
    printf("leith1.timer = %d\n", leith1.get_timer_count());
    printf("leith1.ltimer = %d\n", leith1.get_ltimer_count());
    
}

阅读(1823) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~