cpu/sam0_common: enable static voltages#21555
Conversation
DAC_CTRLA_SWRST clears all registers, so it also clears the config of the first DAC line after configuring the second DAC line.
| /* Settings can only be changed when DAC is disabled, reset config */ | ||
| DAC->CTRLA.reg = DAC_CTRLA_SWRST; | ||
| /* Settings can only be changed when DAC is disabled */ | ||
| DAC->CTRLA.reg &= ~DAC_CTRLA_ENABLE; |
There was a problem hiding this comment.
Since there are only two bits, you could also just
| DAC->CTRLA.reg &= ~DAC_CTRLA_ENABLE; | |
| DAC->CTRLA.reg = 0; |
There was a problem hiding this comment.
For some CPUs there are three bits. One of them is the bit to enable operation during standby power mode:
typedef union {
struct {
uint8_t SWRST:1; /*!< bit: 0 Software Reset */
uint8_t ENABLE:1; /*!< bit: 1 Enable */
uint8_t RUNSTDBY:1; /*!< bit: 2 Run in Standby */
uint8_t :5; /*!< bit: 3.. 7 Reserved */
} bit; /*!< Structure used for bit access */
uint8_t reg; /*!< Type used for register access */
} DAC_CTRLA_Type;
There was a problem hiding this comment.
But now you are writing the entire CTRLA reg anyway at the end, you might as well set it all to 0 here 😉
There was a problem hiding this comment.
But 0 feels like a magic number to me and I like the fact that clearing the bit makes the intention clear.
There was a problem hiding this comment.
Well it saves two instructions - but yea, not really that much relevant on init.
Head branch was pushed to by a user without write access
fc2f722 to
e2695eb
Compare
e2695eb to
4e442a8
Compare
4e442a8 to
4259152
Compare
|
check commits thinks your commit message is too long 😕 (>72 characters) |
4259152 to
b157d5c
Compare
Contribution description
The DAC needs to set up a conversion refresh in order to hold a static voltage, so just do it by default. Also add the option to keep the DAC running during standby mode.
Testing procedure
Can be tested with
tests/periph/dac/main.ce.g. on asame54-xpro.Issues/PRs references
Fixes a configuration issue introduced by #21548