📄 adc.c
字号:
/*
****************************************************************************
* 宁波中科集成电路设计中心 版权所有 Copyright 2005
* http:\\www.nbicc.com
*文件名: adc.c
*程序员: 夏鹏 xpsonny@nbicc.com
*主要内容:adc驱动相关
*
*如有问题或BUG,请登录www.wsn.net.cn 提问或用邮件和作者联系
****************************************************************************
*/
#include "adc.h"
#include "main.h"
static uint8_t ADCHPLDataReady(uint16_t data);
static uint8_t ADCHPLSamplePort(uint8_t port);
void __attribute((signal)) __vector_21(void);
/*************************************************************************
*功能描述:adc初始化
*参数说明:无
*返回值:
**************************************************************************/
uint8_t adc_init(void)
{
{
* (volatile unsigned char *)(0x06 + 0x20) = (1 << 3) | (6 << 0);
* (volatile unsigned char *)(0x07 + 0x20) = 0;
}
return SUCCESS;
}
/*************************************************************************
*功能描述:adc中断响应回调函数
*参数说明:ADC采集到的数据
*返回值:
**************************************************************************/
static uint8_t ADCHPLDataReady(uint16_t data)
{
RadiocontrolRSSIADCDataReady(data);
return SUCCESS;
}
/*************************************************************************
*功能描述:adc启动接口函数
*参数说明:ADC通道号0-8
*返回值:
**************************************************************************/
uint8_t ADCStartGet(uint8_t port)
{
ADCHPLSamplePort(port);
return 1;
}
/*************************************************************************
*功能描述:adc中断响应函数
*参数说明:无
*返回值:
**************************************************************************/
void __attribute((signal)) __vector_21(void)
{
uint16_t data = * (volatile unsigned int *)(unsigned int )& * (volatile unsigned char *)(0x04 + 0x20);
data &= 0x3ff;
* (volatile unsigned char *)(0x06 + 0x20) |= 1 << 4;
* (volatile unsigned char *)(0x06 + 0x20) &= ~(1 << 7);
ADCHPLDataReady(data);
}
/*************************************************************************
*功能描述:adc调用配置函数
*参数说明:ADC通道号0-8
*返回值:
**************************************************************************/
static uint8_t ADCHPLSamplePort(uint8_t port)
{
{
* (volatile unsigned char *)(0x07 + 0x20) = port;
}
* (volatile unsigned char *)(0x06 + 0x20) |= 1 << 7;
* (volatile unsigned char *)(0x06 + 0x20) |= 1 << 6;
return SUCCESS;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -