diff options
author | Clyne Sullivan <clyne@clyne-lp.lan> | 2021-07-31 10:47:00 -0400 |
---|---|---|
committer | Clyne Sullivan <clyne@clyne-lp.lan> | 2021-07-31 10:47:00 -0400 |
commit | 123cc4c756cc8a22f66351ab65595c5a20e53e27 (patch) | |
tree | d12ee8cb3d91e08c422e5bd4b5cb01d7dd622b19 /source/dac.cpp | |
parent | d24ed15843c328983f9ed20283f89624e8574b9f (diff) |
reorganized source, wip
Diffstat (limited to 'source/dac.cpp')
-rw-r--r-- | source/dac.cpp | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/source/dac.cpp b/source/dac.cpp deleted file mode 100644 index 1ff8867..0000000 --- a/source/dac.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/** - * @file dac.cpp - * @brief Manages signal creation using the DAC. - * - * Copyright (C) 2021 Clyne Sullivan - * - * Distributed under the GNU GPL v3 or later. You should have received a copy of - * the GNU General Public License along with this program. - * If not, see <https://www.gnu.org/licenses/>. - */ - -#include "dac.hpp" -#include "sclock.hpp" - -DACDriver *DAC::m_driver[2] = { - &DACD1, &DACD2 -}; - -const DACConfig DAC::m_config = { - .init = 2048, - .datamode = DAC_DHRM_12BIT_RIGHT, - .cr = 0 -}; - -static int dacIsDone = -1; -static void dacEndCallback(DACDriver *dacd) -{ - if (dacd == &DACD2) - dacIsDone = dacIsBufferComplete(dacd) ? 1 : 0; -} - -const DACConversionGroup DAC::m_group_config = { - .num_channels = 1, - .end_cb = dacEndCallback, - .error_cb = nullptr, -#if defined(TARGET_PLATFORM_H7) - .trigger = 5 // TIM6_TRGO -#elif defined(TARGET_PLATFORM_L4) - .trigger = 0 // TIM6_TRGO -#endif -}; - -void DAC::begin() -{ - palSetPadMode(GPIOA, 4, PAL_STM32_MODE_ANALOG); - palSetPadMode(GPIOA, 5, PAL_STM32_MODE_ANALOG); - - dacStart(m_driver[0], &m_config); - dacStart(m_driver[1], &m_config); -} - -void DAC::start(int channel, dacsample_t *buffer, size_t count) -{ - if (channel >= 0 && channel < 2) { - if (channel == 1) - dacIsDone = -1; - dacStartConversion(m_driver[channel], &m_group_config, buffer, count); - SClock::start(); - } -} - -int DAC::sigGenWantsMore() -{ - return dacIsDone; -} - -void DAC::stop(int channel) -{ - if (channel >= 0 && channel < 2) { - dacStopConversion(m_driver[channel]); - SClock::stop(); - } -} - |