01. DAC简介
6 G7 b* \3 N0 `" LSTM32F4的DAC模块(数字/模拟转换模块)是12位数字输入,电压输出型的DAC。DAC可以配置为 8 位或 12 位模式,也可以与 DMA 控制器配合使用。DAC 工作在 12 位模式时,数据可以设置成左对齐或右对齐。DAC 模块有 2 个输出通道,每个通道都有单独的转换器。在双 DAC 模式下,2 个通道可以独立地进行转换,也可以同时进行转换并同步地更新 2 个通道的输出。DAC 可以通过引脚输入参考电压 Vref+(通 ADC 共用)以获得更精确的转换结果。
; B; K0 @" R0 RSTM32F4 的 DAC 模块主要特点有:
& a9 R1 j$ A' j. Y$ b- w① 2 个 DAC 转换器:每个转换器对应 1 个输出通道7 ?' c; l& ]" |, x J# K% }- I* S
② 8 位或者 12 位单调输出! P2 _+ g' R! u% d; k
③ 12 位模式下数据左对齐或者右对齐7 e( t# ~/ _, I4 d0 K$ p+ u
④ 同步更新功能/ ?, A0 [3 i( ] G; l1 ^5 \( i
⑤ 噪声波形生成0 \; T& f" `3 E; m" L7 \$ E
⑥ 三角波形生成
5 S5 j3 i8 L4 s+ i M4 z8 O# K1 T⑦ 双 DAC 通道同时或者分别转换* `/ }( J3 s9 M' _; c2 H) I
⑧ 每个通道都有 DMA 功能" I* X# v8 I+ r% m! D @; g
/ R K3 S) c4 I- R# D5 K3 y4 k
02. 相关类型3 x& p- Z: O, w: t( P4 R w. _
DAC Init structure0 K* a) p5 Y" c& t1 Z8 S) e
; P2 E( _/ i0 U3 j* `8 Q- /**
6 A* D/ D! }; H* _ - * @brief DAC Init structure definition4 e7 \, v. k- p7 b: V
- */
5 H2 m' \8 g7 ~
$ L( `# R: Q- f# g9 t- typedef struct, w) v/ ]2 D5 L) {/ Q
- {
4 F3 @! `& j% ]" M! e - uint32_t DAC_Trigger; /*!< Specifies the external trigger for the selected DAC channel.
* W; {3 {/ T9 x) R) P - This parameter can be a value of @ref DAC_trigger_selection */. C0 J, o+ t! \( ?
- 8 Z; {& N6 c# x2 h: j: g
- uint32_t DAC_WaveGeneration; /*!< Specifies whether DAC channel noise waves or triangle waves( b% x, O' k4 r% S" m' e3 r
- are generated, or whether no wave is generated.
# s3 B6 {! W; A - This parameter can be a value of @ref DAC_wave_generation */
: c/ X) C8 l8 W0 ^( R7 z - 7 L5 d1 v7 \# @7 R
- uint32_t DAC_LFSRUnmask_TriangleAmplitude; /*!< Specifies the LFSR mask for noise wave generation or7 J, |0 }5 P2 \1 Q9 L2 P# v9 b
- the maximum amplitude triangle generation for the DAC channel.
9 H. Z+ X% N* C$ f1 o* I5 h: L! e - This parameter can be a value of @ref DAC_lfsrunmask_triangleamplitude */; l2 ?& X6 m6 N0 Y; R
1 B( h( g; i; Z, @5 U5 I- uint32_t DAC_OutputBuffer; /*!< Specifies whether the DAC channel output buffer is enabled or disabled.. o5 ~5 D1 Y' f: c5 s6 C4 _& w
- This parameter can be a value of @ref DAC_output_buffer */; `- q( r; T- V J9 X8 m
- }DAC_InitTypeDef;
复制代码 . F4 Y9 @" |: e
DAC_trigger_selection
5 `; U: |2 Q2 k. d( y: G$ q3 ?2 W/ `: J* T- \8 i
- /** @defgroup DAC_trigger_selection Z4 w3 [; v& R* M& M! b
- * @{& P- L5 x! \/ c% Q. n" z# `* W
- */9 _* x8 q% Z6 O, x3 b) k& l
# M/ o4 T) e( B- #define DAC_Trigger_None ((uint32_t)0x00000000) /*!< Conversion is automatic once the DAC1_DHRxxxx register
" e4 C) g. I5 T6 O3 S" h - has been loaded, and not by external trigger */- C8 V1 M" v; K5 l
- #define DAC_Trigger_T2_TRGO ((uint32_t)0x00000024) /*!< TIM2 TRGO selected as external conversion trigger for DAC channel */
6 e, a2 G0 b2 e: D/ m6 a - #define DAC_Trigger_T4_TRGO ((uint32_t)0x0000002C) /*!< TIM4 TRGO selected as external conversion trigger for DAC channel */' J( y: m( H: Y& m$ h5 o$ V# C, k
- #define DAC_Trigger_T5_TRGO ((uint32_t)0x0000001C) /*!< TIM5 TRGO selected as external conversion trigger for DAC channel */* u0 C% y0 W7 F
- #define DAC_Trigger_T6_TRGO ((uint32_t)0x00000004) /*!< TIM6 TRGO selected as external conversion trigger for DAC channel */
3 k7 L. [ C" m1 U- u6 {% [- `/ F1 m5 { - #define DAC_Trigger_T7_TRGO ((uint32_t)0x00000014) /*!< TIM7 TRGO selected as external conversion trigger for DAC channel */
\3 u9 n" T! R - #define DAC_Trigger_T8_TRGO ((uint32_t)0x0000000C) /*!< TIM8 TRGO selected as external conversion trigger for DAC channel */ 9 R! k5 q) G* V
- * c4 G8 E* M% U; R, {
- #define DAC_Trigger_Ext_IT9 ((uint32_t)0x00000034) /*!< EXTI Line9 event selected as external conversion trigger for DAC channel */, y) a. t! y3 c( ?6 f
- #define DAC_Trigger_Software ((uint32_t)0x0000003C) /*!< Conversion started by software trigger for DAC channel */2 W" o: Q4 F% G2 o
& D$ Y, ^ q3 Q# b8 [- M! n, t- #define IS_DAC_TRIGGER(TRIGGER) (((TRIGGER) == DAC_Trigger_None) || \& k# Y2 Q% z" [# _* r
- ((TRIGGER) == DAC_Trigger_T6_TRGO) || \
' R0 `( J6 D0 b" z - ((TRIGGER) == DAC_Trigger_T8_TRGO) || \
' q- v' S$ B* Q0 q7 a - ((TRIGGER) == DAC_Trigger_T7_TRGO) || \: j. }1 A H$ A- z, [
- ((TRIGGER) == DAC_Trigger_T5_TRGO) || \
2 P: r* G4 o( X+ p2 k - ((TRIGGER) == DAC_Trigger_T2_TRGO) || \, K2 ~* G F; H0 ]- w. V
- ((TRIGGER) == DAC_Trigger_T4_TRGO) || \2 f {9 b" S9 F) _' Z# v% a
- ((TRIGGER) == DAC_Trigger_Ext_IT9) || \
, o: } X- A1 C+ y- F* M) ?7 V; o - ((TRIGGER) == DAC_Trigger_Software))
复制代码
2 @" U" z$ c0 k; I3 b' a* x3 WDAC_wave_generation
+ r3 h" H2 j: ]( w% r4 v: A& h, ~& q9 w- F9 d! I
- /** @defgroup DAC_wave_generation
5 T8 J( k1 E' F8 [3 l8 D - * @{
, @7 d& x% x& R7 A$ U - */
" Y& ?' }) ?7 a
) S" x" z5 J6 ^1 R- }. Q- #define DAC_WaveGeneration_None ((uint32_t)0x00000000)
' M0 T8 X0 ^" h - #define DAC_WaveGeneration_Noise ((uint32_t)0x00000040)
8 [. N% F3 ^6 u' a - #define DAC_WaveGeneration_Triangle ((uint32_t)0x00000080)
* ]/ R% N! ?3 w) U - #define IS_DAC_GENERATE_WAVE(WAVE) (((WAVE) == DAC_WaveGeneration_None) || \& P& L3 B! H+ ?( ]
- ((WAVE) == DAC_WaveGeneration_Noise) || \
) \' k O3 e) K) n0 c* l6 x1 M! U - ((WAVE) == DAC_WaveGeneration_Triangle))
复制代码 / E6 E- p6 P" ^; i( a+ |" j! h5 Z
DAC_lfsrunmask_triangleamplitude
p' M5 u) I! t7 n# n8 D4 o2 }6 L2 T. r3 N
$ C: a/ m, {: O& u8 t8 ?3 v- /** @defgroup DAC_lfsrunmask_triangleamplitude/ F. A9 L% J' N- r1 I' O" n! \
- * @{
$ D0 m# `. Z) l2 O: u, |7 Q - */. ]9 D, z+ z, X' S3 f) X5 r
- + ~* t- H! q* \2 R
- #define DAC_LFSRUnmask_Bit0 ((uint32_t)0x00000000) /*!< Unmask DAC channel LFSR bit0 for noise wave generation */
! D; [. q& I" [1 z$ H' k- ~ - #define DAC_LFSRUnmask_Bits1_0 ((uint32_t)0x00000100) /*!< Unmask DAC channel LFSR bit[1:0] for noise wave generation */
: O2 {" u3 }% }2 h Z% q - #define DAC_LFSRUnmask_Bits2_0 ((uint32_t)0x00000200) /*!< Unmask DAC channel LFSR bit[2:0] for noise wave generation */
9 d' }) u9 l" z5 i% @' v - #define DAC_LFSRUnmask_Bits3_0 ((uint32_t)0x00000300) /*!< Unmask DAC channel LFSR bit[3:0] for noise wave generation */
7 G7 V6 f, U' n& I0 l- H( Z7 f - #define DAC_LFSRUnmask_Bits4_0 ((uint32_t)0x00000400) /*!< Unmask DAC channel LFSR bit[4:0] for noise wave generation */, l" N" S# ~* Z2 `! A* Y* x6 d
- #define DAC_LFSRUnmask_Bits5_0 ((uint32_t)0x00000500) /*!< Unmask DAC channel LFSR bit[5:0] for noise wave generation */
& X. q$ [& Q6 X7 C$ B/ b - #define DAC_LFSRUnmask_Bits6_0 ((uint32_t)0x00000600) /*!< Unmask DAC channel LFSR bit[6:0] for noise wave generation */
2 m- H% c! l0 E7 i: m - #define DAC_LFSRUnmask_Bits7_0 ((uint32_t)0x00000700) /*!< Unmask DAC channel LFSR bit[7:0] for noise wave generation */. W3 r. a" d/ c7 l
- #define DAC_LFSRUnmask_Bits8_0 ((uint32_t)0x00000800) /*!< Unmask DAC channel LFSR bit[8:0] for noise wave generation */7 K; y( I) g$ r# ~! c* B
- #define DAC_LFSRUnmask_Bits9_0 ((uint32_t)0x00000900) /*!< Unmask DAC channel LFSR bit[9:0] for noise wave generation */8 J. o- O- E% p# A7 Y5 N
- #define DAC_LFSRUnmask_Bits10_0 ((uint32_t)0x00000A00) /*!< Unmask DAC channel LFSR bit[10:0] for noise wave generation */
; |9 u( G6 X' a1 ^( t+ v1 M3 S - #define DAC_LFSRUnmask_Bits11_0 ((uint32_t)0x00000B00) /*!< Unmask DAC channel LFSR bit[11:0] for noise wave generation */
2 v7 T% u5 S* q2 g% |% F: C - #define DAC_TriangleAmplitude_1 ((uint32_t)0x00000000) /*!< Select max triangle amplitude of 1 */ D. a5 y% x! y
- #define DAC_TriangleAmplitude_3 ((uint32_t)0x00000100) /*!< Select max triangle amplitude of 3 */
- E+ @) z) l" v, z$ G - #define DAC_TriangleAmplitude_7 ((uint32_t)0x00000200) /*!< Select max triangle amplitude of 7 */
* x" R8 t* {2 F# i$ @ - #define DAC_TriangleAmplitude_15 ((uint32_t)0x00000300) /*!< Select max triangle amplitude of 15 */8 {' j# ~: H" M% E' \. [: Y
- #define DAC_TriangleAmplitude_31 ((uint32_t)0x00000400) /*!< Select max triangle amplitude of 31 */
) R/ k1 ~/ m- d: I - #define DAC_TriangleAmplitude_63 ((uint32_t)0x00000500) /*!< Select max triangle amplitude of 63 */# U6 G( m# p8 ?% V9 P/ J. f/ {
- #define DAC_TriangleAmplitude_127 ((uint32_t)0x00000600) /*!< Select max triangle amplitude of 127 */: T: d! x' u! J* U) N
- #define DAC_TriangleAmplitude_255 ((uint32_t)0x00000700) /*!< Select max triangle amplitude of 255 *// ]* T) W3 }: y) G0 _% R5 ]1 ^
- #define DAC_TriangleAmplitude_511 ((uint32_t)0x00000800) /*!< Select max triangle amplitude of 511 */
- g9 u2 `4 d: F6 m: r9 D# o - #define DAC_TriangleAmplitude_1023 ((uint32_t)0x00000900) /*!< Select max triangle amplitude of 1023 */3 r# t; _* t& }- b+ v
- #define DAC_TriangleAmplitude_2047 ((uint32_t)0x00000A00) /*!< Select max triangle amplitude of 2047 */
* l5 L# G/ J/ q - #define DAC_TriangleAmplitude_4095 ((uint32_t)0x00000B00) /*!< Select max triangle amplitude of 4095 */
- ^" o5 }3 X+ ?$ `1 X - ) H7 s9 ~1 R! ^0 \) j! V$ Z/ q
- #define IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(VALUE) (((VALUE) == DAC_LFSRUnmask_Bit0) || \
+ h h s0 c) s ]9 ^ - ((VALUE) == DAC_LFSRUnmask_Bits1_0) || \. q2 h4 ^- Q( T5 F3 ~- K/ t: v
- ((VALUE) == DAC_LFSRUnmask_Bits2_0) || \
6 z, ~3 S- T+ V; e- G - ((VALUE) == DAC_LFSRUnmask_Bits3_0) || \7 G1 q" Y& z6 C
- ((VALUE) == DAC_LFSRUnmask_Bits4_0) || \
4 A: e) p% [3 ^ - ((VALUE) == DAC_LFSRUnmask_Bits5_0) || \
6 }, X/ R; Z: G3 ]* ]5 P - ((VALUE) == DAC_LFSRUnmask_Bits6_0) || \' d! E" x4 j Q
- ((VALUE) == DAC_LFSRUnmask_Bits7_0) || \
( Q# W8 W! P5 y4 D8 U - ((VALUE) == DAC_LFSRUnmask_Bits8_0) || \; Z' \ Q. s* K- R7 \$ H) X
- ((VALUE) == DAC_LFSRUnmask_Bits9_0) || \
% ]8 J/ E) |* W - ((VALUE) == DAC_LFSRUnmask_Bits10_0) || \
+ I! [' g1 O Z6 _) g! T% ?6 @& T - ((VALUE) == DAC_LFSRUnmask_Bits11_0) || \' D5 O. ]3 {1 a4 e
- ((VALUE) == DAC_TriangleAmplitude_1) || \- P7 r( S& q- E4 G' u) ~$ A' t# X
- ((VALUE) == DAC_TriangleAmplitude_3) || \% F. X) J8 k. S9 ~) o
- ((VALUE) == DAC_TriangleAmplitude_7) || \
4 i3 Q0 s1 z4 V* ^7 d6 t - ((VALUE) == DAC_TriangleAmplitude_15) || \
( t2 e' ?& k. Z# m - ((VALUE) == DAC_TriangleAmplitude_31) || \
, h. O- i+ f* V! ] - ((VALUE) == DAC_TriangleAmplitude_63) || \. d5 [3 s, V" @! p* ?
- ((VALUE) == DAC_TriangleAmplitude_127) || \
3 p- \1 v6 ? J* L7 q3 P - ((VALUE) == DAC_TriangleAmplitude_255) || \
: H9 V1 t& b% E- ~* c8 G/ t5 T - ((VALUE) == DAC_TriangleAmplitude_511) || \: K4 U( t9 c; `& o: k
- ((VALUE) == DAC_TriangleAmplitude_1023) || \
. Q( ^4 Z: l( } - ((VALUE) == DAC_TriangleAmplitude_2047) || \7 l" u, {# w& P
- ((VALUE) == DAC_TriangleAmplitude_4095))
复制代码 7 l9 j1 _$ R( X. }6 e
DAC_output_buffer
, x: B! |- Z) O1 d! `/ o. u; T2 V5 Q3 h& {& O0 q
- /** @defgroup DAC_output_buffer & D4 V5 o8 ^ @2 u+ T/ b, }
- * @{5 i: P% P, U& w# k+ K
- */
* H* l) C q& a* o - " L3 t- a1 P, U# [. l+ q- N
- #define DAC_OutputBuffer_Enable ((uint32_t)0x00000000)
6 t$ K) j3 A4 [- g+ S' ]: G - #define DAC_OutputBuffer_Disable ((uint32_t)0x00000002)
' T, L. y! b- W5 T6 Q8 ^ - #define IS_DAC_OUTPUT_BUFFER_STATE(STATE) (((STATE) == DAC_OutputBuffer_Enable) || \
: Y0 k: o% _1 [ - ((STATE) == DAC_OutputBuffer_Disable))
复制代码 9 a- x( M7 q, _% d
DAC_Channel_selection
- o5 A( J6 f+ c7 T8 P
% J6 Q. ^) z* A9 O- /** @defgroup DAC_Channel_selection $ S4 | U: t' l; w4 h8 O* ?8 w0 U
- * @{7 }& i# F. [8 ?( [5 W
- */. L: f. S. ]. ?% j* o# {( l
% j. o/ }) y9 x0 A( e' ^, N0 A7 m- #define DAC_Channel_1 ((uint32_t)0x00000000)
[! N4 }1 |( y* q0 j( J - #define DAC_Channel_2 ((uint32_t)0x00000010)4 V: X$ H2 c$ J
- #define IS_DAC_CHANNEL(CHANNEL) (((CHANNEL) == DAC_Channel_1) || \
- q$ }9 \3 T. s - ((CHANNEL) == DAC_Channel_2))
复制代码 + X. t. z8 z& @5 s
DAC_data_alignement
' y9 P( H+ ^$ d5 _% P2 ~1 P; U7 ]
' t+ h) |2 F6 M+ l+ `8 U* X7 [5 a- /** @defgroup DAC_data_alignement 9 W' ]% A; S# n$ y! ^0 z+ L
- * @{9 i8 `: q/ n8 V
- */
' K" r* c3 i, y' g6 H5 a1 T) O# Z
% |! \6 q3 U" N ?8 R- #define DAC_Align_12b_R ((uint32_t)0x00000000)! k- Y% X& G* o: {8 t2 H- E
- #define DAC_Align_12b_L ((uint32_t)0x00000004)
* G" ~; k3 y! D - #define DAC_Align_8b_R ((uint32_t)0x00000008)! U, \7 [: E( @( Q" B
- #define IS_DAC_ALIGN(ALIGN) (((ALIGN) == DAC_Align_12b_R) || \" M1 k' R2 P5 q) N4 y; A6 T
- ((ALIGN) == DAC_Align_12b_L) || \
! `) N& G- ? K7 s. ^, C9 q4 W - ((ALIGN) == DAC_Align_8b_R))
复制代码 ( c. _/ O6 M- d+ ]2 k5 e6 Q" w1 @
DAC_wave_generation: @2 c5 ?8 k1 p' g( ~2 E
, ^, N- T1 m' n- /** @defgroup DAC_wave_generation N/ }3 l# z5 ] ]# U
- * @{
Q% w' ^, @1 _( j - */
. Y. V4 l- d5 g2 ^4 V - 8 }1 E. R8 P' Q
- #define DAC_Wave_Noise ((uint32_t)0x00000040)$ v# s" K3 S, Z, @" e7 T B# o
- #define DAC_Wave_Triangle ((uint32_t)0x00000080)
0 j8 q- e. L6 H8 J - #define IS_DAC_WAVE(WAVE) (((WAVE) == DAC_Wave_Noise) || \
" M y2 w _# w j, z - ((WAVE) == DAC_Wave_Triangle))
复制代码 ' P/ |2 k) ], l
其它
% `' V U4 h' ?% A7 W
" h7 M$ ?0 P' a, g8 [% Z7 w. ~) U, B- /** @defgroup DAC_data
2 X: l4 c# `) h* h - * @{
) Y- q, n" d- j+ g4 }2 M8 M - */
' M$ ]' D% [/ Y$ g( @8 u2 M% s5 @ - * _9 }% R6 _$ E( w
- #define IS_DAC_DATA(DATA) ((DATA) <= 0xFFF0) / j' e! s% g i$ Q
- /**
0 F( A" @- ^4 K2 z( C - * @}6 Y7 w' }. c* I2 c
- */7 t* \, s. I' T, e
- & \# H7 _. `& k# e0 n( t
- /** @defgroup DAC_interrupts_definition
! [' _* u1 J- B2 M$ c. T1 \7 ] - * @{% c. `2 q' O$ o5 y0 l5 ]: G
- */ % M0 J) {" s' [
- #define DAC_IT_DMAUDR ((uint32_t)0x00002000)
2 J/ o8 E. b* ^+ k( t6 g& n - #define IS_DAC_IT(IT) (((IT) == DAC_IT_DMAUDR)) 2 h& ~7 U+ F* P5 S' y' ^9 y
( ^* q( U Y) |9 G- /**; Q/ ]/ U2 G+ `! b* R( r; w8 V
- * @}' Z7 |; D: p" |$ T4 e& ~9 Q$ V9 S5 k
- */ 7 F4 x7 \: h' l5 t- i
1 `5 H4 o% J- c2 ^- /** @defgroup DAC_flags_definition
* |: }( |9 E& Z% p9 r - * @{1 j' Z/ e' ~( }2 Z: A
- */
6 k% d6 }# \$ B
6 F. N; d7 `% x' C- #define DAC_FLAG_DMAUDR ((uint32_t)0x00002000) ) Z( M4 g: o+ S9 o' T7 L# t
- #define IS_DAC_FLAG(FLAG) (((FLAG) == DAC_FLAG_DMAUDR))
复制代码
+ z0 y& F0 [) E! w2 G03. 相关函数
* {9 m% J9 x( h& @7 W- /* Function used to set the DAC configuration to the default reset state *****/ " [1 |* W0 M; ]: {; y, O
- void DAC_DeInit(void);2 F! t& ^/ {, m' n
! W6 ]; m4 d+ C3 _: @5 m* [4 r- /* DAC channels configuration: trigger, output buffer, data format functions */3 q q, b/ K- u |* ]6 Y& i+ z: r7 u
- void DAC_Init(uint32_t DAC_Channel, DAC_InitTypeDef* DAC_InitStruct);
+ s$ q+ N' b& c: b) V. h - void DAC_StructInit(DAC_InitTypeDef* DAC_InitStruct);- N" D0 K6 S0 B3 I5 x3 ?
- void DAC_Cmd(uint32_t DAC_Channel, FunctionalState NewState);5 ]" r( f" [2 l
- void DAC_SoftwareTriggerCmd(uint32_t DAC_Channel, FunctionalState NewState);
. \ A& U3 f: Z! A - void DAC_DualSoftwareTriggerCmd(FunctionalState NewState);4 D( J0 B6 U# k
- void DAC_WaveGenerationCmd(uint32_t DAC_Channel, uint32_t DAC_Wave, FunctionalState NewState);
3 [4 Z- e4 a0 V! T6 }9 M @ - void DAC_SetChannel1Data(uint32_t DAC_Align, uint16_t Data);) Y9 x3 N7 `6 [1 k+ R# b# z
- void DAC_SetChannel2Data(uint32_t DAC_Align, uint16_t Data);
" a/ l$ U4 Q- z4 }% g - void DAC_SetDualChannelData(uint32_t DAC_Align, uint16_t Data2, uint16_t Data1);
) F8 B. y$ u4 p1 x - uint16_t DAC_GetDataOutputValue(uint32_t DAC_Channel);! W. y$ I" s3 t2 M9 I/ B! j
" }" A( J) u/ x5 z* h( s- /* DMA management functions ***************************************************/
+ w+ o7 M$ z7 r - void DAC_DMACmd(uint32_t DAC_Channel, FunctionalState NewState);
4 h2 C7 w) `4 |0 O - ! o% d& Q* E4 H
- /* Interrupts and flags management functions **********************************/
: \) ]3 P7 K C - void DAC_ITConfig(uint32_t DAC_Channel, uint32_t DAC_IT, FunctionalState NewState);; R( C. p" N: G! Z5 \( m
- FlagStatus DAC_GetFlagStatus(uint32_t DAC_Channel, uint32_t DAC_FLAG);
- B, O& W0 d5 a0 [; O6 Y; T" E - void DAC_ClearFlag(uint32_t DAC_Channel, uint32_t DAC_FLAG);
6 `) {: a* v; T7 l8 E, V; k - ITStatus DAC_GetITStatus(uint32_t DAC_Channel, uint32_t DAC_IT);
( ~( D _2 s# v* I# t# C5 T! E - void DAC_ClearITPendingBit(uint32_t DAC_Channel, uint32_t DAC_IT);
复制代码
; z7 H( C! w# X. L04. 结构体封装
/ L" H, N0 V n5 Q3 A- /**
& h3 e M& Y1 ~ - * @brief Digital to Analog Converter
) ]1 m. ?: j3 d2 _* P - */
" N6 a% y0 v" ^+ p1 r( w: {
, `/ a9 P2 D( D6 S! ^- typedef struct1 }; @0 k* S; f9 I' v+ l2 F4 e& S9 W
- {3 o% J0 W+ ]0 |; F9 h- c) j+ I
- __IO uint32_t CR; /*!< DAC control register, Address offset: 0x00 */
# }9 |6 x7 l% o& q - __IO uint32_t SWTRIGR; /*!< DAC software trigger register, Address offset: 0x04 */
9 ?+ l4 g7 s$ Z - __IO uint32_t DHR12R1; /*!< DAC channel1 12-bit right-aligned data holding register, Address offset: 0x08 */
1 i: |% S; _5 l - __IO uint32_t DHR12L1; /*!< DAC channel1 12-bit left aligned data holding register, Address offset: 0x0C */3 N. s$ t1 E9 M! s* [: f
- __IO uint32_t DHR8R1; /*!< DAC channel1 8-bit right aligned data holding register, Address offset: 0x10 */) G7 h S3 d; I. ]
- __IO uint32_t DHR12R2; /*!< DAC channel2 12-bit right aligned data holding register, Address offset: 0x14 */
: F" w1 x0 `! g - __IO uint32_t DHR12L2; /*!< DAC channel2 12-bit left aligned data holding register, Address offset: 0x18 */
7 u# s' |1 T( A+ H - __IO uint32_t DHR8R2; /*!< DAC channel2 8-bit right-aligned data holding register, Address offset: 0x1C */6 |! Z6 s3 ], e; a! K9 w
- __IO uint32_t DHR12RD; /*!< Dual DAC 12-bit right-aligned data holding register, Address offset: 0x20 */7 v& q0 p, p; |- D/ B* O
- __IO uint32_t DHR12LD; /*!< DUAL DAC 12-bit left aligned data holding register, Address offset: 0x24 */) g' U1 U0 |) Q# N9 S+ U
- __IO uint32_t DHR8RD; /*!< DUAL DAC 8-bit right aligned data holding register, Address offset: 0x28 */
4 N3 H3 Z8 _9 m+ R2 P - __IO uint32_t DOR1; /*!< DAC channel1 data output register, Address offset: 0x2C */- a% @$ l4 H u7 D& @4 Y; e
- __IO uint32_t DOR2; /*!< DAC channel2 data output register, Address offset: 0x30 */
; t0 ^0 i5 \6 b- z' u - __IO uint32_t SR; /*!< DAC status register, Address offset: 0x34 */
) }" d% x0 c/ P, q - } DAC_TypeDef;
复制代码
; b( t" R t! {1 ~ G0 u
9 B# K# h$ I$ [ P) [& S0 ]9 F5 u3 e% F9 x
|