SmartOS/Device/DAC.h

42 lines
655 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef __DAC_H__
#define __DAC_H__
/*
STM32F1
两个DAC转换器一个输出通道对应一个转换器
8位/12位单调输出
12位模式 左对齐 又对齐
同步更新功能
DAC同步更新 分别更新
每个通道都有DMA功能
外部触发参考
以 Vref+ 为参考
IO 设置为模拟输入AIN
PA4 PA5
*/
class DAConverter
{
public:
byte Align;
AnalogInPort* Port = nullptr;
byte Channel;
DAConverter(Pin pin);
bool Open();
bool Close();
bool Write(ushort value);
private:
Pin _Pin;
void OnInit();
bool OnOpen();
bool OnClose();
bool OnWrite(ushort value);
};
#endif