M module-audio/board/rt1051/bellpx/BellPxAudioCodec.cpp => module-audio/board/rt1051/bellpx/BellPxAudioCodec.cpp +2 -3
@@ 134,7 134,7 @@ namespace audio
reinterpret_cast<edma_handle_t *>(audioCfg->rxDMAHandle->GetHandle()));
/* I2S mode configurations */
SAI_GetClassicI2SConfig(
- &saiConfig, static_cast<sai_word_width_t>(saiInFormat.bitWidth), saiInFormat.stereo, 0U);
+ &saiConfig, static_cast<sai_word_width_t>(saiInFormat.bitWidth), saiInFormat.stereo, kSAI_Channel0Mask);
saiConfig.syncMode = kSAI_ModeSync;
saiConfig.masterSlave = kSAI_Slave;
SAI_TransferRxSetConfigEDMA(BELL_AUDIOCODEC_SAIx, &txHandle, &saiConfig);
@@ 159,7 159,7 @@ namespace audio
reinterpret_cast<edma_handle_t *>(audioCfg->txDMAHandle->GetHandle()));
/* I2S mode configurations */
SAI_GetClassicI2SConfig(
- &saiConfig, static_cast<sai_word_width_t>(saiOutFormat.bitWidth), saiOutFormat.stereo, 0U);
+ &saiConfig, static_cast<sai_word_width_t>(saiOutFormat.bitWidth), saiOutFormat.stereo, kSAI_Channel0Mask);
SAI_TransferTxSetConfigEDMA(BELL_AUDIOCODEC_SAIx, &txHandle, &saiConfig);
const auto channelNumbers = saiOutFormat.stereo == kSAI_Stereo ? 2U : 1U;
/* set bit clock divider */
@@ 231,5 231,4 @@ namespace audio
auto self = static_cast<BellPxAudioCodec *>(userData);
self->onDataSend();
}
-
} // namespace audio
M module-bsp/board/rt1051/bellpx/audio.cpp => module-bsp/board/rt1051/bellpx/audio.cpp +5 -5
@@ 1,9 1,9 @@
-// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "audio.hpp"
-
#include "board/BoardDefinitions.hpp"
+#include <cstring>
extern "C"
{
@@ 63,9 63,9 @@ void bsp::audio::init(const std::uint32_t sampleRate)
IOMUXC_GPR->GPR1 |= BELL_AUDIOCODEC_SAIx_MCLK_MASK;
audioConfig.txDMAHandle =
- audioConfig.dma->CreateHandle(static_cast<uint32_t>(BoardDefinitions::AUDIOCODEC_TX_DMA_CHANNEL));
+ audioConfig.dma->CreateHandle(static_cast<std::uint32_t>(BoardDefinitions::AUDIOCODEC_TX_DMA_CHANNEL));
audioConfig.rxDMAHandle =
- audioConfig.dma->CreateHandle(static_cast<uint32_t>(BoardDefinitions::AUDIOCODEC_RX_DMA_CHANNEL));
+ audioConfig.dma->CreateHandle(static_cast<std::uint32_t>(BoardDefinitions::AUDIOCODEC_RX_DMA_CHANNEL));
audioConfig.dmamux->Enable(static_cast<uint32_t>(BoardDefinitions::AUDIOCODEC_TX_DMA_CHANNEL),
BSP_AUDIOCODEC_SAIx_DMA_TX_SOURCE);
audioConfig.dmamux->Enable(static_cast<uint32_t>(BoardDefinitions::AUDIOCODEC_RX_DMA_CHANNEL),
@@ 78,7 78,7 @@ void bsp::audio::init(const std::uint32_t sampleRate)
void bsp::audio::deinit()
{
- memset(&audioConfig.config, 0, sizeof(audioConfig.config));
+ std::memset(&audioConfig.config, 0, sizeof(audioConfig.config));
SAI_Deinit(BELL_AUDIOCODEC_SAIx);
if (audioConfig.dmamux) {
audioConfig.dmamux->Disable(static_cast<uint32_t>(BoardDefinitions::AUDIOCODEC_TX_DMA_CHANNEL));
M module-bsp/board/rt1051/common/fsl_drivers/fsl_snvs_hp.c => module-bsp/board/rt1051/common/fsl_drivers/fsl_snvs_hp.c +0 -3
@@ 121,7 121,6 @@ static uint32_t SNVS_HP_ConvertDatetimeToSeconds(const snvs_hp_rtc_datetime_t *d
assert(datetime != NULL);
/* Number of days from begin of the non Leap-year*/
- /* Number of days from begin of the non Leap-year*/
uint16_t monthDays[] = {0U, 0U, 31U, 59U, 90U, 120U, 151U, 181U, 212U, 243U, 273U, 304U, 334U};
uint32_t seconds;
@@ 568,8 567,6 @@ void SNVS_HP_SetLocks(SNVS_Type *base)
*/
status_t SNVS_HP_RTC_SetAlarmSeconds(SNVS_Type *base, uint32_t alarmSeconds)
{
- assert(alarmTime != NULL);
-
uint32_t currSeconds = 0U;
uint32_t tmp = base->HPCR;
M module-services/service-desktop/WorkerDesktop.cpp => module-services/service-desktop/WorkerDesktop.cpp +1 -1
@@ 59,7 59,7 @@ bool WorkerDesktop::init(std::list<sys::WorkerQueueInfo> queues)
return initialized;
}
-void WorkerDesktop::closeWorker(void)
+void WorkerDesktop::closeWorker()
{
if (!initialized) {
return;
M module-sys/Service/Worker.cpp => module-sys/Service/Worker.cpp +11 -11
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include <Service/Worker.hpp>
@@ 18,7 18,7 @@ namespace sys
void Worker::taskAdapter(void *taskParam)
{
- Worker *worker = static_cast<Worker *>(taskParam);
+ auto worker = static_cast<Worker *>(taskParam);
worker->setState(State::Running);
worker->task();
}
@@ 100,7 100,7 @@ namespace sys
name.append("_w" + std::to_string(id));
}
- size_t Worker::addQueue(const std::string &qName, UBaseType_t maxItems, UBaseType_t itemSize)
+ std::size_t Worker::addQueue(const std::string &qName, UBaseType_t maxItems, UBaseType_t itemSize)
{
auto idx = queues.size();
queues.push_back(std::make_shared<WorkerQueue>(qName, maxItems, itemSize));
@@ 157,8 157,8 @@ namespace sys
};
// iterate over all user queues and add them to set
- for (std::uint32_t i = 0; i < queues.size(); ++i) {
- if (xQueueAddToSet(queues[i]->GetQueueHandle(), queueSet) != pdPASS) {
+ for (auto &q : queues) {
+ if (xQueueAddToSet(q->GetQueueHandle(), queueSet) != pdPASS) {
state = State::Invalid;
deinit();
return false;
@@ 195,7 195,7 @@ namespace sys
setState(State::Destroyed);
return true;
- };
+ }
/**
* This method starts RTOS thread that waits for incoming queue events.
@@ 204,15 204,12 @@ namespace sys
{
assert(getState() == State::Initiated);
- BaseType_t task_error = 0;
- task_error = xTaskCreate(
+ const auto taskError = xTaskCreate(
Worker::taskAdapter, name.c_str(), stackDepth / sizeof(StackType_t), this, priority, &taskHandle);
-
- if (task_error != pdPASS) {
+ if (taskError != pdPASS) {
LOG_ERROR("Failed to start the task");
return false;
}
-
return true;
}
@@ 264,10 261,12 @@ namespace sys
bool Worker::join(TickType_t timeout)
{
assert(getState() == State::Running || getState() == State::Stopped);
+
if (xSemaphoreTake(joinSemaphore, timeout) != pdTRUE) {
LOG_ERROR("Failed to take semaphore!");
return false;
}
+
const auto waitDeleteTaskTick = xTaskGetTickCount();
while (eTaskGetState(taskHandle) != eDeleted) {
if ((xTaskGetTickCount() - waitDeleteTaskTick) > timeout) {
@@ 275,6 274,7 @@ namespace sys
return false;
}
}
+
return true;
}
M module-sys/Service/include/Service/Worker.hpp => module-sys/Service/include/Service/Worker.hpp +12 -12
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
@@ 31,12 31,12 @@ namespace sys
: Queue(maxItems, itemSize), name(name)
{}
- QueueHandle_t GetQueueHandle() const
+ [[nodiscard]] QueueHandle_t GetQueueHandle() const
{
return handle;
}
- const std::string &GetQueueName() const
+ [[nodiscard]] const std::string &GetQueueName() const
{
return name;
}
@@ 87,22 87,22 @@ namespace sys
Invalid
};
- using Id = unsigned int;
+ using Id = unsigned;
static void taskAdapter(void *taskParam);
bool handleControlMessage();
void task();
void setState(State newState);
void constructName();
- std::string getControlQueueName() const;
- size_t addQueue(const std::string &queueName, UBaseType_t maxItems, UBaseType_t itemSize);
+ [[nodiscard]] std::string getControlQueueName() const;
+ std::size_t addQueue(const std::string &queueName, UBaseType_t maxItems, UBaseType_t itemSize);
std::optional<std::size_t> controlQueueIndex;
std::optional<std::size_t> serviceQueueIndex;
- WorkerQueue &getControlQueue() const;
+ [[nodiscard]] WorkerQueue &getControlQueue() const;
static constexpr std::size_t controlMessagesCount = static_cast<std::size_t>(ControlMessage::MessageCount);
- static constexpr std::size_t defaultStackSize = 8192;
+ static constexpr std::size_t defaultStackSize = 8 * 1024;
static constexpr TickType_t defaultJoinTimeout = pdMS_TO_TICKS(500);
static constexpr auto controlQueueNamePrefix = "wctrl";
@@ 117,14 117,14 @@ namespace sys
protected:
virtual bool handleMessage(std::uint32_t queueID) = 0;
- WorkerQueue &getServiceQueue() const;
+ [[nodiscard]] WorkerQueue &getServiceQueue() const;
- xQueueHandle getQueueHandleByName(const std::string &qname) const;
- std::shared_ptr<WorkerQueue> getQueueByName(const std::string &qname) const;
+ [[nodiscard]] xQueueHandle getQueueHandleByName(const std::string &qname) const;
+ [[nodiscard]] std::shared_ptr<WorkerQueue> getQueueByName(const std::string &qname) const;
bool sendControlMessage(ControlMessage message);
bool sendCommand(WorkerCommand command);
- State getState() const;
+ [[nodiscard]] State getState() const;
static constexpr std::uint32_t SERVICE_QUEUE_LENGTH = 10;
static constexpr std::uint32_t CONTROL_QUEUE_LENGTH = 4;