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

[sdk] update to Gecko SDK 4.3.2 #733

Merged
merged 3 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all 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 src/src/alarm.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
*
*/

#include <assert.h>
#include <openthread-core-config.h>
#include <openthread-system.h>
#include <stdbool.h>
#include <stdint.h>
#include <openthread/platform/alarm-micro.h>
#include <openthread/platform/alarm-milli.h>
#include <openthread/platform/diag.h>
#include "common/debug.hpp"
#include "common/logging.hpp"

#include "platform-efr32.h"
Expand Down Expand Up @@ -89,7 +89,7 @@ uint32_t otPlatAlarmMilliGetNow(void)

ticks = sl_sleeptimer_get_tick_count64();
status = sl_sleeptimer_tick64_to_ms(ticks, &now);
assert(status == SL_STATUS_OK);
OT_ASSERT(status == SL_STATUS_OK);
return (uint32_t)now;
}

Expand Down Expand Up @@ -131,7 +131,7 @@ void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
NULL,
0,
SL_SLEEPTIMER_NO_HIGH_PRECISION_HF_CLOCKS_REQUIRED_FLAG);
assert(status == SL_STATUS_OK);
OT_ASSERT(status == SL_STATUS_OK);
}
}

Expand Down Expand Up @@ -261,7 +261,7 @@ void otPlatAlarmMicroStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
else
{
status = RAIL_SetMultiTimer(&rail_timer, remaining, RAIL_TIME_DELAY, radioTimerExpired, NULL);
assert(status == RAIL_STATUS_NO_ERROR);
OT_ASSERT(status == RAIL_STATUS_NO_ERROR);
}
}

Expand Down
95 changes: 93 additions & 2 deletions src/src/diag.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
*
*/

#include <assert.h>
#include <stdbool.h>
#include <stdio.h>
#include <sys/time.h>
Expand All @@ -44,9 +43,11 @@
#include <openthread/platform/diag.h>
#include <openthread/platform/radio.h>
#include "common/code_utils.hpp"
#include "common/debug.hpp"
#include "common/logging.hpp"

#include "diag.h"
#include "em_gpio.h"
#include "platform-band.h"
#include "platform-efr32.h"
#include "rail_ieee802154.h"
Expand All @@ -63,6 +64,11 @@
#include "sl_rail_util_ant_div.h"
#endif

#define GPIO_PIN_BITMASK 0xFFFFUL
#define GPIO_PORT_BITMASK (0xFFFFUL << 16)
#define GET_GPIO_PIN(x) (x & GPIO_PIN_BITMASK)
#define GET_GPIO_PORT(x) ((x & GPIO_PORT_BITMASK) >> 16)

struct PlatformDiagCommand
{
const char *mName;
Expand Down Expand Up @@ -227,7 +233,9 @@ static RAIL_Status_t stopTxStream(void)
// Since start transmit stream turn off the radio state,
// call the RAIL_StartRx to turn on radio
IgnoreError(RAIL_GetChannel(gRailHandle, &currentChannel));
assert(RAIL_StartRx(gRailHandle, currentChannel, &rxSchedulerInfo) == RAIL_STATUS_NO_ERROR);

status = RAIL_StartRx(gRailHandle, currentChannel, &rxSchedulerInfo);
OT_ASSERT(status == RAIL_STATUS_NO_ERROR);

exit:
return status;
Expand Down Expand Up @@ -312,4 +320,87 @@ void otPlatDiagAlarmCallback(otInstance *aInstance)
OT_UNUSED_VARIABLE(aInstance);
}

static otError getGpioPortAndPin(uint32_t aGpio, uint16_t *aPort, uint16_t *aPin)
{
otError error = OT_ERROR_NONE;
*aPort = GET_GPIO_PORT(aGpio);
*aPin = GET_GPIO_PIN(aGpio);

if (*aPort > GPIO_PORT_MAX || *aPin > GPIO_PIN_MAX)
{
ExitNow(error = OT_ERROR_INVALID_ARGS);
}

exit:
return error;
}

otError otPlatDiagGpioSet(uint32_t aGpio, bool aValue)
{
otError error;
uint16_t port;
uint16_t pin;

SuccessOrExit(error = getGpioPortAndPin(aGpio, &port, &pin));

if (aValue)
{
GPIO_PinOutSet((GPIO_Port_TypeDef)port, pin);
}
else
{
GPIO_PinOutClear((GPIO_Port_TypeDef)port, pin);
}

exit:
return error;
}

otError otPlatDiagGpioGet(uint32_t aGpio, bool *aValue)
{
otError error;
uint16_t port;
uint16_t pin;

SuccessOrExit(error = getGpioPortAndPin(aGpio, &port, &pin));

*aValue = GPIO_PinInGet((GPIO_Port_TypeDef)port, pin);

exit:
return error;
}

otError otPlatDiagGpioSetMode(uint32_t aGpio, otGpioMode aMode)
{
otError error;
uint16_t port;
uint16_t pin;
GPIO_Mode_TypeDef mode;

SuccessOrExit(error = getGpioPortAndPin(aGpio, &port, &pin));

mode = (aMode == OT_GPIO_MODE_INPUT) ? gpioModeInput : gpioModePushPull;

GPIO_PinModeSet((GPIO_Port_TypeDef)port, pin, mode, 0 /*out*/);

exit:
return error;
}

otError otPlatDiagGpioGetMode(uint32_t aGpio, otGpioMode *aMode)
{
otError error;
uint16_t port;
uint16_t pin;
GPIO_Mode_TypeDef mode;

SuccessOrExit(error = getGpioPortAndPin(aGpio, &port, &pin));

mode = GPIO_PinModeGet((GPIO_Port_TypeDef)port, pin);

*aMode = (mode == gpioModeInput) ? OT_GPIO_MODE_INPUT : OT_GPIO_MODE_OUTPUT;

exit:
return error;
}
#endif // OPENTHREAD_CONFIG_DIAG_ENABLE
1 change: 0 additions & 1 deletion src/src/ieee802154-packet-utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#include "sl_packet_utils.h"
#include "sli_protocol_crypto.h"

#include <assert.h>
#include "common/code_utils.hpp"
#include "common/debug.hpp"
#include "crypto/aes_ccm.hpp"
Expand Down
67 changes: 56 additions & 11 deletions src/src/openthread-core-efr32-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@
#ifndef OPENTHREAD_CORE_EFR32_CONFIG_H_
#define OPENTHREAD_CORE_EFR32_CONFIG_H_

#include "sl_device_init_hfxo.h"
#include "sl_device_init_hfxo_config.h"

#if defined(HARDWARE_BOARD_HAS_LFXO)
#include "sl_device_init_lfxo.h"
#include "sl_device_init_lfxo_config.h"
#endif

// Use (user defined) application config file to define OpenThread configurations
#ifdef SL_OPENTHREAD_APPLICATION_CONFIG_FILE
#include SL_OPENTHREAD_APPLICATION_CONFIG_FILE
Expand Down Expand Up @@ -200,9 +208,23 @@
* The minimum time (in microseconds) before the MHR start that the radio should be in receive state and ready to
* properly receive in order to properly receive any IEEE 802.15.4 frame. Defaults to the duration of SHR + PHR.
*
* 802.15.4 2.4GHz OQPSK:
* SHR: 4 bytes of preamble, 1 byte of sync word
* PHR: 1 byte
* Total (6 * 32) = 192 us.
*
* Proprietary SubGhz (2GFSK in 915MHz):
* SHR: 4 bytes preamble, 2 bytes SFD = 6 bytes
* PHR: 2 bytes
* Total (8 * 32) = 256 us.
*
*/
#ifndef OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AHEAD
#define OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AHEAD (6 * 32)
#if RADIO_CONFIG_SUBGHZ_SUPPORT
#define OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AHEAD 256
#else
#define OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AHEAD 192
#endif
#endif

/**
Expand All @@ -213,9 +235,12 @@
* plus the duration of maximum enh-ack frame. Platforms are encouraged to improve this value for energy
* efficiency purposes.
*
* In theory, RAIL should automatically extend the duration of the receive window once the SHR has been
* detected, so we should be able to set this to zero.
*
*/
#ifndef OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AFTER
#define OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AFTER ((127 + 6 + 39) * 32)
#define OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AFTER 0
#endif

/*
Expand Down Expand Up @@ -423,34 +448,54 @@
*
*/
#ifndef SL_OPENTHREAD_CSL_TX_UNCERTAINTY
#if OPENTHREAD_RADIO || OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
#define SL_OPENTHREAD_CSL_TX_UNCERTAINTY 175
#elif OPENTHREAD_FTD
// Approx. ~128 us. for single CCA + some additional tx uncertainty in testing
#define SL_OPENTHREAD_CSL_TX_UNCERTAINTY 20
#else
// Approx. ~128 us. for single CCA
//
// Note: Our SSEDs "schedule" transmissions to their parent in order to know
// exactly when in the future the data packets go out so they can calculate
// the accurate CSL phase to send to their parent.
//
// The receive windows on the SSEDs scale with this value, so increasing this
// uncertainty to account for full CCA/CSMA with 0..7 backoffs
// (see RAIL_CSMA_CONFIG_802_15_4_2003_2p4_GHz_OQPSK_CSMA) will mean that the
// receive windows can get very long (~ 5ms.)
//
// We have updated SSEDs to use a single CCA (RAIL_CSMA_CONFIG_SINGLE_CCA)
// instead. If they are in very busy channels, CSL won't be reliable anyway.
#define SL_OPENTHREAD_CSL_TX_UNCERTAINTY 12
#endif
#endif

/**
* @def SL_OPENTHREAD_HFXO_ACCURACY
*
* XTAL accuracy in units of ± ppm. Also used for calculations during CSL operations.
*
* According to EFR datasheets, HFXO is ± 40 ppm.
* Worst case XTAL accuracy in units of ± ppm. Also used for calculations during CSL operations.
*
* @note Platforms may optimize this value based on operational conditions (i.e.: temperature).
*
*/
#ifndef SL_OPENTHREAD_HFXO_ACCURACY
#define SL_OPENTHREAD_HFXO_ACCURACY 80
#define SL_OPENTHREAD_HFXO_ACCURACY SL_DEVICE_INIT_HFXO_PRECISION
#endif

/**
* @def SL_OPENTHREAD_LFXO_ACCURACY
*
* XTAL accuracy in units of ± ppm. Also used for calculations during CSL operations.
*
* According to EFR datasheets, LFXO (at least for MG12) is -8 to +40 ppm.
* Worst case XTAL accuracy in units of ± ppm. Also used for calculations during CSL operations.
*
* @note Platforms may optimize this value based on operational conditions (i.e.: temperature).
*/
#ifndef SL_OPENTHREAD_LFXO_ACCURACY
#define SL_OPENTHREAD_LFXO_ACCURACY 48
#if defined(HARDWARE_BOARD_HAS_LFXO)
#define SL_OPENTHREAD_LFXO_ACCURACY SL_DEVICE_INIT_LFXO_PRECISION
#else
#define SL_OPENTHREAD_LFXO_ACCURACY 0
#endif
#endif

/**
Expand All @@ -470,7 +515,7 @@
*
*/
#ifndef SL_OPENTHREAD_RADIO_RX_BUFFER_COUNT
#define SL_OPENTHREAD_RADIO_RX_BUFFER_COUNT 4
#define SL_OPENTHREAD_RADIO_RX_BUFFER_COUNT 16
#endif

/**
Expand Down
Loading