Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Silabs] Change freertos tick to 1024Hz #25499

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions examples/lighting-app/silabs/SiWx917/src/LightingManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ CHIP_ERROR LightingManager::Init()
{
// Create FreeRTOS sw timer for light timer.
sLightTimer = xTimerCreate("lightTmr", // Just a text name, not used by the RTOS kernel
1, // == default timer period (mS)
pdMS_TO_TICKS(1), // == default timer period (mS)
false, // no timer reload (==one-shot)
(void *) this, // init timer id = light obj context
TimerEventHandler // timer callback handler
Expand Down Expand Up @@ -164,9 +164,9 @@ void LightingManager::StartTimer(uint32_t aTimeoutMs)
}

// timer is not active, change its period to required value (== restart).
// FreeRTOS- Block for a maximum of 100 ticks if the change period command
// FreeRTOS- Block for a maximum of 100 ms if the change period command
// cannot immediately be sent to the timer command queue.
if (xTimerChangePeriod(sLightTimer, (aTimeoutMs / portTICK_PERIOD_MS), 100) != pdPASS)
if (xTimerChangePeriod(sLightTimer, pdMS_TO_TICKS(aTimeoutMs), pdMS_TO_TICKS(100)) != pdPASS)
{
SILABS_LOG("sLightTimer timer start() failed");
appError(APP_ERROR_START_TIMER_FAILED);
Expand All @@ -175,7 +175,7 @@ void LightingManager::StartTimer(uint32_t aTimeoutMs)

void LightingManager::CancelTimer(void)
{
if (xTimerStop(sLightTimer, 0) == pdFAIL)
if (xTimerStop(sLightTimer, pdMS_TO_TICKS(0)) == pdFAIL)
{
SILABS_LOG("sLightTimer stop() failed");
appError(APP_ERROR_STOP_TIMER_FAILED);
Expand Down
8 changes: 4 additions & 4 deletions examples/lighting-app/silabs/efr32/src/LightingManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ CHIP_ERROR LightingManager::Init()
{
// Create FreeRTOS sw timer for light timer.
sLightTimer = xTimerCreate("lightTmr", // Just a text name, not used by the RTOS kernel
1, // == default timer period (mS)
pdMS_TO_TICKS(1), // == default timer period (mS)
false, // no timer reload (==one-shot)
(void *) this, // init timer id = light obj context
TimerEventHandler // timer callback handler
Expand Down Expand Up @@ -164,9 +164,9 @@ void LightingManager::StartTimer(uint32_t aTimeoutMs)
}

// timer is not active, change its period to required value (== restart).
// FreeRTOS- Block for a maximum of 100 ticks if the change period command
// FreeRTOS- Block for a maximum of 100 ms if the change period command
// cannot immediately be sent to the timer command queue.
if (xTimerChangePeriod(sLightTimer, (aTimeoutMs / portTICK_PERIOD_MS), 100) != pdPASS)
if (xTimerChangePeriod(sLightTimer, pdMS_TO_TICKS(aTimeoutMs), pdMS_TO_TICKS(100)) != pdPASS)
{
SILABS_LOG("sLightTimer timer start() failed");
appError(APP_ERROR_START_TIMER_FAILED);
Expand All @@ -175,7 +175,7 @@ void LightingManager::StartTimer(uint32_t aTimeoutMs)

void LightingManager::CancelTimer(void)
{
if (xTimerStop(sLightTimer, 0) == pdFAIL)
if (xTimerStop(sLightTimer, pdMS_TO_TICKS(0)) == pdFAIL)
{
SILABS_LOG("sLightTimer stop() failed");
appError(APP_ERROR_STOP_TIMER_FAILED);
Expand Down
8 changes: 4 additions & 4 deletions examples/lock-app/silabs/SiWx917/src/LockManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ CHIP_ERROR LockManager::Init(chip::app::DataModel::Nullable<chip::app::Clusters:

// Create FreeRTOS sw timer for lock timer.
sLockTimer = xTimerCreate("lockTmr", // Just a text name, not used by the RTOS kernel
1, // == default timer period (mS)
pdMS_TO_TICKS(1), // == default timer period (mS)
false, // no timer reload (==one-shot)
(void *) this, // init timer id = lock obj context
TimerEventHandler // timer callback handler
Expand Down Expand Up @@ -225,9 +225,9 @@ void LockManager::StartTimer(uint32_t aTimeoutMs)
}

// timer is not active, change its period to required value (== restart).
// FreeRTOS- Block for a maximum of 100 ticks if the change period command
// FreeRTOS- Block for a maximum of 100 ms if the change period command
// cannot immediately be sent to the timer command queue.
if (xTimerChangePeriod(sLockTimer, (aTimeoutMs / portTICK_PERIOD_MS), 100) != pdPASS)
if (xTimerChangePeriod(sLockTimer, pdMS_TO_TICKS(aTimeoutMs), pdMS_TO_TICKS(100)) != pdPASS)
{
SILABS_LOG("sLockTimer timer start() failed");
appError(APP_ERROR_START_TIMER_FAILED);
Expand All @@ -236,7 +236,7 @@ void LockManager::StartTimer(uint32_t aTimeoutMs)

void LockManager::CancelTimer(void)
{
if (xTimerStop(sLockTimer, 0) == pdFAIL)
if (xTimerStop(sLockTimer, pdMS_TO_TICKS(0)) == pdFAIL)
{
SILABS_LOG("sLockTimer stop() failed");
appError(APP_ERROR_STOP_TIMER_FAILED);
Expand Down
6 changes: 3 additions & 3 deletions examples/lock-app/silabs/efr32/src/LockManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ void LockManager::StartTimer(uint32_t aTimeoutMs)
}

// timer is not active, change its period to required value (== restart).
// FreeRTOS- Block for a maximum of 100 ticks if the change period command
// FreeRTOS- Block for a maximum of 100 ms if the change period command
// cannot immediately be sent to the timer command queue.
if (xTimerChangePeriod(sLockTimer, (aTimeoutMs / portTICK_PERIOD_MS), 100) != pdPASS)
if (xTimerChangePeriod(sLockTimer, pdMS_TO_TICKS(aTimeoutMs), pdMS_TO_TICKS(100)) != pdPASS)
{
SILABS_LOG("sLockTimer timer start() failed");
appError(APP_ERROR_START_TIMER_FAILED);
Expand All @@ -236,7 +236,7 @@ void LockManager::StartTimer(uint32_t aTimeoutMs)

void LockManager::CancelTimer(void)
{
if (xTimerStop(sLockTimer, 0) == pdFAIL)
if (xTimerStop(sLockTimer, pdMS_TO_TICKS(0)) == pdFAIL)
{
SILABS_LOG("sLockTimer stop() failed");
appError(APP_ERROR_STOP_TIMER_FAILED);
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/silabs/Rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class Efr32Device final : public Device
pw::Status Reboot(const pw_protobuf_Empty & request, pw_protobuf_Empty & response) override
{
mRebootTimer = xTimerCreateStatic("Reboot", kRebootTimerPeriodTicks, false, nullptr, RebootHandler, &mRebootTimerBuffer);
xTimerStart(mRebootTimer, 0);
xTimerStart(mRebootTimer, pdMS_TO_TICKS(0));
return pw::OkStatus();
}

Expand Down
14 changes: 7 additions & 7 deletions examples/platform/silabs/SiWx917/BaseApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ CHIP_ERROR BaseApplication::Init(Identify * identifyObj)

// Create FreeRTOS sw timer for Function Selection.
sFunctionTimer = xTimerCreate("FnTmr", // Just a text name, not used by the RTOS kernel
1, // == default timer period (mS)
pdMS_TO_TICKS(1), // == default timer period (mS)
false, // no timer reload (==one-shot)
(void *) this, // init timer id = app task obj context
FunctionTimerEventHandler // timer callback handler
Expand All @@ -190,7 +190,7 @@ CHIP_ERROR BaseApplication::Init(Identify * identifyObj)

// Create FreeRTOS sw timer for LED Management.
sLightTimer = xTimerCreate("LightTmr", // Text Name
10, // Default timer period (mS)
pdMS_TO_TICKS(10), // Default timer period (mS)
true, // reload timer
(void *) this, // Timer Id
LightTimerEventHandler // Timer callback handler
Expand Down Expand Up @@ -426,7 +426,7 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent)

void BaseApplication::CancelFunctionTimer()
{
if (xTimerStop(sFunctionTimer, 0) == pdFAIL)
if (xTimerStop(sFunctionTimer, pdMS_TO_TICKS(0)) == pdFAIL)
{
SILABS_LOG("app timer stop() failed");
appError(APP_ERROR_STOP_TIMER_FAILED);
Expand All @@ -444,9 +444,9 @@ void BaseApplication::StartFunctionTimer(uint32_t aTimeoutInMs)
}

// timer is not active, change its period to required value (== restart).
// FreeRTOS- Block for a maximum of 100 ticks if the change period command
// FreeRTOS- Block for a maximum of 100 ms if the change period command
// cannot immediately be sent to the timer command queue.
if (xTimerChangePeriod(sFunctionTimer, aTimeoutInMs / portTICK_PERIOD_MS, 100) != pdPASS)
if (xTimerChangePeriod(sFunctionTimer, pdMS_TO_TICKS(aTimeoutInMs), pdMS_TO_TICKS(100)) != pdPASS)
{
SILABS_LOG("app timer start() failed");
appError(APP_ERROR_START_TIMER_FAILED);
Expand All @@ -457,7 +457,7 @@ void BaseApplication::StartFunctionTimer(uint32_t aTimeoutInMs)

void BaseApplication::StartStatusLEDTimer()
{
if (pdPASS != xTimerStart(sLightTimer, 0))
if (pdPASS != xTimerStart(sLightTimer, pdMS_TO_TICKS(0)))
{
SILABS_LOG("Light Time start failed");
appError(APP_ERROR_START_TIMER_FAILED);
Expand All @@ -470,7 +470,7 @@ void BaseApplication::StopStatusLEDTimer()
sStatusLED.Set(false);
#endif // ENABLE_WSTK_LEDS

if (xTimerStop(sLightTimer, 100) != pdPASS)
if (xTimerStop(sLightTimer, pdMS_TO_TICKS(100)) != pdPASS)
{
SILABS_LOG("Light Time start failed");
appError(APP_ERROR_START_TIMER_FAILED);
Expand Down
14 changes: 7 additions & 7 deletions examples/platform/silabs/efr32/BaseApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ CHIP_ERROR BaseApplication::Init(Identify * identifyObj)

// Create FreeRTOS sw timer for Function Selection.
sFunctionTimer = xTimerCreate("FnTmr", // Just a text name, not used by the RTOS kernel
1, // == default timer period (mS)
pdMS_TO_TICKS(1), // == default timer period (mS)
false, // no timer reload (==one-shot)
(void *) this, // init timer id = app task obj context
FunctionTimerEventHandler // timer callback handler
Expand All @@ -196,7 +196,7 @@ CHIP_ERROR BaseApplication::Init(Identify * identifyObj)

// Create FreeRTOS sw timer for LED Management.
sLightTimer = xTimerCreate("LightTmr", // Text Name
10, // Default timer period (mS)
pdMS_TO_TICKS(10), // Default timer period (mS)
true, // reload timer
(void *) this, // Timer Id
LightTimerEventHandler // Timer callback handler
Expand Down Expand Up @@ -463,7 +463,7 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent)
#endif
void BaseApplication::CancelFunctionTimer()
{
if (xTimerStop(sFunctionTimer, 0) == pdFAIL)
if (xTimerStop(sFunctionTimer, pdMS_TO_TICKS(0)) == pdFAIL)
{
SILABS_LOG("app timer stop() failed");
appError(APP_ERROR_STOP_TIMER_FAILED);
Expand All @@ -481,9 +481,9 @@ void BaseApplication::StartFunctionTimer(uint32_t aTimeoutInMs)
}

// timer is not active, change its period to required value (== restart).
// FreeRTOS- Block for a maximum of 100 ticks if the change period command
// FreeRTOS- Block for a maximum of 100 ms if the change period command
// cannot immediately be sent to the timer command queue.
if (xTimerChangePeriod(sFunctionTimer, aTimeoutInMs / portTICK_PERIOD_MS, 100) != pdPASS)
if (xTimerChangePeriod(sFunctionTimer, pdMS_TO_TICKS(aTimeoutInMs), pdMS_TO_TICKS(100)) != pdPASS)
{
SILABS_LOG("app timer start() failed");
appError(APP_ERROR_START_TIMER_FAILED);
Expand All @@ -494,7 +494,7 @@ void BaseApplication::StartFunctionTimer(uint32_t aTimeoutInMs)

void BaseApplication::StartStatusLEDTimer()
{
if (pdPASS != xTimerStart(sLightTimer, 0))
if (pdPASS != xTimerStart(sLightTimer, pdMS_TO_TICKS(0)))
{
SILABS_LOG("Light Time start failed");
appError(APP_ERROR_START_TIMER_FAILED);
Expand All @@ -507,7 +507,7 @@ void BaseApplication::StopStatusLEDTimer()
sStatusLED.Set(false);
#endif // ENABLE_WSTK_LEDS

if (xTimerStop(sLightTimer, 100) != pdPASS)
if (xTimerStop(sLightTimer, pdMS_TO_TICKS(100)) != pdPASS)
{
SILABS_LOG("Light Time start failed");
appError(APP_ERROR_START_TIMER_FAILED);
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/silabs/efr32/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ extern "C" {
#define configUSE_TICKLESS_IDLE 0
#endif // SL_CATALOG_POWER_MANAGER_PRESENT

#define configTICK_RATE_HZ (1000)
#define configTICK_RATE_HZ (1024)
/* Definition used by Keil to replace default system clock source. */
#define configOVERRIDE_DEFAULT_TICK_CONFIGURATION 1

Expand Down
6 changes: 3 additions & 3 deletions examples/platform/silabs/efr32/wf200/wf200_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ sl_status_t sl_wfx_host_reset_chip(void)
*****************************************************************************/
sl_status_t sl_wfx_host_wait_for_wake_up(void)
{
xSemaphoreTake(wfx_wakeup_sem, TICKS_TO_WAIT_0);
xSemaphoreTake(wfx_wakeup_sem, TICKS_TO_WAIT_3 / portTICK_PERIOD_MS);
xSemaphoreTake(wfx_wakeup_sem, pdMS_TO_TICKS(TICKS_TO_WAIT_0));
xSemaphoreTake(wfx_wakeup_sem, pdMS_TO_TICKS(TICKS_TO_WAIT_3));

return SL_STATUS_OK;
}
Expand Down Expand Up @@ -418,7 +418,7 @@ sl_status_t sl_wfx_host_lock(void)

sl_status_t status = SL_STATUS_OK;

if (xSemaphoreTake(wfx_mutex, TICKS_TO_WAIT_500) != pdTRUE)
if (xSemaphoreTake(wfx_mutex, pdMS_TO_TICKS(TICKS_TO_WAIT_500)) != pdTRUE)
{
SILABS_LOG("*ERR*Wi-Fi driver mutex timo");
status = SL_STATUS_TIMEOUT;
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/silabs/matter_shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void MatterShellTask(void * args)

extern "C" unsigned int sleep(unsigned int seconds)
{
const TickType_t xDelay = 1000 * seconds / portTICK_PERIOD_MS;
const TickType_t xDelay = pdMS_TO_TICKS(1000 * seconds);
vTaskDelay(xDelay);
return 0;
}
Expand Down
14 changes: 7 additions & 7 deletions examples/window-app/silabs/SiWx917/src/WindowAppImpl.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ chip::app::Clusters::NetworkCommissioning::Instance
WindowAppImpl::Timer::Timer(const char * name, uint32_t timeoutInMs, Callback callback, void * context) :
WindowApp::Timer(name, timeoutInMs, callback, context)
{
mHandler = xTimerCreate(name, // Just a text name, not used by the RTOS kernel
timeoutInMs, // == default timer period (mS)
false, // no timer reload (==one-shot)
(void *) this, // init timer id = app task obj context
TimerCallback // timer callback handler
mHandler = xTimerCreate(name, // Just a text name, not used by the RTOS kernel
pdMS_TO_TICKS(timeoutInMs), // == default timer period (mS)
false, // no timer reload (==one-shot)
(void *) this, // init timer id = app task obj context
TimerCallback // timer callback handler
);
if (mHandler == NULL)
{
Expand All @@ -90,7 +90,7 @@ void WindowAppImpl::Timer::Start()
}

// Timer is not active
if (xTimerStart(mHandler, 100) != pdPASS)
if (xTimerStart(mHandler, pdMS_TO_TICKS(100)) != pdPASS)
{
SILABS_LOG("Timer start() failed");
appError(CHIP_ERROR_INTERNAL);
Expand All @@ -115,7 +115,7 @@ void WindowAppImpl::Timer::IsrStart()
void WindowAppImpl::Timer::Stop()
{
mIsActive = false;
if (xTimerStop(mHandler, 0) == pdFAIL)
if (xTimerStop(mHandler, pdMS_TO_TICKS(0)) == pdFAIL)
{
SILABS_LOG("Timer stop() failed");
appError(CHIP_ERROR_INTERNAL);
Expand Down
14 changes: 7 additions & 7 deletions examples/window-app/silabs/efr32/src/WindowAppImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ chip::app::Clusters::NetworkCommissioning::Instance
WindowAppImpl::Timer::Timer(const char * name, uint32_t timeoutInMs, Callback callback, void * context) :
WindowApp::Timer(name, timeoutInMs, callback, context)
{
mHandler = xTimerCreate(name, // Just a text name, not used by the RTOS kernel
timeoutInMs, // == default timer period (mS)
false, // no timer reload (==one-shot)
(void *) this, // init timer id = app task obj context
TimerCallback // timer callback handler
mHandler = xTimerCreate(name, // Just a text name, not used by the RTOS kernel
pdMS_TO_TICKS(timeoutInMs), // == default timer period (mS)
false, // no timer reload (==one-shot)
(void *) this, // init timer id = app task obj context
TimerCallback // timer callback handler
);
if (mHandler == NULL)
{
Expand All @@ -95,7 +95,7 @@ void WindowAppImpl::Timer::Start()
}

// Timer is not active
if (xTimerStart(mHandler, 100) != pdPASS)
if (xTimerStart(mHandler, pdMS_TO_TICKS(100)) != pdPASS)
{
SILABS_LOG("Timer start() failed");
appError(CHIP_ERROR_INTERNAL);
Expand All @@ -120,7 +120,7 @@ void WindowAppImpl::Timer::IsrStart()
void WindowAppImpl::Timer::Stop()
{
mIsActive = false;
if (xTimerStop(mHandler, 0) == pdFAIL)
if (xTimerStop(mHandler, pdMS_TO_TICKS(0)) == pdFAIL)
{
SILABS_LOG("Timer stop() failed");
appError(CHIP_ERROR_INTERNAL);
Expand Down
14 changes: 7 additions & 7 deletions src/platform/silabs/SiWx917/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,11 @@ CHIP_ERROR BLEManagerImpl::_Init()
mServiceMode = ConnectivityManager::kCHIPoBLEServiceMode_Enabled;

// Create FreeRTOS sw timer for BLE timeouts and interval change.
sbleAdvTimeoutTimer = xTimerCreate("BleAdvTimer", // Just a text name, not used by the RTOS kernel
BLE__DEFAULT_TIMER_PERIOD, // == default timer period (mS)
false, // no timer reload (==one-shot)
(void *) this, // init timer id = ble obj context
BleAdvTimeoutHandler // timer callback handler
sbleAdvTimeoutTimer = xTimerCreate("BleAdvTimer", // Just a text name, not used by the RTOS kernel
pdMS_TO_TICKS(BLE__DEFAULT_TIMER_PERIOD), // == default timer period (mS)
false, // no timer reload (==one-shot)
(void *) this, // init timer id = ble obj context
BleAdvTimeoutHandler // timer callback handler
);

mFlags.ClearAll().Set(Flags::kAdvertisingEnabled, CHIP_DEVICE_CONFIG_CHIPOBLE_ENABLE_ADVERTISING_AUTOSTART);
Expand Down Expand Up @@ -985,7 +985,7 @@ void BLEManagerImpl::BleAdvTimeoutHandler(TimerHandle_t xTimer)

void BLEManagerImpl::CancelBleAdvTimeoutTimer(void)
{
if (xTimerStop(sbleAdvTimeoutTimer, 0) == pdFAIL)
if (xTimerStop(sbleAdvTimeoutTimer, pdMS_TO_TICKS(0)) == pdFAIL)
{
ChipLogError(DeviceLayer, "Failed to stop BledAdv timeout timer");
}
Expand All @@ -1001,7 +1001,7 @@ void BLEManagerImpl::StartBleAdvTimeoutTimer(uint32_t aTimeoutInMs)
// timer is not active, change its period to required value (== restart).
// FreeRTOS- Block for a maximum of 100 ticks if the change period command
// cannot immediately be sent to the timer command queue.
if (xTimerChangePeriod(sbleAdvTimeoutTimer, aTimeoutInMs / portTICK_PERIOD_MS, 100) != pdPASS)
if (xTimerChangePeriod(sbleAdvTimeoutTimer, pdMS_TO_TICKS(aTimeoutInMs), pdMS_TO_TICKS(100)) != pdPASS)
{
ChipLogError(DeviceLayer, "Failed to start BledAdv timeout timer");
}
Expand Down
2 changes: 1 addition & 1 deletion src/platform/silabs/SiWx917/wifi/wfx_host_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
* be held in the Blocked state to wait for the start command to be successfully
* sent to the timer command queue.
*/
#define TIMER_TICKS_TO_WAIT_0 0
#define TIMER_TICKS_TO_WAIT_0 pdMS_TO_TICKS(0)

#define CONVERT_SEC_TO_MSEC 1000
#define CONVERT_USEC_TO_MSEC (1 / 1000)
Expand Down
Loading