Skip to content

Commit

Permalink
[sdk] update to Gecko SDK 4.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
lmnotran committed Nov 22, 2023
1 parent d1156ad commit 3ce7285
Show file tree
Hide file tree
Showing 6 changed files with 306 additions and 144 deletions.
90 changes: 89 additions & 1 deletion 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 @@ -47,6 +46,7 @@
#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 +63,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 @@ -312,4 +317,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
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

0 comments on commit 3ce7285

Please sign in to comment.