Chinaunix首页 | 论坛 | 博客
  • 博客访问: 9085911
  • 博文数量: 1732
  • 博客积分: 12961
  • 博客等级: 上将
  • 技术积分: 19830
  • 用 户 组: 普通用户
  • 注册时间: 2009-01-09 11:25
个人简介

偷得浮生半桶水(半日闲), 好记性不如抄下来(烂笔头). 信息爆炸的时代, 学习是一项持续的工作.

文章分类

全部博文(1732)

文章存档

2023年(26)

2022年(112)

2021年(217)

2020年(157)

2019年(192)

2018年(81)

2017年(78)

2016年(70)

2015年(52)

2014年(40)

2013年(51)

2012年(85)

2011年(45)

2010年(231)

2009年(287)

分类: LINUX

2010-08-23 11:14:23

static inline
int xn_voltage_probe(struct xn_tool *tool)
{
    int adc_value = 0;
    int i = 0;

    printf("\nVoltage Probe:\n");

    gpio_set_pin(S3C_GPN5, S3C_GPN5_INP);
    gpio_pullup(S3C_GPN5, 0x2);
    
    
    if(gpio_get_value(S3C_GPN5) == 0)
        printf("EXTERNAL_POWER.......................................[YES]\n");
    else
        printf("EXTERNAL_POWER.......................................[NO]\n");

while(i++ < 10)

{    adc_value = get_adc_i(1);

    

    printf("BATTERY_VOLTAGE......................................[%u mv]\n",(unsigned int)(adc_value * VOLTAGE_FACTOR));

}

    wait_user_ack(tool);
    return 0;
}




static inline
int get_adc_i(int channel)
{
    volatile S3C2410_ADC * reg_adc = S3C2410_GetBase_ADC();

    reg_adc->ADCCON     = (1<<14) | (49<< 6) | (channel<<3);
    reg_adc->ADCDLY        = 40000;
    reg_adc->ADCCON     |= (1 << 0);

    while(reg_adc->ADCCON & 0x1);
    while (!(reg_adc->ADCCON & (1 << 15)));
    
    return (0x3ff & reg_adc->ADCDAT0);
}


阅读(2428) | 评论(0) | 转发(1) |
0

上一篇:UBOOT 网口测试

下一篇:UBOOT 串口测试

给主人留下些什么吧!~~