M harmony_changelog.md => harmony_changelog.md +1 -0
@@ 18,6 18,7 @@
* Fixed problem with an unresponsive device after playing specific WAV files.
* Fixed USB charging port detection.
* Fixed problem with deleting files during Relaxation session.
+* Fixed occasional crash on system startup.
### Added
M module-bsp/drivers/pwm/DriverPWM.cpp => module-bsp/drivers/pwm/DriverPWM.cpp +16 -20
@@ 1,8 1,7 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2023, 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)
@@ 15,7 14,6 @@
namespace drivers
{
-
std::weak_ptr<DriverPWM> DriverPWM::pwmDrivers[static_cast<std::uint32_t>(PWMInstances::COUNT)]
[static_cast<std::uint32_t>(PWMModules::COUNT)];
@@ 23,30 21,28 @@ namespace drivers
drivers::PWMModules module,
const drivers::DriverPWMParams ¶ms)
{
- {
+ const auto instanceIndex =
+ static_cast<std::uint32_t>(instance) - static_cast<std::uint32_t>(PWMInstances::OFFSET);
+ const auto moduleIndex = static_cast<std::uint32_t>(module);
- cpp_freertos::CriticalSection::Enter();
- std::shared_ptr<DriverPWM> inst =
- pwmDrivers[static_cast<std::uint32_t>(instance)][static_cast<std::uint32_t>(module)].lock();
+ cpp_freertos::CriticalSection::Enter();
+ std::shared_ptr<DriverPWM> inst = pwmDrivers[instanceIndex][moduleIndex].lock();
- if (!inst) {
+ if (!inst) {
#if defined(TARGET_RT1051)
- inst = std::make_shared<RT1051DriverPWM>(instance, module, params);
+ 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;
- }
- else {
- inst->InitNextChannel(params);
- }
-
- cpp_freertos::CriticalSection::Exit();
-
- return inst;
+ pwmDrivers[instanceIndex][moduleIndex] = inst;
}
- }
+ else {
+ inst->InitNextChannel(params);
+ }
+ cpp_freertos::CriticalSection::Exit();
+ return inst;
+ }
} // namespace drivers
M module-bsp/drivers/pwm/DriverPWM.hpp => module-bsp/drivers/pwm/DriverPWM.hpp +4 -3
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
@@ 9,10 9,10 @@
namespace drivers
{
-
enum class PWMInstances
{
- PWM_1 = 1,
+ OFFSET = 1,
+ PWM_1 = OFFSET,
PWM_2,
PWM_3,
PWM_4,
@@ 34,6 34,7 @@ namespace drivers
B,
X
};
+
struct DriverPWMParams
{
PWMChannel channel;