mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-04-24 17:09:39 -04:00
* [EGD-4449] Added fsl drivers for pwm * [EGD-4449] Added sketch of cpp wrapper for PWM driver * [EGD-4449] First configuration of pwm * [EGD-4449] Pin Mux config added * [EGD-4449] Finalized basic configuration * [EGD-4449] Added layer of eink frontlight control * [EGD-4449] Added to worker event * [EGD-4449] Added getter for brightness level * [EGD-4449] Added mutex and clamp * [EGD-4449] First working PWM driver configuration * [EGD-4449] More minimalistic interface * [EGD-4449] Cleaning and refactoring * [EGD-4449] Connected to message system * [EGD-4449] Added gamma correction * [EGD-4449] PWM Start/Stop logic configuration * [EGD-4449] Linux target file added * [EGD-4449] Minor refactorings * [EGD-4449] Branch style fix * [EGD-4449] PR comments pt 1 * [EGD-4449] PR comments pt 2 * [EGD-4449] branch style fix * [EGD-4449] PR pt3 - messages change * [EGD-4449] Minor change * [EGD-4449] BrightnessLevel type added * [EGD-4449] Moved processing to EventManager * [EGD-4449] 1-5 levels to percentage * [EGD-4449] Fix style Co-authored-by: Wojtek Rzepecki <wojtek.rzepecki@mudita.com>
50 lines
1.4 KiB
C++
50 lines
1.4 KiB
C++
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
|
|
|
#include "DriverPWM.hpp"
|
|
|
|
#include "critical.hpp"
|
|
|
|
#if defined(TARGET_RT1051)
|
|
#include "board/rt1051/drivers/RT1051DriverPWM.hpp"
|
|
#elif defined(TARGET_Linux)
|
|
|
|
#else
|
|
#error "Unsupported target"
|
|
#endif
|
|
|
|
namespace drivers
|
|
{
|
|
|
|
std::weak_ptr<DriverPWM> DriverPWM::pwmDrivers[static_cast<std::uint32_t>(PWMInstances::COUNT)]
|
|
[static_cast<std::uint32_t>(PWMModules::COUNT)];
|
|
|
|
std::shared_ptr<DriverPWM> DriverPWM::Create(drivers::PWMInstances instance,
|
|
drivers::PWMModules module,
|
|
const drivers::DriverPWMParams ¶ms)
|
|
{
|
|
{
|
|
|
|
cpp_freertos::CriticalSection::Enter();
|
|
std::shared_ptr<DriverPWM> inst =
|
|
pwmDrivers[static_cast<std::uint32_t>(instance)][static_cast<std::uint32_t>(module)].lock();
|
|
|
|
if (!inst) {
|
|
#if defined(TARGET_RT1051)
|
|
inst = std::make_shared<RT1051DriverPWM>(instance, module, params);
|
|
#elif defined(TARGET_Linux)
|
|
#else
|
|
#error "Unsupported target"
|
|
#endif
|
|
|
|
pwmDrivers[static_cast<std::uint32_t>(instance)][static_cast<std::uint32_t>(module)] = inst;
|
|
}
|
|
|
|
cpp_freertos::CriticalSection::Exit();
|
|
|
|
return inst;
|
|
}
|
|
}
|
|
|
|
} // namespace drivers
|