3 Star 0 Fork 0

思源 / stm32.nrf24l01

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
bsp_dac.c 815 Bytes
一键复制 编辑 原始数据 按行查看 历史
博远 提交于 2018-08-25 22:11 . first init
#include <stm32f10x.h>
#include <bsp_dac.h>
#include <bsp_uart.h>
void DAC2_Init(void)
{
RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE); //enable the clock
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
DAC_InitTypeDef dac;
GPIO_InitTypeDef gpio;
gpio.GPIO_Mode = GPIO_Mode_AIN;
gpio.GPIO_Pin = GPIO_Pin_5;
GPIO_Init(GPIOA, &gpio);
dac.DAC_Trigger = DAC_Trigger_Software;
dac.DAC_OutputBuffer = DAC_OutputBuffer_Disable;
dac.DAC_WaveGeneration = DAC_WaveGeneration_None;
DAC_Init(DAC_Channel_2, &dac);
DAC_Cmd(DAC_Channel_2, ENABLE);
}
void DAC2_Output(float vol)
{
char str[10];
uint16_t v_data = 4096/3.3 * vol;
sprintf(str, "%d\n", v_data);
debug(str);
DAC_SetChannel2Data(DAC_Align_12b_R, v_data);
DAC_SoftwareTriggerCmd(DAC_Channel_2, ENABLE);
}
C
1
https://gitee.com/yuanbocode/stm32.nrf24l01.git
git@gitee.com:yuanbocode/stm32.nrf24l01.git
yuanbocode
stm32.nrf24l01
stm32.nrf24l01
master

搜索帮助