01. DAC简介
) t1 H- ]: ^# l& F R/ ~" SSTM32F4的DAC模块(数字/模拟转换模块)是12位数字输入,电压输出型的DAC。DAC可以配置为 8 位或 12 位模式,也可以与 DMA 控制器配合使用。DAC 工作在 12 位模式时,数据可以设置成左对齐或右对齐。DAC 模块有 2 个输出通道,每个通道都有单独的转换器。在双 DAC 模式下,2 个通道可以独立地进行转换,也可以同时进行转换并同步地更新 2 个通道的输出。DAC 可以通过引脚输入参考电压 Vref+(通 ADC 共用)以获得更精确的转换结果。
+ v4 V4 N! I7 y0 e) [STM32F4 的 DAC 模块主要特点有:5 t; Y2 k* k4 q) _' {
① 2 个 DAC 转换器:每个转换器对应 1 个输出通道, ]; U- `. H/ J) Z4 r
② 8 位或者 12 位单调输出7 N! l4 @) A. ?" T, h/ F7 ?3 {/ M& g
③ 12 位模式下数据左对齐或者右对齐
6 e* y' i' T0 L& J④ 同步更新功能& U; \' {5 X9 T
⑤ 噪声波形生成 X9 o, ~# e# b) r; q$ h. u
⑥ 三角波形生成0 R5 \( S& k/ }: p( {( m
⑦ 双 DAC 通道同时或者分别转换
3 e. R2 U! f: N9 w⑧ 每个通道都有 DMA 功能' b6 Z _3 }4 @3 Z' ^9 P3 _) [
5 ~2 [3 h2 G- k% v( z( o3 I' t7 Z02. 相关类型" X' s2 O* j R B% r- c. G3 `
DAC Init structure
2 {, J! n- k$ H7 R% i9 I5 ^- ~' N" D
- /** 6 y9 K. W$ G7 w# N8 n
- * @brief DAC Init structure definition, d+ @0 T% Z3 m/ y1 |
- */2 T1 C' V J! a: }# O+ j* Z
! G- N8 M7 e8 C' k7 A0 j$ U1 v8 }- typedef struct2 @8 E3 L m* I5 V: [
- {
. ]+ |5 A) ^5 t) Y - uint32_t DAC_Trigger; /*!< Specifies the external trigger for the selected DAC channel.( n0 U* \( e; J2 y$ R
- This parameter can be a value of @ref DAC_trigger_selection */2 ]- _5 ~6 q5 B
- 1 h' ~7 }3 }! W- }- S/ ?4 O3 Y. n
- uint32_t DAC_WaveGeneration; /*!< Specifies whether DAC channel noise waves or triangle waves' @5 W' J8 o& | V
- are generated, or whether no wave is generated.& Z5 `7 U: R6 I
- This parameter can be a value of @ref DAC_wave_generation */9 }' i. s" D0 P3 Y1 z
( }) U4 D; c; e* b# s; d- uint32_t DAC_LFSRUnmask_TriangleAmplitude; /*!< Specifies the LFSR mask for noise wave generation or- n6 ]7 e9 B6 P5 O, x4 K- C
- the maximum amplitude triangle generation for the DAC channel. 6 O( U5 [, E: O6 I; J
- This parameter can be a value of @ref DAC_lfsrunmask_triangleamplitude */0 J0 O' e- l1 W. d$ V
- 4 c! z; M# T1 a9 ]
- uint32_t DAC_OutputBuffer; /*!< Specifies whether the DAC channel output buffer is enabled or disabled.% c! W/ P, D; ^* q
- This parameter can be a value of @ref DAC_output_buffer */1 K2 `$ k: [6 W# X9 }5 G5 ^ @
- }DAC_InitTypeDef; ?" h& L! G5 G4 ?* m$ C0 c
复制代码 6 n0 |3 x J) D7 |, d
DAC_trigger_selection/ M x+ i( `& e# F9 i& x/ q) k
% y* T7 U& t9 @1 U" C- /** @defgroup DAC_trigger_selection
* B8 r, q9 M+ l! r2 H; L, U9 e - * @{
5 Q }% a& M4 ` N4 d - */
, A8 D# A! j' ^1 L
9 D+ O1 g$ X: \0 p2 g+ q- #define DAC_Trigger_None ((uint32_t)0x00000000) /*!< Conversion is automatic once the DAC1_DHRxxxx register
: M5 }* r$ j; [: D, V8 p( X8 Q - has been loaded, and not by external trigger */
# T+ o7 ?( s4 A8 }1 l) M1 [ - #define DAC_Trigger_T2_TRGO ((uint32_t)0x00000024) /*!< TIM2 TRGO selected as external conversion trigger for DAC channel */# u# ?/ B; M8 q! K
- #define DAC_Trigger_T4_TRGO ((uint32_t)0x0000002C) /*!< TIM4 TRGO selected as external conversion trigger for DAC channel */
5 o& ~) k x" J! M - #define DAC_Trigger_T5_TRGO ((uint32_t)0x0000001C) /*!< TIM5 TRGO selected as external conversion trigger for DAC channel */5 q/ d/ H+ H% D J! |
- #define DAC_Trigger_T6_TRGO ((uint32_t)0x00000004) /*!< TIM6 TRGO selected as external conversion trigger for DAC channel */( v: e3 |7 q/ ~- W& ]
- #define DAC_Trigger_T7_TRGO ((uint32_t)0x00000014) /*!< TIM7 TRGO selected as external conversion trigger for DAC channel */% \ ?: x. K$ g% @" @
- #define DAC_Trigger_T8_TRGO ((uint32_t)0x0000000C) /*!< TIM8 TRGO selected as external conversion trigger for DAC channel */
. z7 P* n, h+ A( e+ c7 F2 f - 9 {; L, j6 Q+ S( Z
- #define DAC_Trigger_Ext_IT9 ((uint32_t)0x00000034) /*!< EXTI Line9 event selected as external conversion trigger for DAC channel */
) H5 Y9 h7 z; Y+ @$ @0 y! s+ H - #define DAC_Trigger_Software ((uint32_t)0x0000003C) /*!< Conversion started by software trigger for DAC channel */
0 p- ~8 s& o1 h" g( |: O - + R3 i. G2 P2 ~* `; T
- #define IS_DAC_TRIGGER(TRIGGER) (((TRIGGER) == DAC_Trigger_None) || \5 E$ z# ~ w/ |2 H$ ~/ _
- ((TRIGGER) == DAC_Trigger_T6_TRGO) || \
. L- f+ W- i# {) } - ((TRIGGER) == DAC_Trigger_T8_TRGO) || \9 r2 c% ]: L- q& n) B
- ((TRIGGER) == DAC_Trigger_T7_TRGO) || \3 Y) }8 B! l. u4 X! A
- ((TRIGGER) == DAC_Trigger_T5_TRGO) || \7 p8 b# z7 n( j6 w
- ((TRIGGER) == DAC_Trigger_T2_TRGO) || \
0 u5 S- H+ ?6 l - ((TRIGGER) == DAC_Trigger_T4_TRGO) || \0 w4 {, m+ I- t6 G
- ((TRIGGER) == DAC_Trigger_Ext_IT9) || \
" q5 L, r, K* T& X: Y! I' d0 m - ((TRIGGER) == DAC_Trigger_Software))/ R, _( b0 v1 i, M
复制代码 9 x% G4 K. r- B* t) i
DAC_wave_generation
) i g9 i/ K9 a9 r8 w y
9 r0 q4 Z M# y& d- /** @defgroup DAC_wave_generation
7 U0 S/ m& ]5 N& k8 W, L3 p. n: L - * @{. R: [/ `7 p5 _
- */
( c. C9 M# L6 ~$ O& }2 n0 @) _8 l* q
1 }. t3 m' n, b* _1 i- #define DAC_WaveGeneration_None ((uint32_t)0x00000000)
. w- R- h& v" F, A# j% _ - #define DAC_WaveGeneration_Noise ((uint32_t)0x00000040)6 V! D M- w8 J- a( Z c
- #define DAC_WaveGeneration_Triangle ((uint32_t)0x00000080)# f3 W/ J0 E! e. y2 X3 u3 y. G
- #define IS_DAC_GENERATE_WAVE(WAVE) (((WAVE) == DAC_WaveGeneration_None) || \
1 \3 J% N. s6 t - ((WAVE) == DAC_WaveGeneration_Noise) || \2 |! S9 ^1 Q$ y5 K M; H
- ((WAVE) == DAC_WaveGeneration_Triangle))
复制代码
& q6 M1 y1 b. c M0 sDAC_lfsrunmask_triangleamplitude
' y" N! Q" V, p0 t, k M; [" p5 X2 Y& z- _5 f: e* P
- /** @defgroup DAC_lfsrunmask_triangleamplitude
* g! n+ E+ j5 X* v* v% g - * @{
& U9 X0 K! p/ E* z# t5 u# g - */
0 i4 G" c4 E* U9 @# S# s
4 I) Z/ `, |8 C5 w9 Q# @- #define DAC_LFSRUnmask_Bit0 ((uint32_t)0x00000000) /*!< Unmask DAC channel LFSR bit0 for noise wave generation */1 a' K% J6 m. g4 ]2 K1 l# H
- #define DAC_LFSRUnmask_Bits1_0 ((uint32_t)0x00000100) /*!< Unmask DAC channel LFSR bit[1:0] for noise wave generation */$ t8 d& I _0 E. f2 I) {
- #define DAC_LFSRUnmask_Bits2_0 ((uint32_t)0x00000200) /*!< Unmask DAC channel LFSR bit[2:0] for noise wave generation */4 }4 d- [- H+ y/ h4 ~2 T
- #define DAC_LFSRUnmask_Bits3_0 ((uint32_t)0x00000300) /*!< Unmask DAC channel LFSR bit[3:0] for noise wave generation */; L/ Q& r' a% g2 n+ |+ @
- #define DAC_LFSRUnmask_Bits4_0 ((uint32_t)0x00000400) /*!< Unmask DAC channel LFSR bit[4:0] for noise wave generation */
. P; c, i9 K3 O0 P! l' G4 Z7 v - #define DAC_LFSRUnmask_Bits5_0 ((uint32_t)0x00000500) /*!< Unmask DAC channel LFSR bit[5:0] for noise wave generation */
0 U# Q- _: z! N" M - #define DAC_LFSRUnmask_Bits6_0 ((uint32_t)0x00000600) /*!< Unmask DAC channel LFSR bit[6:0] for noise wave generation */* w1 }, i/ e& x ?1 x
- #define DAC_LFSRUnmask_Bits7_0 ((uint32_t)0x00000700) /*!< Unmask DAC channel LFSR bit[7:0] for noise wave generation */( ]4 T% ~9 C8 e
- #define DAC_LFSRUnmask_Bits8_0 ((uint32_t)0x00000800) /*!< Unmask DAC channel LFSR bit[8:0] for noise wave generation */2 i4 U8 t# J/ v3 q
- #define DAC_LFSRUnmask_Bits9_0 ((uint32_t)0x00000900) /*!< Unmask DAC channel LFSR bit[9:0] for noise wave generation */
( t( B' s* r+ M% w/ c, H - #define DAC_LFSRUnmask_Bits10_0 ((uint32_t)0x00000A00) /*!< Unmask DAC channel LFSR bit[10:0] for noise wave generation */
) t F$ `% { ]: ` - #define DAC_LFSRUnmask_Bits11_0 ((uint32_t)0x00000B00) /*!< Unmask DAC channel LFSR bit[11:0] for noise wave generation */
; {% P0 |3 T5 X! J9 C6 ]2 J+ K - #define DAC_TriangleAmplitude_1 ((uint32_t)0x00000000) /*!< Select max triangle amplitude of 1 */- U3 [& Z! `! s1 {# `
- #define DAC_TriangleAmplitude_3 ((uint32_t)0x00000100) /*!< Select max triangle amplitude of 3 */) ^) T# n; z% K- u
- #define DAC_TriangleAmplitude_7 ((uint32_t)0x00000200) /*!< Select max triangle amplitude of 7 */
( ]2 t' j2 c/ t) e; o- l8 d - #define DAC_TriangleAmplitude_15 ((uint32_t)0x00000300) /*!< Select max triangle amplitude of 15 */3 m; A. s* X) U A8 o6 L) _
- #define DAC_TriangleAmplitude_31 ((uint32_t)0x00000400) /*!< Select max triangle amplitude of 31 */4 X p& g w+ m
- #define DAC_TriangleAmplitude_63 ((uint32_t)0x00000500) /*!< Select max triangle amplitude of 63 */" m: V5 e# r" ~# R
- #define DAC_TriangleAmplitude_127 ((uint32_t)0x00000600) /*!< Select max triangle amplitude of 127 */
' x" D' U* T% z" p9 N - #define DAC_TriangleAmplitude_255 ((uint32_t)0x00000700) /*!< Select max triangle amplitude of 255 */
/ e7 d; G& z! P; O" x - #define DAC_TriangleAmplitude_511 ((uint32_t)0x00000800) /*!< Select max triangle amplitude of 511 */. K: u- ^- a/ @2 G& m% D
- #define DAC_TriangleAmplitude_1023 ((uint32_t)0x00000900) /*!< Select max triangle amplitude of 1023 *// I: E$ u( a7 B3 T* ~# A5 r! y0 G
- #define DAC_TriangleAmplitude_2047 ((uint32_t)0x00000A00) /*!< Select max triangle amplitude of 2047 */
( D0 \; ]1 S" j' v - #define DAC_TriangleAmplitude_4095 ((uint32_t)0x00000B00) /*!< Select max triangle amplitude of 4095 */
/ ^5 _% Q7 P: e: V' i2 q - # v( P; I( P0 J% K
- #define IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(VALUE) (((VALUE) == DAC_LFSRUnmask_Bit0) || \. |* e% q. t* w8 L$ b
- ((VALUE) == DAC_LFSRUnmask_Bits1_0) || \
0 o: G9 X8 Y3 V0 ^7 \# {1 j! H+ t - ((VALUE) == DAC_LFSRUnmask_Bits2_0) || \
1 g& `* @) B3 y) S' [ - ((VALUE) == DAC_LFSRUnmask_Bits3_0) || \7 }! R) T+ b+ k6 s% ~! Z2 y
- ((VALUE) == DAC_LFSRUnmask_Bits4_0) || \! `8 @0 w3 P5 u. r4 S& o
- ((VALUE) == DAC_LFSRUnmask_Bits5_0) || \
; I/ O& C' O( g: m% K - ((VALUE) == DAC_LFSRUnmask_Bits6_0) || \" e/ j' d) P- t: J
- ((VALUE) == DAC_LFSRUnmask_Bits7_0) || \
; g, B4 v6 g' y" i! c3 ? - ((VALUE) == DAC_LFSRUnmask_Bits8_0) || \
4 W7 G: B: N* `& u7 Q - ((VALUE) == DAC_LFSRUnmask_Bits9_0) || \
. y0 V' r! m- Y, p1 V! R - ((VALUE) == DAC_LFSRUnmask_Bits10_0) || \
$ P6 \ n/ {' o; G - ((VALUE) == DAC_LFSRUnmask_Bits11_0) || \
8 w8 a6 y( W+ n N/ e3 \+ z! N - ((VALUE) == DAC_TriangleAmplitude_1) || \
0 D; J2 O6 e8 w - ((VALUE) == DAC_TriangleAmplitude_3) || \
2 x0 x8 h6 J' f6 _0 y! A - ((VALUE) == DAC_TriangleAmplitude_7) || \
3 C9 B& E/ x h5 L - ((VALUE) == DAC_TriangleAmplitude_15) || \
! p9 H5 D' {& S! B- F - ((VALUE) == DAC_TriangleAmplitude_31) || \3 a; [% o& w0 P$ i( T7 A& t
- ((VALUE) == DAC_TriangleAmplitude_63) || \
9 K3 ?6 n* N4 y/ U - ((VALUE) == DAC_TriangleAmplitude_127) || \- t( Z& x5 \# e T5 o* ^7 X
- ((VALUE) == DAC_TriangleAmplitude_255) || \! s4 R3 c% b1 g' L X7 @
- ((VALUE) == DAC_TriangleAmplitude_511) || \2 }. A" e2 a* \0 N/ q' N+ _, M
- ((VALUE) == DAC_TriangleAmplitude_1023) || \
W2 ~5 r6 d( O3 ?) r7 N% w- n' E - ((VALUE) == DAC_TriangleAmplitude_2047) || \
, I$ i" N& X! c4 E& o: M) \; g* S - ((VALUE) == DAC_TriangleAmplitude_4095))) ^5 U3 g( ]: z7 |" l9 m1 R
复制代码
3 Q) d J, Z* F/ ~- @DAC_output_buffer
1 t7 R7 s1 m" { x3 A
# r* Z( w: @ u4 z, c- /** @defgroup DAC_output_buffer ! Z: A5 u! p D$ J. C
- * @{3 W0 C4 L6 Q7 C: ]. a' q
- */
( e( u+ B G( C* T" B( N Q - + s3 j8 `3 G! C/ H5 f% F) c
- #define DAC_OutputBuffer_Enable ((uint32_t)0x00000000)
* e1 e/ r+ ^) E/ C6 x8 |' m# \ - #define DAC_OutputBuffer_Disable ((uint32_t)0x00000002)6 N( d( u% u8 w: Y) y, U
- #define IS_DAC_OUTPUT_BUFFER_STATE(STATE) (((STATE) == DAC_OutputBuffer_Enable) || \, X$ Z/ f( {* q3 y$ E+ H
- ((STATE) == DAC_OutputBuffer_Disable))
复制代码
# b% t0 I8 |0 K* i7 |' ODAC_Channel_selection! Q5 t5 h- a/ F
& H( K& n n! D9 I. a) |% E$ v- /** @defgroup DAC_Channel_selection # C" X7 Y" _. {
- * @{: b3 x* m" O! ~4 H% w) l
- */
/ Y& S# C! {( ~8 ]% e) _
2 u6 d. b" T6 t! r- b- #define DAC_Channel_1 ((uint32_t)0x00000000)
: S! T) M9 l2 C - #define DAC_Channel_2 ((uint32_t)0x00000010)
+ p$ q8 Z( d0 h$ e7 o - #define IS_DAC_CHANNEL(CHANNEL) (((CHANNEL) == DAC_Channel_1) || \, s0 \$ z! Q$ q9 `- o
- ((CHANNEL) == DAC_Channel_2))
复制代码
+ S) G: v3 k9 v3 ]& Q9 bDAC_data_alignement, I! T" ^0 n1 G% `- q
" v: l5 i# t$ ^" S- /** @defgroup DAC_data_alignement
% c0 { c% C9 V6 u3 k, N - * @{
9 o6 t: O% F; c4 i5 Q - */0 p# \) b% m! [% S* k. p8 s
3 w8 t; v# h0 _$ B- #define DAC_Align_12b_R ((uint32_t)0x00000000)
$ p) C" F4 `* e4 ` - #define DAC_Align_12b_L ((uint32_t)0x00000004). H2 a, p- e: d5 \3 o$ I
- #define DAC_Align_8b_R ((uint32_t)0x00000008)
, l* T* m* I* L/ m+ Q- e; e9 ~4 U - #define IS_DAC_ALIGN(ALIGN) (((ALIGN) == DAC_Align_12b_R) || \( R+ a: S. D: d) _* |
- ((ALIGN) == DAC_Align_12b_L) || \
% J9 X6 P' K# V* j3 }/ \+ o8 ^ - ((ALIGN) == DAC_Align_8b_R))
复制代码 * B' l/ T2 ]* C) z; a
DAC_wave_generation: g; f2 h; t6 A. q
! S0 q6 x1 p5 Z, k+ M
- /** @defgroup DAC_wave_generation
" }! h [! S" ?" G: c6 s - * @{
+ C$ z1 r2 Z: v. x, U5 O - */# [: U. c9 D2 |8 ?3 o
- 4 {6 Q+ M; I, u1 N7 @: r# z
- #define DAC_Wave_Noise ((uint32_t)0x00000040)% T6 g, Q H6 g8 i
- #define DAC_Wave_Triangle ((uint32_t)0x00000080)
1 u( G; ]. A7 J C. y' x - #define IS_DAC_WAVE(WAVE) (((WAVE) == DAC_Wave_Noise) || \
7 s6 m1 G* L" ?, W - ((WAVE) == DAC_Wave_Triangle))
复制代码 + _: A3 f u m/ _* z5 a
其它
, T/ _7 p9 M% k# O( Z+ g) ~; `& x; O
- /** @defgroup DAC_data
4 D7 \) M+ v) |& x8 N - * @{" F9 Y( x2 e, B' Y
- */
9 c$ t( \1 m6 b" O8 m! O; T - % C) y! | Z/ |
- #define IS_DAC_DATA(DATA) ((DATA) <= 0xFFF0) / v: o+ B$ ~/ R
- /**
. R) N: Y8 a/ G( a J - * @}
8 [- ~/ o7 G' m - */$ P# q) [. p- c9 Q% r
. D. X3 I" |& E! D0 d- /** @defgroup DAC_interrupts_definition $ ~7 n- b W" X6 r
- * @{
; x' R$ d2 v* Q0 l Q - */
% M1 E' t1 S+ R( R0 z - #define DAC_IT_DMAUDR ((uint32_t)0x00002000)
0 c S p( P+ d( ? - #define IS_DAC_IT(IT) (((IT) == DAC_IT_DMAUDR))
/ v& ^, a5 b* c. }, Z% T0 y4 q - 3 f: h+ m) L4 x4 l9 O
- /**% \. ?# N; s4 K% [' l* N3 O g
- * @}
/ b4 h! r) @! [ M - */ 6 G# C) ~$ k$ t8 `1 R3 v. _1 r3 D2 x
- # ?2 L$ I/ g4 E% P4 e; i! U* @7 k
- /** @defgroup DAC_flags_definition ! C0 j7 H2 e: p% y3 `
- * @{/ s% M. Y$ K1 Z& ^7 h) x$ F0 Z7 {
- */ * b# K1 x# S" ]& k7 G% T+ N: R% C
- . L% |% S) P$ ~* } S7 z% A
- #define DAC_FLAG_DMAUDR ((uint32_t)0x00002000) ; ]: a, D/ _, V" w
- #define IS_DAC_FLAG(FLAG) (((FLAG) == DAC_FLAG_DMAUDR)) ! N0 v( ~; }7 D& f( l; e f0 Z
复制代码
8 I4 J* G# G# P; M( k. v0 U0 v" s03. 相关函数
' m7 z" q9 s/ n6 n9 Z- M; R2 M- /* Function used to set the DAC configuration to the default reset state *****/
/ y }* C+ H& |7 J6 @( \5 w! N - void DAC_DeInit(void);$ J/ K5 f" H& C" L/ f' q( T! _
- 0 J% H1 t% v$ P6 a- J1 j
- /* DAC channels configuration: trigger, output buffer, data format functions */
/ x+ q2 }6 f# X) v ?6 y- F4 Y& j - void DAC_Init(uint32_t DAC_Channel, DAC_InitTypeDef* DAC_InitStruct);
' N* x1 ~$ i/ a3 F6 T - void DAC_StructInit(DAC_InitTypeDef* DAC_InitStruct);
0 V9 T9 ^, O( f2 T' ~9 R - void DAC_Cmd(uint32_t DAC_Channel, FunctionalState NewState);0 i" a5 m8 v _" b. q
- void DAC_SoftwareTriggerCmd(uint32_t DAC_Channel, FunctionalState NewState);
- ^ n2 B$ q0 I9 U4 h( |6 F - void DAC_DualSoftwareTriggerCmd(FunctionalState NewState);
0 _: d% d I3 n/ Y. w" [. D - void DAC_WaveGenerationCmd(uint32_t DAC_Channel, uint32_t DAC_Wave, FunctionalState NewState);
# g% [; {7 s4 u - void DAC_SetChannel1Data(uint32_t DAC_Align, uint16_t Data);
4 @3 p4 M; J. L% \, U- t - void DAC_SetChannel2Data(uint32_t DAC_Align, uint16_t Data);2 o! C# X% A% H* L
- void DAC_SetDualChannelData(uint32_t DAC_Align, uint16_t Data2, uint16_t Data1);- P) y% ~* A8 S$ Y: \7 Q
- uint16_t DAC_GetDataOutputValue(uint32_t DAC_Channel);
6 _1 G" Y, R& c# H, Z& V
5 K: T* Y4 D4 t' v' |/ n- /* DMA management functions ***************************************************/
# u7 n. d" D2 M! M! I& R7 ~& m - void DAC_DMACmd(uint32_t DAC_Channel, FunctionalState NewState);3 W8 R! b1 H" m" E4 \
- & T. r- {" D- Y. a& R. D
- /* Interrupts and flags management functions **********************************/
5 Y7 H* [5 A, X h' W. E5 u - void DAC_ITConfig(uint32_t DAC_Channel, uint32_t DAC_IT, FunctionalState NewState);
0 K" I7 r v, [4 U# p) u8 [; K - FlagStatus DAC_GetFlagStatus(uint32_t DAC_Channel, uint32_t DAC_FLAG);0 `% _$ X+ P& }5 r7 d7 n) D) e. O& \
- void DAC_ClearFlag(uint32_t DAC_Channel, uint32_t DAC_FLAG);
/ A7 ~$ f3 |$ y - ITStatus DAC_GetITStatus(uint32_t DAC_Channel, uint32_t DAC_IT);4 U& G0 W- }4 W# ^; Q7 i+ k6 [* q
- void DAC_ClearITPendingBit(uint32_t DAC_Channel, uint32_t DAC_IT);
复制代码 ) ^! }9 d+ j$ A3 ~
04. 结构体封装
: s2 r/ q$ L) B% L2 ]- /** . H2 G. H: m* J5 q# J
- * @brief Digital to Analog Converter
7 X# F: i" f0 F& w6 J - */0 s+ @$ h: r0 L- A, Q
- / Y4 Q5 f0 ]( s+ W% x* y( u$ l
- typedef struct
$ s* ]- G5 x+ O: Y" E& O - {
+ U* c3 G. S. b; J! }. D - __IO uint32_t CR; /*!< DAC control register, Address offset: 0x00 */
* Q! }. V) h' z - __IO uint32_t SWTRIGR; /*!< DAC software trigger register, Address offset: 0x04 */
1 ~! [/ _6 ?6 V7 C - __IO uint32_t DHR12R1; /*!< DAC channel1 12-bit right-aligned data holding register, Address offset: 0x08 */
6 `: l* A% S9 ~* ? - __IO uint32_t DHR12L1; /*!< DAC channel1 12-bit left aligned data holding register, Address offset: 0x0C */9 f1 M4 l; G, Z- f3 e% c
- __IO uint32_t DHR8R1; /*!< DAC channel1 8-bit right aligned data holding register, Address offset: 0x10 */7 C1 z) S" K5 H8 I* @5 e3 J& \
- __IO uint32_t DHR12R2; /*!< DAC channel2 12-bit right aligned data holding register, Address offset: 0x14 */
; O, c% e, ~4 G5 O' z - __IO uint32_t DHR12L2; /*!< DAC channel2 12-bit left aligned data holding register, Address offset: 0x18 */, x! h9 L! {8 }
- __IO uint32_t DHR8R2; /*!< DAC channel2 8-bit right-aligned data holding register, Address offset: 0x1C */5 o! I; y5 k) \" L
- __IO uint32_t DHR12RD; /*!< Dual DAC 12-bit right-aligned data holding register, Address offset: 0x20 */: w, J2 ]3 P' u Y
- __IO uint32_t DHR12LD; /*!< DUAL DAC 12-bit left aligned data holding register, Address offset: 0x24 */
7 u* U3 ]* c8 s2 }" g& @" O - __IO uint32_t DHR8RD; /*!< DUAL DAC 8-bit right aligned data holding register, Address offset: 0x28 */7 A% q* I6 c0 h# z, ]( h6 |: x
- __IO uint32_t DOR1; /*!< DAC channel1 data output register, Address offset: 0x2C */5 H0 a) v' U( X$ {7 f
- __IO uint32_t DOR2; /*!< DAC channel2 data output register, Address offset: 0x30 */
/ e g/ z1 A: h0 Z9 R6 Q$ y; `4 { - __IO uint32_t SR; /*!< DAC status register, Address offset: 0x34 */
! v) E: n, f P0 S6 d - } DAC_TypeDef;
复制代码
7 d% _5 m, q1 S" z/ l) |7 u q0 b; D5 {$ L3 H# T- R$ A9 h" ~- n
! K2 W' v9 j0 X
|