Browse Source

API change to remove dual loading default case for dac_load_data_buffer_single

Also change dac_data from u32 to u16
pull/138/head
Alan Braithwaite 12 years ago
committed by Felix Ruess
parent
commit
67903bfbfe
  1. 4
      include/libopencm3/stm32/common/dac_common_all.h
  2. 28
      lib/stm32/common/dac_common_all.c

4
include/libopencm3/stm32/common/dac_common_all.h

@ -401,8 +401,8 @@ void dac_set_trigger_source(u32 dac_trig_src);
void dac_set_waveform_generation(u32 dac_wave_ens); void dac_set_waveform_generation(u32 dac_wave_ens);
void dac_disable_waveform_generation(data_channel dac_channel); void dac_disable_waveform_generation(data_channel dac_channel);
void dac_set_waveform_characteristics(u32 dac_mamp); void dac_set_waveform_characteristics(u32 dac_mamp);
void dac_load_data_buffer_single(u32 dac_data, data_align dac_data_format, data_channel dac_channel); void dac_load_data_buffer_single(u16 dac_data, data_align dac_data_format, data_channel dac_channel);
void dac_load_data_buffer_dual(u32 dac_data1, u32 dac_data2, data_align dac_data_format); void dac_load_data_buffer_dual(u16 dac_data1, u16 dac_data2, data_align dac_data_format);
void dac_software_trigger(data_channel dac_channel); void dac_software_trigger(data_channel dac_channel);
END_DECLS END_DECLS

28
lib/stm32/common/dac_common_all.c

@ -402,18 +402,12 @@ data to be converted on a channel. The data can be aligned as follows:
@li right-aligned 12 bit data in bits 0-11 @li right-aligned 12 bit data in bits 0-11
@li left aligned 12 bit data in bits 4-15 @li left aligned 12 bit data in bits 4-15
This function can also be used to load the dual channel registers if the data is @param[in] dac_data u16 with appropriate alignment.
formatted according to the datasheets:
@li right-aligned 8 bit data in bits 0-7 for channel 1 and 8-15 for channel 2
@li right-aligned 12 bit data in bits 0-11 for channel 1 and 16-27 for channel 2
@li left aligned 12 bit data in bits 4-15 for channel 1 and 20-31 for channel 2
@param[in] dac_data u32 with appropriate alignment.
@param[in] dac_data_format enum ::data_align. Alignment and size. @param[in] dac_data_format enum ::data_align. Alignment and size.
@param[in] dac_channel enum ::data_channel. @param[in] dac_channel enum ::data_channel.
*/ */
void dac_load_data_buffer_single(u32 dac_data, data_align dac_data_format, data_channel dac_channel) void dac_load_data_buffer_single(u16 dac_data, data_align dac_data_format, data_channel dac_channel)
{ {
if (dac_channel == CHANNEL_1) if (dac_channel == CHANNEL_1)
{ {
@ -443,18 +437,6 @@ void dac_load_data_buffer_single(u32 dac_data, data_align dac_data_format, data_
break; break;
} }
} }
else
switch (dac_data_format) {
case RIGHT8:
DAC_DHR8RD = dac_data;
break;
case RIGHT12:
DAC_DHR12RD = dac_data;
break;
case LEFT12:
DAC_DHR12LD = dac_data;
break;
}
} }
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
@ -465,12 +447,12 @@ Loads the appropriate digital to analog converter dual data register with 12 or
simultaneous or independent analog output. The data in both channels are aligned simultaneous or independent analog output. The data in both channels are aligned
identically. identically.
@param[in] dac_data1 u32 for channel 1 with appropriate alignment. @param[in] dac_data1 u16 for channel 1 with appropriate alignment.
@param[in] dac_data2 u32 for channel 2 with appropriate alignment. @param[in] dac_data2 u16 for channel 2 with appropriate alignment.
@param[in] dac_data_format enum ::data_align. Right or left aligned, and 8 or 12 bit. @param[in] dac_data_format enum ::data_align. Right or left aligned, and 8 or 12 bit.
*/ */
void dac_load_data_buffer_dual(u32 dac_data1, u32 dac_data2, data_align dac_data_format) void dac_load_data_buffer_dual(u16 dac_data1, u16 dac_data2, data_align dac_data_format)
{ {
switch (dac_data_format) { switch (dac_data_format) {
case RIGHT8: case RIGHT8:

Loading…
Cancel
Save