Skip to content

Commit

Permalink
(wip) make-pretty gsdk-pal
Browse files Browse the repository at this point in the history
  • Loading branch information
lmnotran committed Nov 22, 2023
1 parent 89f944a commit eeed38d
Show file tree
Hide file tree
Showing 26 changed files with 988 additions and 898 deletions.
53 changes: 24 additions & 29 deletions src/gsdk-pal/alarm.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
*
*/

#include "openthread-system.h"
#include <assert.h>
#include <openthread-core-config.h>
#include <stdbool.h>
#include <stdint.h>
#include "openthread-system.h"
#include <openthread-core-config.h>
#include <openthread/platform/alarm-micro.h>
#include <openthread/platform/alarm-milli.h>
#include <openthread/platform/diag.h>
Expand Down Expand Up @@ -67,14 +67,12 @@ static void AlarmCallback(sl_sleeptimer_timer_handle_t *aHandle, void *aData)
otSysEventSignalPending();
}

static void radioTimerExpired(struct RAIL_MultiTimer *tmr,
RAIL_Time_t expectedTimeOfEvent,
void *cbArg)
static void radioTimerExpired(struct RAIL_MultiTimer *tmr, RAIL_Time_t expectedTimeOfEvent, void *cbArg)
{
OT_UNUSED_VARIABLE(tmr);
OT_UNUSED_VARIABLE(expectedTimeOfEvent);
OT_UNUSED_VARIABLE(cbArg);

otSysEventSignalPending();
}

Expand Down Expand Up @@ -118,7 +116,7 @@ void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
sl_sleeptimer_stop_timer(&sl_handle);

sMsAlarm = aT0 + aDt;
remaining = (int32_t)(sMsAlarm - otPlatAlarmMilliGetNow());
remaining = (int32_t)(sMsAlarm - otPlatAlarmMilliGetNow());
sIsMsRunning = true;

if (remaining <= 0)
Expand All @@ -140,7 +138,7 @@ void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
uint32_t efr32AlarmPendingTime(void)
{
uint32_t remaining = 0;
uint32_t now = otPlatAlarmMilliGetNow();
uint32_t now = otPlatAlarmMilliGetNow();
if (sIsMsRunning && (sMsAlarm > now))
{
remaining = sMsAlarm - now;
Expand All @@ -150,7 +148,7 @@ uint32_t efr32AlarmPendingTime(void)

bool efr32AlarmIsRunning(otInstance *aInstance)
{
return (otInstanceIsInitialized(aInstance) ? sIsMsRunning : false);
return (otInstanceIsInitialized(aInstance) ? sIsMsRunning : false);
}

void otPlatAlarmMilliStop(otInstance *aInstance)
Expand All @@ -164,7 +162,7 @@ void otPlatAlarmMilliStop(otInstance *aInstance)
void efr32AlarmProcess(otInstance *aInstance)
{
int32_t remaining;
bool alarmMilliFired = false;
bool alarmMilliFired = false;
#if OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE
bool alarmMicroFired = false;
#endif
Expand Down Expand Up @@ -227,20 +225,21 @@ uint32_t otPlatAlarmMicroGetNow(void)
// period for the wrap-around logic to work below
uint64_t otPlatTimeGet(void)
{
static uint32_t timerWraps = 0U;
static uint32_t prev32TimeUs = 0U;
uint32_t now32TimeUs;
uint64_t now64TimeUs;
CORE_DECLARE_IRQ_STATE;
CORE_ENTER_CRITICAL();
now32TimeUs = RAIL_GetTime();
if (now32TimeUs < prev32TimeUs) {
timerWraps += 1U;
}
prev32TimeUs = now32TimeUs;
now64TimeUs = ((uint64_t)timerWraps << 32) + now32TimeUs;
CORE_EXIT_CRITICAL();
return now64TimeUs;
static uint32_t timerWraps = 0U;
static uint32_t prev32TimeUs = 0U;
uint32_t now32TimeUs;
uint64_t now64TimeUs;
CORE_DECLARE_IRQ_STATE;
CORE_ENTER_CRITICAL();
now32TimeUs = RAIL_GetTime();
if (now32TimeUs < prev32TimeUs)
{
timerWraps += 1U;
}
prev32TimeUs = now32TimeUs;
now64TimeUs = ((uint64_t)timerWraps << 32) + now32TimeUs;
CORE_EXIT_CRITICAL();
return now64TimeUs;
}

void otPlatAlarmMicroStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
Expand All @@ -261,11 +260,7 @@ void otPlatAlarmMicroStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
}
else
{
status = RAIL_SetMultiTimer(&rail_timer,
remaining,
RAIL_TIME_DELAY,
radioTimerExpired,
NULL);
status = RAIL_SetMultiTimer(&rail_timer, remaining, RAIL_TIME_DELAY, radioTimerExpired, NULL);
assert(status == RAIL_STATUS_NO_ERROR);
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/gsdk-pal/board_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@
#ifndef __BOARD_CONFIG_H__
#define __BOARD_CONFIG_H__

#if (!defined(RADIO_CONFIG_SUBGHZ_SUPPORT) || !RADIO_CONFIG_SUBGHZ_SUPPORT)
#define RADIO_CONFIG_2P4GHZ_OQPSK_SUPPORT 1 /// Enable OQPSK modulation in 2.4GHz band
#if (!defined(RADIO_CONFIG_SUBGHZ_SUPPORT) || !RADIO_CONFIG_SUBGHZ_SUPPORT)
#define RADIO_CONFIG_2P4GHZ_OQPSK_SUPPORT 1 /// Enable OQPSK modulation in 2.4GHz band
#endif

#ifndef RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT
#define RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT 0 /// Set to 1 to enable debug counters in radio.c
#define RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT 0 /// Set to 1 to enable debug counters in radio.c
#endif

#ifndef RADIO_CONFIG_ENABLE_CUSTOM_EUI_SUPPORT
#define RADIO_CONFIG_ENABLE_CUSTOM_EUI_SUPPORT 1 /// Set to 1 to enable custom EUI support (enabled by default)
#define RADIO_CONFIG_ENABLE_CUSTOM_EUI_SUPPORT 1 /// Set to 1 to enable custom EUI support (enabled by default)
#endif

#ifndef RADIO_CONFIG_DMP_SUPPORT
#define RADIO_CONFIG_DMP_SUPPORT 0 /// Set to 1 to enable Dynamic Multi-Protocol support in radio.c
#define RADIO_CONFIG_DMP_SUPPORT 0 /// Set to 1 to enable Dynamic Multi-Protocol support in radio.c
#endif

#endif // __BOARD_CONFIG_H__
Loading

0 comments on commit eeed38d

Please sign in to comment.