u16 dac_raw_ch1, dac_raw_ch2;
void dac_task_init(void)
{
// DAC_InitTypeDef x;
// x.DAC_Trigger = DAC_Trigger_None;
// x.DAC_WaveGeneration = DAC_WaveGeneration_None;
// x.DAC_OutputBuffer = DAC_OutputBuffer_Enable;
// DAC_Init(DAC_Channel_1, &x);
// DAC_Init(DAC_Channel_2, &x);
// DAC_Cmd(DAC_Channel_1, ENABLE);
// DAC_Cmd(DAC_Channel_2, ENABLE);
DAC->CR = 0x0F030F03;
dac_update();
}
void dac_update(void)
{
u32 dat;
dat = dac_raw_ch2 << 16;
dat |= dac_raw_ch1;
DAC->DHR12RD = dat;
}
注释掉的是ST库版本,实际初始化只需要1行 |