Browse Source

stm32: dac: doc: link data types

And also drop pointless whitespace and divider markers
pull/1277/head
Karl Palsson 4 years ago
parent
commit
59fdb61bf2
  1. 71
      lib/stm32/common/dac_common_all.c
  2. 12
      lib/stm32/common/dac_common_v1.c
  3. 32
      lib/stm32/common/dac_common_v2.c

71
lib/stm32/common/dac_common_all.c

@ -1,5 +1,6 @@
/** @addtogroup dac_file DAC peripheral API
* @ingroup peripheral_apis
* @brief Digital to Analog Converter
@author @htmlonly &copy; @endhtmlonly 2012 Ken Sarkies <ksarkies@internode.on.net>
@author @htmlonly &copy; @endhtmlonly 2020 Ben Brewer <ben.brewer@codethink.co.uk>
@ -124,17 +125,15 @@ LGPL License Terms @ref lgpl_license
#include <libopencm3/stm32/dac.h>
/*---------------------------------------------------------------------------*/
/** @brief DAC Channel Enable.
Enable a digital to analog converter channel. After setting this enable, the
DAC requires a t<sub>wakeup</sub> time typically around 10 microseconds before
it actually wakes up.
@param[in] dac uint32_t the base address of the DAC.
@param[in] channel uint8_t with DAC mask.
@param[in] dac the base address of the DAC @ref dac_reg_base
@param[in] channel with DAC mask. @ref dac_channel_id
*/
void dac_enable(uint32_t dac, int channel)
{
switch (channel) {
@ -150,15 +149,13 @@ void dac_enable(uint32_t dac, int channel)
}
}
/*---------------------------------------------------------------------------*/
/** @brief DAC Channel Disable.
Disable a digital to analog converter channel.
@param[in] dac uint32_t the base address of the DAC.
@param[in] channel uint8_t with DAC mask.
@param[in] dac the base address of the DAC @ref dac_reg_base
@param[in] channel with DAC mask @ref dac_channel_id
*/
void dac_disable(uint32_t dac, int channel)
{
switch (channel) {
@ -176,17 +173,15 @@ void dac_disable(uint32_t dac, int channel)
}
}
/*---------------------------------------------------------------------------*/
/** @brief DAC Channel DMA Enable.
Enable a digital to analog converter channel DMA mode (connected to DMA2 channel
3 for DAC channel 1 and DMA2 channel 4 for DAC channel 2). A DMA request is
generated following an external trigger.
@param[in] dac uint32_t the base address of the DAC.
@param[in] channel uint8_t with DAC mask.
@param[in] dac the base address of the DAC. @ref dac_reg_base
@param[in] channel with DAC mask. @ref dac_channel_id
*/
void dac_dma_enable(uint32_t dac, int channel)
{
switch (channel) {
@ -204,15 +199,13 @@ void dac_dma_enable(uint32_t dac, int channel)
}
}
/*---------------------------------------------------------------------------*/
/** @brief DAC Channel DMA Disable.
Disable a digital to analog converter channel DMA mode.
@param[in] dac uint32_t the base address of the DAC.
@param[in] channel uint8_t with DAC mask.
@param[in] dac the base address of the DAC. @ref dac_reg_base
@param[in] channel with DAC mask. @ref dac_channel_id
*/
void dac_dma_disable(uint32_t dac, int channel)
{
switch (channel) {
@ -230,7 +223,6 @@ void dac_dma_disable(uint32_t dac, int channel)
}
}
/*---------------------------------------------------------------------------*/
/** @brief DAC Channel Trigger Enable.
Enable a digital to analog converter channel external trigger mode. This allows
@ -238,10 +230,9 @@ an external trigger to initiate register transfers from the buffer register to
the DAC output register, followed by a DMA transfer to the buffer register if
DMA is enabled. The trigger source must also be selected.
@param[in] dac uint32_t the base address of the DAC.
@param[in] channel uint8_t with DAC mask.
@param[in] dac the base address of the DAC. @ref dac_reg_base
@param[in] channel with DAC mask. @ref dac_channel_id
*/
void dac_trigger_enable(uint32_t dac, int channel)
{
switch (channel) {
@ -259,15 +250,13 @@ void dac_trigger_enable(uint32_t dac, int channel)
}
}
/*---------------------------------------------------------------------------*/
/** @brief DAC Channel Trigger Disable.
Disable a digital to analog converter channel external trigger.
@param[in] dac uint32_t the base address of the DAC.
@param[in] channel uint8_t with DAC mask.
@param[in] dac the base address of the DAC. @ref dac_reg_base
@param[in] channel with DAC mask. @ref dac_channel_id
*/
void dac_trigger_disable(uint32_t dac, int channel)
{
switch (channel) {
@ -285,24 +274,21 @@ void dac_trigger_disable(uint32_t dac, int channel)
}
}
/*---------------------------------------------------------------------------*/
/** @brief Set DAC Channel Trigger Source.
Sets the digital to analog converter trigger source, which can be taken from
various timers, an external trigger or a software trigger.
@param[in] dac uint32_t the base address of the DAC.
@param[in] source uint32_t. Taken from @ref dac_trig2_sel or @ref
@param[in] dac the base address of the DAC. @ref dac_reg_base
@param[in] source Taken from @ref dac_trig2_sel or @ref
dac_trig1_sel or a logical OR of one of each of these to set both channels
simultaneously.
*/
void dac_set_trigger_source(uint32_t dac, uint32_t source)
{
DAC_CR(dac) |= source;
}
/*---------------------------------------------------------------------------*/
/** @brief Enable and Set DAC Channel Waveform Generation.
Enable the digital to analog converter waveform generation as either
@ -310,26 +296,23 @@ pseudo-random noise or triangular wave. These signals are superimposed on
existing output values in the DAC output registers.
@note The DAC trigger must be enabled for this to work.
@param[in] dac the base address of the DAC. @ref dac_reg_base
@param[in] wave enum ::dac_wave. Taken from @ref dac_wave1_en or @ref
dac_wave2_en or a logical OR of one of each of these to set both channels
simultaneously.
*/
void dac_set_waveform_generation(uint32_t dac, enum dac_wave wave)
{
DAC_CR(dac) |= wave;
}
/*---------------------------------------------------------------------------*/
/** @brief Disable DAC Channel Waveform Generation.
Disable a digital to analog converter channel superimposed waveform generation.
@param[in] dac uint32_t the base address of the DAC.
@param[in] channel uint8_t with DAC mask.
@param[in] dac the base address of the DAC. @ref dac_reg_base
@param[in] channel with DAC mask. @ref dac_channel_id
*/
void dac_disable_waveform_generation(uint32_t dac, int channel)
{
switch (channel) {
@ -348,7 +331,6 @@ void dac_disable_waveform_generation(uint32_t dac, int channel)
}
}
/*---------------------------------------------------------------------------*/
/** @brief Set DAC Channel LFSR Mask or Triangle Wave Amplitude.
Sets the digital to analog converter superimposed waveform generation
@ -364,17 +346,15 @@ the signal output.
become read-only.
@note The DAC trigger must be enabled for this to work.
@param[in] dac uint32_t the base address of the DAC.
@param[in] dac the base address of the DAC. @ref dac_reg_base
@param[in] mamp uint8_t. Taken from @ref dac_mamp2 or @ref dac_mamp1 or a
logical OR of one of each of these to set both channels simultaneously.
*/
void dac_set_waveform_characteristics(uint32_t dac, uint8_t mamp)
{
DAC_CR(dac) |= mamp;
}
/*---------------------------------------------------------------------------*/
/** @brief Load DAC Data Register.
Loads the appropriate digital to analog converter data register with 12 or 8 bit
@ -383,12 +363,11 @@ 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 left aligned 12 bit data in bits 4-15
@param[in] dac uint32_t the base address of the DAC.
@param[in] dac the base address of the DAC. @ref dac_reg_base
@param[in] data uint16_t with appropriate alignment.
@param[in] align enum ::dac_align. Alignment and size.
@param[in] channel uint8_t with DAC mask.
*/
void dac_load_data_buffer_single(uint32_t dac, uint16_t data,
enum dac_align align,
int channel)
@ -424,7 +403,6 @@ void dac_load_data_buffer_single(uint32_t dac, uint16_t data,
}
}
/*---------------------------------------------------------------------------*/
/** @brief Load DAC Dual Data Register.
Loads the appropriate digital to analog converter dual data register with 12 or
@ -432,13 +410,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
identically.
@param[in] dac uint32_t the base address of the DAC.
@param[in] dac the base address of the DAC. @ref dac_reg_base
@param[in] data1 uint16_t for channel 1 with appropriate alignment.
@param[in] data2 uint16_t for channel 2 with appropriate alignment.
@param[in] align enum ::dac_align. Right or left aligned, and 8 or
12 bit.
*/
void dac_load_data_buffer_dual(uint32_t dac,
uint16_t data1, uint16_t data2,
enum dac_align align)
@ -460,16 +437,14 @@ void dac_load_data_buffer_dual(uint32_t dac,
}
}
/*---------------------------------------------------------------------------*/
/** @brief Trigger the DAC by a Software Trigger.
If the trigger source is set to be a software trigger, cause a trigger to occur.
The trigger is cleared by hardware after conversion.
@param[in] dac uint32_t the base address of the DAC.
@param[in] channel uint8_t with DAC mask.
@param[in] dac the base address of the DAC. @ref dac_reg_base
@param[in] channel with DAC mask. @ref dac_channel_id
*/
void dac_software_trigger(uint32_t dac, int channel)
{
switch (channel) {

12
lib/stm32/common/dac_common_v1.c

@ -29,7 +29,6 @@ LGPL License Terms @ref lgpl_license
#include <libopencm3/stm32/dac.h>
/*---------------------------------------------------------------------------*/
/** @brief DAC Channel Output Buffer Enable.
Enable a digital to analog converter channel output drive buffer. This is an
@ -37,10 +36,9 @@ optional amplifying buffer that provides additional drive for the output
signal. The buffer is enabled by default after a reset and needs to be
explicitly disabled if required.
@param[in] dac uint32_t the base address of the DAC.
@param[in] channel uint8_t with DAC mask.
@param[in] dac the base address of the DAC. @ref dac_reg_base
@param[in] channel with DAC mask. @ref dac_channel_id
*/
void dac_buffer_enable(uint32_t dac, int channel)
{
switch (channel) {
@ -56,17 +54,15 @@ void dac_buffer_enable(uint32_t dac, int channel)
}
}
/*---------------------------------------------------------------------------*/
/** @brief DAC Channel Output Buffer Disable.
Disable a digital to analog converter channel output drive buffer. Disabling
this will reduce power consumption slightly and will increase the output
impedance of the DAC. The buffers are enabled by default after a reset.
@param[in] dac uint32_t the base address of the DAC.
@param[in] channel uint8_t with DAC mask.
@param[in] dac the base address of the DAC. @ref dac_reg_base
@param[in] channel with DAC mask. @ref dac_channel_id
*/
void dac_buffer_disable(uint32_t dac, int channel)
{
switch (channel) {

32
lib/stm32/common/dac_common_v2.c

@ -29,7 +29,6 @@ LGPL License Terms @ref lgpl_license
#include <libopencm3/stm32/dac.h>
/*---------------------------------------------------------------------------*/
/** @brief DAC Channel Output Buffer Enable.
Enable a digital to analog converter channel output drive buffer. This is an
@ -37,10 +36,9 @@ optional amplifying buffer that provides additional drive for the output
signal. The buffer is enabled by default after a reset and needs to be
explicitly disabled if required.
@param[in] dac uint32_t the base address of the DAC.
@param[in] channel uint8_t with DAC mask.
@param[in] dac the base address of the DAC. @ref dac_reg_base
@param[in] channel with DAC mask. @ref dac_channel_id
*/
void dac_buffer_enable(uint32_t dac, int channel)
{
switch (channel) {
@ -59,17 +57,15 @@ void dac_buffer_enable(uint32_t dac, int channel)
}
}
/*---------------------------------------------------------------------------*/
/** @brief DAC Channel Output Buffer Disable.
Disable a digital to analog converter channel output drive buffer. Disabling
this will reduce power consumption slightly and will increase the output
impedance of the DAC. The buffers are enabled by default after a reset.
@param[in] dac uint32_t the base address of the DAC.
@param[in] channel uint8_t with DAC mask.
@param[in] dac the base address of the DAC. @ref dac_reg_base
@param[in] channel with DAC mask. @ref dac_channel_id
*/
void dac_buffer_disable(uint32_t dac, int channel)
{
switch (channel) {
@ -88,7 +84,6 @@ void dac_buffer_disable(uint32_t dac, int channel)
}
}
/*---------------------------------------------------------------------------*/
/** @brief DAC Channel Output Mode.
Each DAC channel can be configured in Normal mode or Sample and hold mode. The
@ -100,23 +95,20 @@ during application operation.
@note This must be called before enabling the DAC as the settings will then
become read-only.
@param[in] dac uint32_t the base address of the DAC.
@param[in] dac the base address of the DAC. @ref dac_reg_base
@param[in] mamp uint32_t. Taken from @ref dac_mode2_sel or @ref dac_mode1_sel or
a logical OR of one of each of these to set both channels simultaneously.
*/
void dac_set_mode(uint32_t dac, uint32_t mode)
{
DAC_MCR(dac) |= mode;
}
/*---------------------------------------------------------------------------*/
/** @brief Check if DAC channel is ready to receive data.
@param[in] dac uint32_t the base address of the DAC.
@param[in] channel uint8_t with DAC mask.
@param[in] dac the base address of the DAC. @ref dac_reg_base
@param[in] channel with DAC mask. @ref dac_channel_id
*/
bool dac_is_ready(uint32_t dac, int channel)
{
uint32_t mask = 0;
@ -130,28 +122,24 @@ bool dac_is_ready(uint32_t dac, int channel)
return (DAC_SR(dac) & mask) != 0;
}
/*---------------------------------------------------------------------------*/
/** @brief Wait until DAC channel is ready to receive data.
@param[in] dac uint32_t the base address of the DAC.
@param[in] channel uint8_t with DAC mask.
@param[in] dac the base address of the DAC. @ref dac_reg_base
@param[in] channel with DAC mask. @ref dac_channel_id
*/
void dac_wait_on_ready(uint32_t dac, int channel)
{
while (!dac_is_ready(dac, channel));
}
/*---------------------------------------------------------------------------*/
/** @brief High frequency interface mode selection.
If the AHB frequency of the DAC is above 80MHz then this value needs setting
to an appropriate value.
@param[in] dac uint32_t the base address of the DAC.
@param[in] dac the base address of the DAC. @ref dac_reg_base
@param[in] hfsel uint32_t with appropriate HFSEL mask.
*/
void dac_set_high_frequency_mode(uint32_t dac, uint32_t hfsel)
{
uint32_t reg32 = DAC_MCR(dac);

Loading…
Cancel
Save