stm32f103 ADC 代码 rt-thread

本文详细介绍了如何在stm32f103微控制器上使用rt-thread实时操作系统进行ADC(模拟数字转换器)的编程,包括配置ADC通道、初始化设置、读取ADC转换结果等关键步骤,为嵌入式系统开发提供了实用的参考资料。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#ifndef __ADC_H__
#define __ADC_H__

#include <rtthread.h>

void rt_hw_adc_init(void);

#endif
#include <rtthread.h>
#include <stm32f10x.h>

void rt_hw_adc_init(void)
{
	ADC_InitTypeDef  ADC_InitStructure;
	GPIO_InitTypeDef GPIO_InitStructure;
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1,ENABLE);
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE);
	GPIO_InitStructure.GPIO_Pin  =GPIO_Pin_0;
	GPIO_InitStructure.GPIO_Mode =GPIO_Mode_AIN;
	GPIO_Init(GPIOC,&GPIO_InitStructure);
	
	ADC_InitStructure.ADC_Mode              = ADC_Mode_Independent;  //独立模式
	ADC_InitStructure.ADC_ScanConvMode      =DISABLE;      //连续多通道模式
	ADC_InitStructure.ADC_ContinuousConvMode =ENABLE;      //连续转换
	ADC_InitStructure.ADC_ExternalTrigConv  = ADC_ExternalTrigConv_None; //转换不受外界决定
	ADC_InitStructure.ADC_DataAlign         =AD
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值