Skip to content

Commit

Permalink
[Telink]: Added a test retention platform for tlsr9528a
Browse files Browse the repository at this point in the history
Added draft Thread-only solution for deep sleep retention tlsr9528a platform

Signed-off-by: Misha Tkachenko <[email protected]>
  • Loading branch information
mishadesh committed Oct 3, 2023
1 parent 1ec98c8 commit 8905974
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 5 deletions.
12 changes: 9 additions & 3 deletions config/telink/chip-module/Kconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ config INIT_STACKS
default y

config IDLE_STACK_SIZE
default 387 if PM
default 512 if PM

config ISR_STACK_SIZE
default 502 if PM
Expand All @@ -73,7 +73,7 @@ config SYSTEM_WORKQUEUE_STACK_SIZE
default 616 if PM

config HEAP_MEM_POOL_SIZE
default 128 if PM
default 256

config NET_IPV6_MLD
default n
Expand All @@ -98,7 +98,7 @@ config NET_BUF_TX_COUNT
# Bluetooth Low Energy configs

config BT
default y
default n

config BT_PERIPHERAL
default y
Expand Down Expand Up @@ -151,6 +151,12 @@ choice B9X_BLE_CTRL_MAC_TYPE
default B9X_BLE_CTRL_MAC_TYPE_RANDOM_STATIC
endchoice

#Board retention config
if BOARD_TLSR9528A_RETENTION || BOARD_TLSR9518ADK80D_RETENTION
config BOARD_TLSR9X_NON_RETENTION_RAM_CODE
default y if PM
endif

# Config dynamic interrupts to have posibility to switch between BLE/Thread radio drivers
config DYNAMIC_INTERRUPTS
default y
Expand Down
5 changes: 5 additions & 0 deletions examples/light-switch-app/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,8 @@ CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE=n

# Enable Power Management
CONFIG_PM=y
CONFIG_CHIP_ICD_SLOW_POLL_INTERVAL=10000
CONFIG_CHIP_ICD_FAST_POLLING_INTERVAL=2000
CONFIG_CHIP_ICD_IDLE_MODE_INTERVAL=2000
CONFIG_CHIP_ICD_ACTIVE_MODE_INTERVAL=2001
CONFIG_CHIP_ICD_ACTIVE_MODE_THRESHOLD=2000
2 changes: 1 addition & 1 deletion examples/platform/telink/common/include/AppTaskCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class AppTaskCommon
static void StartBleAdvHandler(AppEvent * aEvent);
#endif

#if APP_USE_THREAD_START_BUTTON
#if APP_USE_THREAD_START_BUTTON || !CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
static void StartThreadButtonEventHandler(void);
static void StartThreadHandler(AppEvent * aEvent);
#endif
Expand Down
13 changes: 12 additions & 1 deletion examples/platform/telink/common/src/AppTaskCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,14 @@ class AppCallbacks : public AppDelegate
void OnCommissioningSessionStarted() override { isComissioningStarted = true; }
void OnCommissioningSessionStopped() override { isComissioningStarted = false; }
void OnCommissioningSessionEstablishmentError(CHIP_ERROR err) override { sIsCommissioningFailed = true; }

#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
void OnCommissioningWindowClosed() override
{
if (!isComissioningStarted)
chip::DeviceLayer::Internal::BLEMgr().Shutdown();
}
#endif
};

AppCallbacks sCallbacks;
Expand Down Expand Up @@ -244,6 +247,9 @@ CHIP_ERROR AppTaskCommon::StartApp(void)
}

AppEvent event = {};
#if !CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
StartThreadButtonEventHandler();
#endif

while (true)
{
Expand Down Expand Up @@ -634,7 +640,7 @@ void AppTaskCommon::FactoryResetTimerEventHandler(AppEvent * aEvent)
LOG_INF("Factory Reset Trigger Counter is cleared");
}

#if APP_USE_THREAD_START_BUTTON
#if APP_USE_THREAD_START_BUTTON || !CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
void AppTaskCommon::StartThreadButtonEventHandler(void)
{
AppEvent event;
Expand All @@ -651,8 +657,13 @@ void AppTaskCommon::StartThreadHandler(AppEvent * aEvent)
if (!chip::DeviceLayer::ConnectivityMgr().IsThreadProvisioned())
{
// Switch context from BLE to Thread
#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
Internal::BLEManagerImpl sInstance;
sInstance.SwitchToIeee802154();
#else
ThreadStackMgrImpl().SetRadioBlocked(false);
ThreadStackMgrImpl().SetThreadEnabled(true);
#endif
StartDefaultThreadNetwork();
}
else
Expand Down
116 changes: 116 additions & 0 deletions src/platform/telink/tlsr9528a_retention.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/ {
aliases {
system-state-led = &led_red;
pwm-led0 = &pwm_led0;
pwm-led1 = &pwm_led1;
pwm-led2 = &pwm_led2;
pwm-led3 = &pwm_led3;
};

pwm_leds {
/delete-node/ pwm_led_0;
pwm_led0: pwm_led_0 {
pwms = <&pwm0 0 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
label = "PWM LED Blue";
};
pwm_led1: pwm_led_1 {
pwms = <&pwm0 3 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
label = "PWM LED Green";
};
pwm_led2: pwm_led_2 {
pwms = <&pwm0 2 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
label = "PWM LED Red";
};
pwm_led3: pwm_led_3 {
pwms = <&pwm0 1 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
label = "PWM IDENTIFY LED Green";
};
};

keys {
/delete-node/ button_1;
/delete-node/ button_3;
compatible = "gpio-keys";
key_1: button_1 {
gpios = <&gpiod 2 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
};
key_2: button_2 {
gpios = <&gpiod 7 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
};
key_3: button_3 {
gpios = <&gpiod 6 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
};
key_4: button_4 {
gpios = <&gpiof 6 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
};

key_matrix_col1: key_matrix_col1 {
gpios = <&gpiod 6 GPIO_ACTIVE_HIGH>;
};
key_matrix_col2: key_matrix_col2 {
gpios = <&gpiof 6 GPIO_ACTIVE_HIGH>;
};
key_matrix_row1: key_matrix_row1 {
gpios = <&gpiod 2 GPIO_PULL_DOWN>;
};
key_matrix_row2: key_matrix_row2 {
gpios = <&gpiod 7 GPIO_PULL_DOWN>;
};
};
};

&pinctrl {
pwm_ch0_pd0_default: pwm_ch0_pd0_default {
pinmux = <B9x_PINMUX_SET(B9x_PORT_D, B9x_PIN_0, B92_FUNC_PWM0)>;
};
pwm_ch1_pd1_default: pwm_ch1_pd1_default {
pinmux = <B9x_PINMUX_SET(B9x_PORT_D, B9x_PIN_1, B92_FUNC_PWM1)>;
};
pwm_ch2_pe2_default: pwm_ch2_pe2_default {
pinmux = <B9x_PINMUX_SET(B9x_PORT_E, B9x_PIN_2, B92_FUNC_PWM2)>;
};
pwm_ch3_pe0_default: pwm_ch3_pe0_default {
pinmux = <B9x_PINMUX_SET(B9x_PORT_E, B9x_PIN_0, B92_FUNC_PWM3)>;
};
};

&pwm0 {
pinctrl-0 = <&pwm_ch0_pd0_default &pwm_ch1_pd1_default &pwm_ch2_pe2_default &pwm_ch3_pe0_default>;
};

&flash {
reg = <0x20000000 0x200000>;

partitions {
/delete-node/ partition@0;
/delete-node/ partition@20000;
/delete-node/ partition@88000;
/delete-node/ partition@f0000;
/delete-node/ partition@f4000;
/delete-node/ partition@fe000;
boot_partition: partition@0 {
label = "mcuboot";
reg = <0x00000000 0x19000>;
};
slot0_partition: partition@19000 {
label = "image-0";
reg = <0x19000 0xee000>;
};
factory_partition: partition@107000 {
label = "factory-data";
reg = <0x107000 0x1000>;
};
storage_partition: partition@108000 {
label = "storage";
reg = <0x108000 0x8000>;
};
slot1_partition: partition@110000 {
label = "image-1";
reg = <0x110000 0xee000>;
};
vendor_partition: partition@1fe000 {
label = "vendor-data";
reg = <0x1fe000 0x2000>;
};
};
};

0 comments on commit 8905974

Please sign in to comment.