diff options
author | clyne <clyne@bitgloo.com> | 2021-03-21 16:34:21 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-21 16:34:21 -0400 |
commit | 9b926b81ef1e8a4c7266494ae2a1369380e01b35 (patch) | |
tree | 746095fa69eccccdc1c2830fdd0c06bac01848f5 /source/dac.cpp | |
parent | e080a26651f90c88176140d63a74c93c2f4041a2 (diff) | |
parent | a4f1482a8b23d5f761f60d6f3821c84190d89e2f (diff) |
Merge pull request #3 from tcsullivan/stm32h7
Stm32h7
Diffstat (limited to 'source/dac.cpp')
-rw-r--r-- | source/dac.cpp | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/source/dac.cpp b/source/dac.cpp index ed08461..2116dcb 100644 --- a/source/dac.cpp +++ b/source/dac.cpp @@ -9,14 +9,12 @@ * If not, see <https://www.gnu.org/licenses/>. */ -#include "adc.hpp" // ADC::getTimerDivisor #include "dac.hpp" +#include "sclock.hpp" DACDriver *DAC::m_driver[2] = { &DACD1, &DACD2 }; -GPTDriver *DAC::m_timer = &GPTD7; -int DAC::m_timer_user_count = 0; const DACConfig DAC::m_config = { .init = 0, @@ -28,14 +26,7 @@ const DACConversionGroup DAC::m_group_config = { .num_channels = 1, .end_cb = nullptr, .error_cb = nullptr, - .trigger = DAC_TRG(2) -}; - -const GPTConfig DAC::m_timer_config = { - .frequency = 36000000, - .callback = nullptr, - .cr2 = TIM_CR2_MMS_1, /* TRGO */ - .dier = 0 + .trigger = 5 // TIM6_TRGO }; void DAC::begin() @@ -45,17 +36,13 @@ void DAC::begin() dacStart(m_driver[0], &m_config); dacStart(m_driver[1], &m_config); - gptStart(m_timer, &m_timer_config); } void DAC::start(int channel, dacsample_t *buffer, size_t count) { if (channel >= 0 && channel < 2) { dacStartConversion(m_driver[channel], &m_group_config, buffer, count); - - if (m_timer_user_count == 0) - gptStartContinuous(m_timer, ADC::getTimerDivisor()); - m_timer_user_count++; + SClock::start(); } } @@ -63,9 +50,7 @@ void DAC::stop(int channel) { if (channel >= 0 && channel < 2) { dacStopConversion(m_driver[channel]); - - if (--m_timer_user_count == 0) - gptStopTimer(m_timer); + SClock::stop(); } } |