Skip to content

Commit 77efe91

Browse files
committed
Merge branch 'feat/calibrate_bus_latency' into 'master'
feat(openthread/br): calibrate bus latency Closes TZ-1455 See merge request espressif/esp-idf!38529
2 parents f809c11 + 427084d commit 77efe91

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed

components/openthread/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,12 @@ menu "OpenThread"
400400
help
401401
The device's XTAL accuracy, in ppm.
402402

403+
config OPENTHREAD_BUS_LATENCY
404+
int "The bus latency between host and radio chip"
405+
default 4000
406+
help
407+
The device's bus latency, in us.
408+
403409
config OPENTHREAD_MLE_MAX_CHILDREN
404410
int "The size of max MLE children entries"
405411
default 10

components/openthread/private_include/esp_openthread_radio.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ void esp_openthread_radio_deinit(void);
4444
*/
4545
void esp_openthread_radio_update(esp_openthread_mainloop_context_t *mainloop);
4646

47+
/**
48+
* @brief This function handles netif change for radio spinel.
49+
*
50+
* @param[in] state The updated netif state.
51+
*
52+
*/
53+
void esp_openthread_handle_netif_state_change(bool state);
54+
4755
/**
4856
* @brief This function performs the OpenThread radio process.
4957
*

components/openthread/src/port/esp_openthread_radio_spinel.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,11 @@ void esp_openthread_radio_update(esp_openthread_mainloop_context_t *mainloop)
209209
s_spinel_interface.GetSpinelInterface().UpdateFdSet((void *)mainloop);
210210
}
211211

212+
void esp_openthread_handle_netif_state_change(bool state)
213+
{
214+
s_radio.SetTimeSyncState(state);
215+
}
216+
212217
void otPlatRadioGetIeeeEui64(otInstance *instance, uint8_t *ieee_eui64)
213218
{
214219
SuccessOrDie(s_radio.GetIeeeEui64(ieee_eui64));
@@ -523,3 +528,27 @@ uint32_t otPlatRadioGetSupportedChannelMask(otInstance *aInstance)
523528
// Refer to `GetRadioChannelMask(bool aPreferred)`: FALSE to get supported channel mask
524529
return s_radio.GetRadioChannelMask(false);
525530
}
531+
532+
uint32_t otPlatRadioGetBusSpeed(otInstance *aInstance)
533+
{
534+
OT_UNUSED_VARIABLE(aInstance);
535+
536+
#if CONFIG_OPENTHREAD_RADIO_SPINEL_UART
537+
return s_esp_openthread_radio_config->radio_uart_config.uart_config.baud_rate;
538+
#elif CONFIG_OPENTHREAD_RADIO_SPINEL_SPI
539+
return s_esp_openthread_radio_config->radio_spi_config.spi_device.clock_speed_hz;
540+
#else
541+
return 0;
542+
#endif
543+
}
544+
545+
uint32_t otPlatRadioGetBusLatency(otInstance *aInstance)
546+
{
547+
OT_UNUSED_VARIABLE(aInstance);
548+
549+
#if CONFIG_OPENTHREAD_RADIO_SPINEL_UART || CONFIG_OPENTHREAD_RADIO_SPINEL_SPI
550+
return CONFIG_OPENTHREAD_BUS_LATENCY;
551+
#else
552+
return 0;
553+
#endif
554+
}

components/openthread/src/port/esp_openthread_state.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
static void handle_ot_netif_state_change(otInstance* instance)
2323
{
24-
if (otLinkIsEnabled(instance)) {
24+
if (otIp6IsEnabled(instance)) {
2525
ESP_LOGI(TAG, "netif up");
2626
if (esp_event_post(OPENTHREAD_EVENT, OPENTHREAD_EVENT_IF_UP, NULL, 0, 0) != ESP_OK) {
2727
ESP_LOGE(TAG, "Failed to post OpenThread if up event");
@@ -32,6 +32,10 @@ static void handle_ot_netif_state_change(otInstance* instance)
3232
ESP_LOGE(TAG, "Failed to post OpenThread if down event");
3333
}
3434
}
35+
36+
#if (CONFIG_OPENTHREAD_RADIO_SPINEL_UART || CONFIG_OPENTHREAD_RADIO_SPINEL_SPI)
37+
esp_openthread_handle_netif_state_change(otIp6IsEnabled(instance));
38+
#endif
3539
}
3640

3741
static void handle_ot_netdata_change(void)

0 commit comments

Comments
 (0)