11 #ifndef __MG32F157_DAC_H 12 #define __MG32F157_DAC_H 60 #define DAC_Trigger_None ((uint32_t)0x00000000) 62 #define DAC_Trigger_T6_TRGO ((uint32_t)0x00000004) 63 #define DAC_Trigger_T3_TRGO ((uint32_t)0x0000000C) 64 #define DAC_Trigger_T7_TRGO ((uint32_t)0x00000014) 65 #define DAC_Trigger_T5_TRGO ((uint32_t)0x0000001C) 66 #define DAC_Trigger_T2_TRGO ((uint32_t)0x00000024) 67 #define DAC_Trigger_T4_TRGO ((uint32_t)0x0000002C) 68 #define DAC_Trigger_Ext_IT9 ((uint32_t)0x00000034) 69 #define DAC_Trigger_Software ((uint32_t)0x0000003C) 71 #define IS_DAC_TRIGGER(TRIGGER) (((TRIGGER) == DAC_Trigger_None) || \ 72 ((TRIGGER) == DAC_Trigger_T6_TRGO) || \ 73 ((TRIGGER) == DAC_Trigger_T8_TRGO) || \ 74 ((TRIGGER) == DAC_Trigger_T7_TRGO) || \ 75 ((TRIGGER) == DAC_Trigger_T5_TRGO) || \ 76 ((TRIGGER) == DAC_Trigger_T2_TRGO) || \ 77 ((TRIGGER) == DAC_Trigger_T4_TRGO) || \ 78 ((TRIGGER) == DAC_Trigger_Ext_IT9) || \ 79 ((TRIGGER) == DAC_Trigger_Software)) 88 #define DAC_WaveGeneration_None ((uint32_t)0x00000000) 89 #define DAC_WaveGeneration_Noise ((uint32_t)0x00000040) 90 #define DAC_WaveGeneration_Triangle ((uint32_t)0x00000080) 91 #define IS_DAC_GENERATE_WAVE(WAVE) (((WAVE) == DAC_WaveGeneration_None) || \ 92 ((WAVE) == DAC_WaveGeneration_Noise) || \ 93 ((WAVE) == DAC_WaveGeneration_Triangle)) 102 #define DAC_LFSRUnmask_Bit0 ((uint32_t)0x00000000) 103 #define DAC_LFSRUnmask_Bits1_0 ((uint32_t)0x00000100) 104 #define DAC_LFSRUnmask_Bits2_0 ((uint32_t)0x00000200) 105 #define DAC_LFSRUnmask_Bits3_0 ((uint32_t)0x00000300) 106 #define DAC_LFSRUnmask_Bits4_0 ((uint32_t)0x00000400) 107 #define DAC_LFSRUnmask_Bits5_0 ((uint32_t)0x00000500) 108 #define DAC_LFSRUnmask_Bits6_0 ((uint32_t)0x00000600) 109 #define DAC_LFSRUnmask_Bits7_0 ((uint32_t)0x00000700) 110 #define DAC_LFSRUnmask_Bits8_0 ((uint32_t)0x00000800) 111 #define DAC_LFSRUnmask_Bits9_0 ((uint32_t)0x00000900) 112 #define DAC_LFSRUnmask_Bits10_0 ((uint32_t)0x00000A00) 113 #define DAC_LFSRUnmask_Bits11_0 ((uint32_t)0x00000B00) 114 #define DAC_TriangleAmplitude_1 ((uint32_t)0x00000000) 115 #define DAC_TriangleAmplitude_3 ((uint32_t)0x00000100) 116 #define DAC_TriangleAmplitude_7 ((uint32_t)0x00000200) 117 #define DAC_TriangleAmplitude_15 ((uint32_t)0x00000300) 118 #define DAC_TriangleAmplitude_31 ((uint32_t)0x00000400) 119 #define DAC_TriangleAmplitude_63 ((uint32_t)0x00000500) 120 #define DAC_TriangleAmplitude_127 ((uint32_t)0x00000600) 121 #define DAC_TriangleAmplitude_255 ((uint32_t)0x00000700) 122 #define DAC_TriangleAmplitude_511 ((uint32_t)0x00000800) 123 #define DAC_TriangleAmplitude_1023 ((uint32_t)0x00000900) 124 #define DAC_TriangleAmplitude_2047 ((uint32_t)0x00000A00) 125 #define DAC_TriangleAmplitude_4095 ((uint32_t)0x00000B00) 127 #define IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(VALUE) (((VALUE) == DAC_LFSRUnmask_Bit0) || \ 128 ((VALUE) == DAC_LFSRUnmask_Bits1_0) || \ 129 ((VALUE) == DAC_LFSRUnmask_Bits2_0) || \ 130 ((VALUE) == DAC_LFSRUnmask_Bits3_0) || \ 131 ((VALUE) == DAC_LFSRUnmask_Bits4_0) || \ 132 ((VALUE) == DAC_LFSRUnmask_Bits5_0) || \ 133 ((VALUE) == DAC_LFSRUnmask_Bits6_0) || \ 134 ((VALUE) == DAC_LFSRUnmask_Bits7_0) || \ 135 ((VALUE) == DAC_LFSRUnmask_Bits8_0) || \ 136 ((VALUE) == DAC_LFSRUnmask_Bits9_0) || \ 137 ((VALUE) == DAC_LFSRUnmask_Bits10_0) || \ 138 ((VALUE) == DAC_LFSRUnmask_Bits11_0) || \ 139 ((VALUE) == DAC_TriangleAmplitude_1) || \ 140 ((VALUE) == DAC_TriangleAmplitude_3) || \ 141 ((VALUE) == DAC_TriangleAmplitude_7) || \ 142 ((VALUE) == DAC_TriangleAmplitude_15) || \ 143 ((VALUE) == DAC_TriangleAmplitude_31) || \ 144 ((VALUE) == DAC_TriangleAmplitude_63) || \ 145 ((VALUE) == DAC_TriangleAmplitude_127) || \ 146 ((VALUE) == DAC_TriangleAmplitude_255) || \ 147 ((VALUE) == DAC_TriangleAmplitude_511) || \ 148 ((VALUE) == DAC_TriangleAmplitude_1023) || \ 149 ((VALUE) == DAC_TriangleAmplitude_2047) || \ 150 ((VALUE) == DAC_TriangleAmplitude_4095)) 159 #define DAC_OutputBuffer_Enable ((uint32_t)0x00000000) 160 #define DAC_OutputBuffer_Disable ((uint32_t)0x00000002) 161 #define IS_DAC_OUTPUT_BUFFER_STATE(STATE) (((STATE) == DAC_OutputBuffer_Enable) || \ 162 ((STATE) == DAC_OutputBuffer_Disable)) 171 #define DAC_Channel_1 ((uint32_t)0x00000000) 172 #define DAC_Channel_2 ((uint32_t)0x00000010) 173 #define IS_DAC_CHANNEL(CHANNEL) (((CHANNEL) == DAC_Channel_1) || \ 174 ((CHANNEL) == DAC_Channel_2)) 183 #define DAC_Align_12b_R ((uint32_t)0x00000000) 184 #define DAC_Align_12b_L ((uint32_t)0x00000004) 185 #define DAC_Align_8b_R ((uint32_t)0x00000008) 186 #define IS_DAC_ALIGN(ALIGN) (((ALIGN) == DAC_Align_12b_R) || \ 187 ((ALIGN) == DAC_Align_12b_L) || \ 188 ((ALIGN) == DAC_Align_8b_R)) 197 #define DAC_Wave_Noise ((uint32_t)0x00000040) 198 #define DAC_Wave_Triangle ((uint32_t)0x00000080) 199 #define IS_DAC_WAVE(WAVE) (((WAVE) == DAC_Wave_Noise) || \ 200 ((WAVE) == DAC_Wave_Triangle)) 209 #define IS_DAC_DATA(DATA) ((DATA) <= 0xFFF0) 224 void DAC_Cmd(uint32_t DAC_Channel, FunctionalState NewState);
225 void DAC_DMACmd(uint32_t DAC_Channel, FunctionalState NewState);
void DAC_SetChannel1Data(uint32_t DAC_Align, uint16_t Data)
Set the specified data holding register value for DAC channel1.
Definition: mg32f157_dac.c:273
void DAC_Cmd(uint32_t DAC_Channel, FunctionalState NewState)
Enables or disables the specified DAC channel.
Definition: mg32f157_dac.c:137
void DAC_SoftwareTriggerCmd(uint32_t DAC_Channel, FunctionalState NewState)
Enables or disables the selected DAC channel software trigger.
Definition: mg32f157_dac.c:191
uint32_t DAC_OutputBuffer
Definition: mg32f157_dac.h:47
void DAC_DMACmd(uint32_t DAC_Channel, FunctionalState NewState)
Enables or disables the specified DAC channel DMA request.
Definition: mg32f157_dac.c:164
void DAC_WaveGenerationCmd(uint32_t DAC_Channel, uint32_t DAC_Wave, FunctionalState NewState)
Enables or disables the selected DAC channel wave generation.
Definition: mg32f157_dac.c:245
void DAC_SetChannel2Data(uint32_t DAC_Align, uint16_t Data)
Set the specified data holding register value for DAC channel2.
Definition: mg32f157_dac.c:298
void DAC_DeInit(void)
Deinitializes the DAC peripheral registers to their default reset values.
Definition: mg32f157_dac.c:62
void DAC_Init(uint32_t DAC_Channel, DAC_InitTypeDef *DAC_InitStruct)
Initializes the DAC peripheral according to the specified parameters in the DAC_InitStruct.
Definition: mg32f157_dac.c:81
void DAC_StructInit(DAC_InitTypeDef *DAC_InitStruct)
Fills each DAC_InitStruct member with its default value.
Definition: mg32f157_dac.c:114
DAC Init structure definition.
Definition: mg32f157_dac.h:34
uint16_t DAC_GetDataOutputValue(uint32_t DAC_Channel)
Returns the last data output value of the selected DAC channel.
Definition: mg32f157_dac.c:361
uint32_t DAC_WaveGeneration
Definition: mg32f157_dac.h:39
void DAC_DualSoftwareTriggerCmd(FunctionalState NewState)
Enables or disables simultaneously the two DAC channels software triggers.
Definition: mg32f157_dac.c:215
uint32_t DAC_Trigger
Definition: mg32f157_dac.h:36
void DAC_SetDualChannelData(uint32_t DAC_Align, uint16_t Data2, uint16_t Data1)
Set the specified data holding register value for dual channel DAC.
Definition: mg32f157_dac.c:327
uint32_t DAC_LFSRUnmask_TriangleAmplitude
Definition: mg32f157_dac.h:43