代码拉取完成,页面将自动刷新
ADC,Analog-to-Digital Converter的缩写,指模/数转换器或者模拟/数字转换器。是将连续变量的模拟信号转换为离散的数字信号的器件。真实世界的模拟信号,例如温度、压力、声音或者图像等,需要转换成更容易储存、处理和发射的数字形式。模/数转换器可以实现这个功能,典型的模拟数字转换器将模拟信号转换为表示一定比例电压值的数字信号。
adc控制器驱动提供了adc的控制访问方法,
驱动相关的源文件包括
.
├── fadc_g.c
├── fadc_hw.c
├── fadc_hw.h
├── fadc_intr.c
├── fadc_sinit.c
├── fadc.c
└── fadc.h
以下部分将指导您完成 fadc 驱动的软件配置:
typedef struct
{
FAdcConfig config;/* adc config */
FAdcConvertConfig convert_config; /* adc convert config */
FAdcThresholdConfig threshold_config; /* adc channel threshold config */
u32 is_ready;/* adc init ready flag */
u16 value[FADC_CHANNEL_NUM]; /* adc value */
boolean convert_complete[FADC_CHANNEL_NUM]; /*!< Specifies whether the conversion is complete> */
FAdcIntrEventHandler event_handler[FADC_INTR_EVENT_NUM]; /* event handler for interrupt */
void *event_param[FADC_INTR_EVENT_NUM]; /* parameters of event handler */
}FAdcCtrl;
typedef struct
{
u32 instance_id;/* adc id */
uintptr base_addr;/* adc control register base address*/
u32 irq_num;/* adc interrupt number */
u32 irq_prority;/* adc interrupt priority*/
const char *instance_name;/* instance name */
} FAdcConfig;
typedef struct
{
u32 convert_interval; /* convert interval time */
u32 clk_div; /* clock divider */
FAdcConvertMode convert_mode;/*!< convert mode */
FAdcChannelMode channel_mode;/*!< channel mode */
} FAdcConvertConfig;
typedef struct
{
u16 high_threshold[FADC_CHANNEL_NUM]; /*!< Configures the ADC analog high threshold value.
This parameter must be a 10-bit value. */
u16 low_threshold[FADC_CHANNEL_NUM]; /*!< Configures the ADC analog low threshold value.
This parameter must be a 10-bit value. */
} FAdcThresholdConfig;
typedef enum
{
FADC_CONTINUOUS_CONVERT = 0,/* continuous conversion*/
FADC_SINGLE_CONVERT = 1, /* single conversion*/
FADC_CONVERT_MODE_NUM
} FAdcCovertMode;
typedef enum
{
FADC_MULTI_CHANNEL = 0, /* multi channel conversion*/
FADC_FIXED_CHANNEL = 1, /* fixed channel conversion*/
FADC_CHANNEL_MODE_NUM
} FAdcChannelMode;
typedef enum
{
FADC_INTR_EVENT_COVFIN = 0, /**< Handler type for convert finish interrupt */
FADC_INTR_EVENT_DLIMIT = 1, /**< Handler type for low limit interrupt*/
FADC_INTR_EVENT_ULIMIT = 2, /**< Handler type for high limit interrupt*/
FADC_INTR_EVENT_ERROR = 3, /**< Handler type for error interrupt*/
FADC_INTR_EVENT_NUM
} FAdcIntrEventType;
const FAdcConfig *FAdcLookupConfig(u32 instance_id);
Note:
Input:
Return:
FError FAdcCfgInitialize(FAdcCtrl *pctrl, const FAdcConfig *input_config_p);
Note:
Input:
Return:
FError FAdcVariableConfig(FAdcCtrl *pctrl, u8 channel, FAdcConvertConfig *convert_config,
FAdcThresholdConfig *threshold_config);
Note:
Input:
Return:
FError FAdcChannelThresholdSet(FAdcCtrl *pctrl, u8 channel, FAdcThresholdConfig *threshold_config);
Note:
Input:
Return:
FError FAdcConvertStart(FAdcCtrl *pctrl);
Note:
Input:
Return:
FError FAdcInterruptEnable(FAdcCtrl *pctrl, u8 channel, FAdcIntrEventType event_type);
Note:
Input:
Return:
FError FAdcReadConvertResult(FAdcCtrl *pctrl, u8 channel, u16 *val);
Note:
Input:
Return:
void FAdcRegisterInterruptHandler(FAdcCtrl *instance_p, FAdcIntrEventType event_type,
FAdcIntrEventHandler handler, void *param);
Note:
Input:
Return:
void FAdcIntrHandler(s32 vector, void *args);
Note:
Input:
Return:
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。