From 44e1993aba085615d0a0a04067ffa1e42bfc403c Mon Sep 17 00:00:00 2001 From: Yann Locatelli Date: Fri, 1 Mar 2024 17:10:00 +0100 Subject: [PATCH 1/2] :sparkles: (dac): Add CoreDAC Co-Authored-By: Maxime Blanc <66126094+aermanio@users.noreply.github.com> Co-Authored-By: SamHadjes <48731907+samhadjes@users.noreply.github.com> --- config/mbed_app.json | 4 + drivers/CoreDAC/CMakeLists.txt | 1 + drivers/CoreDAC/include/CoreDAC.h | 49 ++++++++ drivers/CoreDAC/source/CoreDAC.cpp | 116 +++++++++++++++++++ drivers/CoreDAC/source/HAL_IRQHandlers.cpp | 9 +- drivers/CoreSTM32Hal/include/CoreSTM32Hal.h | 14 +++ drivers/CoreSTM32Hal/source/CoreSTM32Hal.cpp | 48 ++++++++ include/interface/drivers/DAC.h | 25 ++++ include/interface/drivers/STM32Hal.h | 14 +++ tests/unit/headers/mbed/mbed_config.h | 1 + tests/unit/mocks/mocks/leka/CoreSTM32Hal.h | 15 +++ 11 files changed, 295 insertions(+), 1 deletion(-) create mode 100644 drivers/CoreDAC/include/CoreDAC.h create mode 100644 drivers/CoreDAC/source/CoreDAC.cpp create mode 100644 include/interface/drivers/DAC.h diff --git a/config/mbed_app.json b/config/mbed_app.json index 8e56ae60fc..5a0361614c 100644 --- a/config/mbed_app.json +++ b/config/mbed_app.json @@ -8,6 +8,10 @@ "USE_HAL_TIM_REGISTER_CALLBACKS": { "macro_name": "USE_HAL_TIM_REGISTER_CALLBACKS", "value": "1U" + }, + "USE_HAL_DAC_REGISTER_CALLBACKS": { + "macro_name": "USE_HAL_DAC_REGISTER_CALLBACKS", + "value": "1U" } }, "target_overrides": { diff --git a/drivers/CoreDAC/CMakeLists.txt b/drivers/CoreDAC/CMakeLists.txt index c50cf4348a..c2e26193d8 100644 --- a/drivers/CoreDAC/CMakeLists.txt +++ b/drivers/CoreDAC/CMakeLists.txt @@ -12,6 +12,7 @@ target_include_directories(CoreDAC target_sources(CoreDAC PRIVATE source/CoreSTM32HalBasicTimer.cpp + source/CoreDAC.cpp ) if(NOT(${CMAKE_PROJECT_NAME} STREQUAL "LekaOSUnitTests")) diff --git a/drivers/CoreDAC/include/CoreDAC.h b/drivers/CoreDAC/include/CoreDAC.h new file mode 100644 index 0000000000..5b00409bfd --- /dev/null +++ b/drivers/CoreDAC/include/CoreDAC.h @@ -0,0 +1,49 @@ +// Leka - LekaOS +// Copyright 2024 APF France handicap +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include +#include +#include + +#include "interface/drivers/DAC.h" +#include "interface/drivers/STM32Hal.h" +#include "interface/drivers/STM32HalBasicTimer.h" + +namespace leka { + +class CoreDAC : public interface::DACBase +{ + public: + CoreDAC(interface::STM32Hal &hal, interface::STM32HalBasicTimer &hal_timer); + + [[nodiscard]] auto getHandle() -> DAC_HandleTypeDef & final; + + void initialize() final; + void terminate() final; + + void registerDataToPlay(std::span data); + void registerDMACallbacks(std::function const &on_half_transfer, + std::function const &on_complete_transfer); + + void start() final; + void stop() final; + + private: + void _registerMspCallbacks(); + void _initializeDMA(); + + interface::STM32Hal &_hal; + interface::STM32HalBasicTimer &_hal_timer; + + DAC_HandleTypeDef _hdac {}; + DMA_HandleTypeDef _hdma {}; + + std::span _data; + std::function _on_half_transfer {}; + std::function _on_complete_transfer {}; +}; + +} // namespace leka diff --git a/drivers/CoreDAC/source/CoreDAC.cpp b/drivers/CoreDAC/source/CoreDAC.cpp new file mode 100644 index 0000000000..c3a28f899e --- /dev/null +++ b/drivers/CoreDAC/source/CoreDAC.cpp @@ -0,0 +1,116 @@ +// Leka - LekaOS +// Copyright 2024 APF France handicap +// SPDX-License-Identifier: Apache-2.0 + +#include "CoreDAC.h" + +using namespace leka; + +CoreDAC::CoreDAC(interface::STM32Hal &hal, interface::STM32HalBasicTimer &hal_timer) : _hal(hal), _hal_timer(hal_timer) +{ + _hdac.Instance = DAC; +} + +auto CoreDAC::getHandle() -> DAC_HandleTypeDef & +{ + return _hdac; +} + +void CoreDAC::initialize() +{ + _registerMspCallbacks(); + + _hal.HAL_DAC_Init(&_hdac); + + DAC_ChannelConfTypeDef config = {}; + config.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE; + _hal_timer.linkDACTimer(&config); + _hal.HAL_DAC_ConfigChannel(&_hdac, &config, DAC_CHANNEL_1); + + static const auto &self = *this; + _hal.HAL_DAC_RegisterCallback(&_hdac, HAL_DAC_CH1_HALF_COMPLETE_CB_ID, + []([[maybe_unused]] DAC_HandleTypeDef *hdac) { + if (self._on_half_transfer != nullptr) { + self._on_half_transfer(); + } + }); + _hal.HAL_DAC_RegisterCallback(&_hdac, HAL_DAC_CH1_COMPLETE_CB_ID, []([[maybe_unused]] DAC_HandleTypeDef *hdac) { + if (self._on_complete_transfer != nullptr) { + self._on_complete_transfer(); + } + }); +} + +void CoreDAC::terminate() +{ + _hal.HAL_DAC_DeInit(&_hdac); +} + +void CoreDAC::registerDataToPlay(std::span data) +{ + _data = data; +} + +void CoreDAC::registerDMACallbacks(std::function const &on_half_transfer, + std::function const &on_complete_transfer) +{ + _on_half_transfer = on_half_transfer; + _on_complete_transfer = on_complete_transfer; +} + +void CoreDAC::start() +{ + _hal_timer.start(); + _hal.HAL_DAC_Start_DMA(&_hdac, DAC_CHANNEL_1, reinterpret_cast(_data.data()), _data.size(), + DAC_ALIGN_12B_R); +} + +void CoreDAC::stop() +{ + _hal.HAL_DAC_Stop_DMA(&_hdac, DAC_CHANNEL_1); +} + +void CoreDAC::_registerMspCallbacks() +{ + static auto &self = *this; + + _hal.HAL_DAC_RegisterCallback(&_hdac, HAL_DAC_MSPINIT_CB_ID, []([[maybe_unused]] DAC_HandleTypeDef *hdac) { + __HAL_LINKDMA(&self._hdac, DMA_Handle1, self._hdma); + self._initializeDMA(); + + self._hal.HAL_RCC_DAC_CLK_ENABLE(); + }); + + _hal.HAL_DAC_RegisterCallback(&_hdac, HAL_DAC_MSPDEINIT_CB_ID, []([[maybe_unused]] DAC_HandleTypeDef *hdac) { + self._hal.HAL_DMA_DeInit(&self._hdma); + + self._hal.HAL_RCC_DAC_CLK_DISABLE(); + }); +} + +void CoreDAC::_initializeDMA() +{ + _hal.HAL_RCC_DMA1_CLK_ENABLE(); + + _hal.HAL_NVIC_SetPriority(DMA1_Stream5_IRQn, 3, 0); + _hal.HAL_NVIC_EnableIRQ(DMA1_Stream5_IRQn); + + _hdma.Instance = DMA1_Stream5; // DMA1_Stream5 is the only DMA channel for DAC + + _hdma.Init.Channel = DMA_CHANNEL_7; + _hdma.Init.Direction = DMA_MEMORY_TO_PERIPH; + _hdma.Init.PeriphInc = DMA_PINC_DISABLE; + _hdma.Init.MemInc = DMA_MINC_ENABLE; + _hdma.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; + _hdma.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; + _hdma.Init.Mode = DMA_CIRCULAR; + _hdma.Init.Priority = DMA_PRIORITY_LOW; + _hdma.Init.FIFOMode = DMA_FIFOMODE_ENABLE; + _hdma.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_HALFFULL; + _hdma.Init.MemBurst = DMA_MBURST_SINGLE; + // Single mem burst is more ressource consuming than 4 burst or more + // However the buffer apparently needs to be of a size multiple of the burst mode chosen + _hdma.Init.PeriphBurst = DMA_PBURST_SINGLE; + + _hal.HAL_DMA_Init(&_hdma); +} diff --git a/drivers/CoreDAC/source/HAL_IRQHandlers.cpp b/drivers/CoreDAC/source/HAL_IRQHandlers.cpp index a2e695b99f..a4aca95cab 100644 --- a/drivers/CoreDAC/source/HAL_IRQHandlers.cpp +++ b/drivers/CoreDAC/source/HAL_IRQHandlers.cpp @@ -1,10 +1,12 @@ +#include "CoreDAC.h" #include "CoreSTM32HalBasicTimer.h" extern "C" { namespace audio::internal { extern leka::CoreSTM32HalBasicTimer hal_timer; -} + extern leka::CoreDAC coredac; +} // namespace audio::internal void TIM6_DAC_IRQHandler() { @@ -16,4 +18,9 @@ void TIM7_DAC_IRQHandler() HAL_TIM_IRQHandler(&audio::internal::hal_timer.getHandle()); } +void DMA1_Stream5_IRQHandler() +{ + HAL_DMA_IRQHandler(audio::internal::coredac.getHandle().DMA_Handle1); +} + } // extern "C" diff --git a/drivers/CoreSTM32Hal/include/CoreSTM32Hal.h b/drivers/CoreSTM32Hal/include/CoreSTM32Hal.h index 0d552636b5..2453a066f8 100644 --- a/drivers/CoreSTM32Hal/include/CoreSTM32Hal.h +++ b/drivers/CoreSTM32Hal/include/CoreSTM32Hal.h @@ -29,8 +29,12 @@ class CoreSTM32Hal : public interface::STM32Hal void HAL_RCC_FMC_CLK_ENABLE() final; + void HAL_RCC_DMA1_CLK_ENABLE() final; void HAL_RCC_DMA2_CLK_ENABLE() final; + void HAL_RCC_DAC_CLK_ENABLE() final; + void HAL_RCC_DAC_CLK_DISABLE() final; + void HAL_RCC_JPEG_CLK_ENABLE() final; void HAL_RCC_JPEG_FORCE_RESET() final; void HAL_RCC_JPEG_RELEASE_RESET() final; @@ -118,6 +122,16 @@ class CoreSTM32Hal : public interface::STM32Hal auto HAL_TIM_Base_Start_IT(TIM_HandleTypeDef *htim) -> HAL_StatusTypeDef final; auto HAL_TIM_Base_Stop_IT(TIM_HandleTypeDef *htim) -> HAL_StatusTypeDef final; auto HAL_TIM_Base_DeInit(TIM_HandleTypeDef *htim) -> HAL_StatusTypeDef final; + + auto HAL_DAC_Init(DAC_HandleTypeDef *hdac) -> HAL_StatusTypeDef final; + auto HAL_DAC_ConfigChannel(DAC_HandleTypeDef *hdac, DAC_ChannelConfTypeDef *sConfig, uint32_t Channel) + -> HAL_StatusTypeDef final; + auto HAL_DAC_RegisterCallback(DAC_HandleTypeDef *hdac, HAL_DAC_CallbackIDTypeDef CallbackID, + pDAC_CallbackTypeDef pCallback) -> HAL_StatusTypeDef final; + auto HAL_DAC_Start_DMA(DAC_HandleTypeDef *hdac, uint32_t Channel, uint32_t *pData, uint32_t Length, + uint32_t Alignment) -> HAL_StatusTypeDef final; + auto HAL_DAC_Stop_DMA(DAC_HandleTypeDef *hdac, uint32_t Channel) -> HAL_StatusTypeDef final; + auto HAL_DAC_DeInit(DAC_HandleTypeDef *hdac) -> HAL_StatusTypeDef final; }; } // namespace leka diff --git a/drivers/CoreSTM32Hal/source/CoreSTM32Hal.cpp b/drivers/CoreSTM32Hal/source/CoreSTM32Hal.cpp index 50a925207e..2beb724e2a 100644 --- a/drivers/CoreSTM32Hal/source/CoreSTM32Hal.cpp +++ b/drivers/CoreSTM32Hal/source/CoreSTM32Hal.cpp @@ -66,11 +66,26 @@ void CoreSTM32Hal::HAL_RCC_FMC_CLK_ENABLE() __HAL_RCC_FMC_CLK_ENABLE(); // NOLINT } +void CoreSTM32Hal::HAL_RCC_DMA1_CLK_ENABLE() +{ + __HAL_RCC_DMA1_CLK_ENABLE(); // NOLINT +} + void CoreSTM32Hal::HAL_RCC_DMA2_CLK_ENABLE() { __HAL_RCC_DMA2_CLK_ENABLE(); // NOLINT } +void CoreSTM32Hal::HAL_RCC_DAC_CLK_ENABLE() +{ + __HAL_RCC_DAC_CLK_ENABLE(); // NOLINT +} + +void CoreSTM32Hal::HAL_RCC_DAC_CLK_DISABLE() +{ + __HAL_RCC_DAC_CLK_DISABLE(); // NOLINT +} + void CoreSTM32Hal::HAL_RCC_JPEG_CLK_ENABLE() { __HAL_RCC_JPEG_CLK_ENABLE(); // NOLINT @@ -363,4 +378,37 @@ auto CoreSTM32Hal::HAL_TIM_Base_DeInit(TIM_HandleTypeDef *htim) -> HAL_StatusTyp return ::HAL_TIM_Base_DeInit(htim); } +auto CoreSTM32Hal::HAL_DAC_Init(DAC_HandleTypeDef *hdac) -> HAL_StatusTypeDef +{ + return ::HAL_DAC_Init(hdac); +} + +auto CoreSTM32Hal::HAL_DAC_ConfigChannel(DAC_HandleTypeDef *hdac, DAC_ChannelConfTypeDef *sConfig, uint32_t Channel) + -> HAL_StatusTypeDef +{ + return ::HAL_DAC_ConfigChannel(hdac, sConfig, Channel); +} + +auto CoreSTM32Hal::HAL_DAC_RegisterCallback(DAC_HandleTypeDef *hdac, HAL_DAC_CallbackIDTypeDef CallbackID, + pDAC_CallbackTypeDef pCallback) -> HAL_StatusTypeDef +{ + return ::HAL_DAC_RegisterCallback(hdac, CallbackID, pCallback); +} + +auto CoreSTM32Hal::HAL_DAC_Start_DMA(DAC_HandleTypeDef *hdac, uint32_t Channel, uint32_t *pData, uint32_t Length, + uint32_t Alignment) -> HAL_StatusTypeDef +{ + return ::HAL_DAC_Start_DMA(hdac, Channel, pData, Length, Alignment); +} + +auto CoreSTM32Hal::HAL_DAC_Stop_DMA(DAC_HandleTypeDef *hdac, uint32_t Channel) -> HAL_StatusTypeDef +{ + return ::HAL_DAC_Stop_DMA(hdac, Channel); +} + +auto CoreSTM32Hal::HAL_DAC_DeInit(DAC_HandleTypeDef *hdac) -> HAL_StatusTypeDef +{ + return ::HAL_DAC_DeInit(hdac); +} + } // namespace leka diff --git a/include/interface/drivers/DAC.h b/include/interface/drivers/DAC.h new file mode 100644 index 0000000000..a1fdfe2968 --- /dev/null +++ b/include/interface/drivers/DAC.h @@ -0,0 +1,25 @@ +// Leka - LekaOS +// Copyright 2024 APF France handicap +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "interface/drivers/STM32Hal.h" + +namespace leka::interface { + +class DACBase +{ + public: + virtual ~DACBase() = default; + + [[nodiscard]] virtual auto getHandle() -> DAC_HandleTypeDef & = 0; + + virtual void initialize() = 0; + virtual void terminate() = 0; + + virtual void start() = 0; + virtual void stop() = 0; +}; + +} // namespace leka::interface diff --git a/include/interface/drivers/STM32Hal.h b/include/interface/drivers/STM32Hal.h index 79417cc996..4b5f56ad86 100644 --- a/include/interface/drivers/STM32Hal.h +++ b/include/interface/drivers/STM32Hal.h @@ -29,8 +29,12 @@ class STM32Hal virtual void HAL_RCC_FMC_CLK_ENABLE() = 0; + virtual void HAL_RCC_DMA1_CLK_ENABLE() = 0; virtual void HAL_RCC_DMA2_CLK_ENABLE() = 0; + virtual void HAL_RCC_DAC_CLK_ENABLE() = 0; + virtual void HAL_RCC_DAC_CLK_DISABLE() = 0; + virtual void HAL_RCC_JPEG_CLK_ENABLE() = 0; virtual void HAL_RCC_JPEG_FORCE_RESET() = 0; virtual void HAL_RCC_JPEG_RELEASE_RESET() = 0; @@ -121,6 +125,16 @@ class STM32Hal virtual auto HAL_TIM_Base_Start_IT(TIM_HandleTypeDef *htim) -> HAL_StatusTypeDef = 0; virtual auto HAL_TIM_Base_Stop_IT(TIM_HandleTypeDef *htim) -> HAL_StatusTypeDef = 0; virtual auto HAL_TIM_Base_DeInit(TIM_HandleTypeDef *htim) -> HAL_StatusTypeDef = 0; + + virtual auto HAL_DAC_Init(DAC_HandleTypeDef *hdac) -> HAL_StatusTypeDef = 0; + virtual auto HAL_DAC_ConfigChannel(DAC_HandleTypeDef *hdac, DAC_ChannelConfTypeDef *sConfig, uint32_t Channel) + -> HAL_StatusTypeDef = 0; + virtual auto HAL_DAC_RegisterCallback(DAC_HandleTypeDef *hdac, HAL_DAC_CallbackIDTypeDef CallbackID, + pDAC_CallbackTypeDef pCallback) -> HAL_StatusTypeDef = 0; + virtual auto HAL_DAC_Start_DMA(DAC_HandleTypeDef *hdac, uint32_t Channel, uint32_t *pData, uint32_t Length, + uint32_t Alignment) -> HAL_StatusTypeDef = 0; + virtual auto HAL_DAC_Stop_DMA(DAC_HandleTypeDef *hdac, uint32_t Channel) -> HAL_StatusTypeDef = 0; + virtual auto HAL_DAC_DeInit(DAC_HandleTypeDef *hdac) -> HAL_StatusTypeDef = 0; }; } // namespace leka::interface diff --git a/tests/unit/headers/mbed/mbed_config.h b/tests/unit/headers/mbed/mbed_config.h index 5ff7967da5..5b057607c0 100644 --- a/tests/unit/headers/mbed/mbed_config.h +++ b/tests/unit/headers/mbed/mbed_config.h @@ -289,6 +289,7 @@ #define TARGET_LSE_DRIVE_LOAD_LEVEL RCC_LSEDRIVE_LOW // set by target:MCU_STM32F7 #define USE_HAL_JPEG_REGISTER_CALLBACKS 1U // set by application #define USE_HAL_TIM_REGISTER_CALLBACKS 1U // set by application +#define USE_HAL_DAC_REGISTER_CALLBACKS 1U // set by application // Macros #define WSF_MS_PER_TICK 1 // defined by library:cordio #define _RTE_ // defined by library:rtos diff --git a/tests/unit/mocks/mocks/leka/CoreSTM32Hal.h b/tests/unit/mocks/mocks/leka/CoreSTM32Hal.h index d72b263f4d..5751098106 100644 --- a/tests/unit/mocks/mocks/leka/CoreSTM32Hal.h +++ b/tests/unit/mocks/mocks/leka/CoreSTM32Hal.h @@ -24,7 +24,10 @@ class CoreSTM32Hal : public interface::STM32Hal MOCK_METHOD(void, HAL_RCC_TIM7_CLK_ENABLE, (), (override)); MOCK_METHOD(void, HAL_RCC_TIM7_CLK_DISABLE, (), (override)); MOCK_METHOD(void, HAL_RCC_FMC_CLK_ENABLE, (), (override)); + MOCK_METHOD(void, HAL_RCC_DMA1_CLK_ENABLE, (), (override)); MOCK_METHOD(void, HAL_RCC_DMA2_CLK_ENABLE, (), (override)); + MOCK_METHOD(void, HAL_RCC_DAC_CLK_ENABLE, (), (override)); + MOCK_METHOD(void, HAL_RCC_DAC_CLK_DISABLE, (), (override)); MOCK_METHOD(void, HAL_RCC_JPEG_CLK_ENABLE, (), (override)); MOCK_METHOD(void, HAL_RCC_JPEG_FORCE_RESET, (), (override)); MOCK_METHOD(void, HAL_RCC_JPEG_RELEASE_RESET, (), (override)); @@ -125,6 +128,18 @@ class CoreSTM32Hal : public interface::STM32Hal MOCK_METHOD(HAL_StatusTypeDef, HAL_TIM_Base_Start_IT, (TIM_HandleTypeDef * htim), (override)); MOCK_METHOD(HAL_StatusTypeDef, HAL_TIM_Base_Stop_IT, (TIM_HandleTypeDef * htim), (override)); MOCK_METHOD(HAL_StatusTypeDef, HAL_TIM_Base_DeInit, (TIM_HandleTypeDef * htim), (override)); + + MOCK_METHOD(HAL_StatusTypeDef, HAL_DAC_Init, (DAC_HandleTypeDef * hdac), (override)); + MOCK_METHOD(HAL_StatusTypeDef, HAL_DAC_ConfigChannel, + (DAC_HandleTypeDef * hdac, DAC_ChannelConfTypeDef *sConfig, uint32_t Channel), (override)); + MOCK_METHOD(HAL_StatusTypeDef, HAL_DAC_RegisterCallback, + (DAC_HandleTypeDef * hdac, HAL_DAC_CallbackIDTypeDef CallbackID, pDAC_CallbackTypeDef pCallback), + (override)); + MOCK_METHOD(HAL_StatusTypeDef, HAL_DAC_Start_DMA, + (DAC_HandleTypeDef * hdac, uint32_t Channel, uint32_t *pData, uint32_t Length, uint32_t Alignment), + (override)); + MOCK_METHOD(HAL_StatusTypeDef, HAL_DAC_Stop_DMA, (DAC_HandleTypeDef * hdac, uint32_t Channel), (override)); + MOCK_METHOD(HAL_StatusTypeDef, HAL_DAC_DeInit, (DAC_HandleTypeDef * hdac), (override)); }; } // namespace leka::mock From 3096fdac0f7d9884e9accfcee9a06a493155e189 Mon Sep 17 00:00:00 2001 From: Yann Locatelli Date: Thu, 14 Mar 2024 19:32:11 +0100 Subject: [PATCH 2/2] :art: (dac): Add and use interface::DACDMA for DMA usage --- drivers/CoreDAC/include/CoreDAC.h | 6 +++--- include/interface/drivers/DAC.h | 13 +++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/CoreDAC/include/CoreDAC.h b/drivers/CoreDAC/include/CoreDAC.h index 5b00409bfd..5b41fcced6 100644 --- a/drivers/CoreDAC/include/CoreDAC.h +++ b/drivers/CoreDAC/include/CoreDAC.h @@ -14,7 +14,7 @@ namespace leka { -class CoreDAC : public interface::DACBase +class CoreDAC : public interface::DACDMA { public: CoreDAC(interface::STM32Hal &hal, interface::STM32HalBasicTimer &hal_timer); @@ -24,9 +24,9 @@ class CoreDAC : public interface::DACBase void initialize() final; void terminate() final; - void registerDataToPlay(std::span data); + void registerDataToPlay(std::span data) final; void registerDMACallbacks(std::function const &on_half_transfer, - std::function const &on_complete_transfer); + std::function const &on_complete_transfer) final; void start() final; void stop() final; diff --git a/include/interface/drivers/DAC.h b/include/interface/drivers/DAC.h index a1fdfe2968..6ec3464e49 100644 --- a/include/interface/drivers/DAC.h +++ b/include/interface/drivers/DAC.h @@ -4,6 +4,9 @@ #pragma once +#include +#include + #include "interface/drivers/STM32Hal.h" namespace leka::interface { @@ -22,4 +25,14 @@ class DACBase virtual void stop() = 0; }; +class DACDMA : public DACBase +{ + public: + virtual ~DACDMA() = default; + + virtual void registerDataToPlay(std::span data) = 0; + virtual void registerDMACallbacks(std::function const &on_half_transfer, + std::function const &on_complete_transfer) = 0; +}; + } // namespace leka::interface