diff --git a/docs/guides/ti/enabling_icd_on_ti_devices.md b/docs/guides/ti/enabling_icd_on_ti_devices.md new file mode 100644 index 00000000000000..7e10ceb0c11ee0 --- /dev/null +++ b/docs/guides/ti/enabling_icd_on_ti_devices.md @@ -0,0 +1,59 @@ +# Configuring Intermittently Connected Devices on TI CC13x4 Platforms + +## Overview + +Intermittently Connected Devices are devices in a network that do not always +need to be active. Matter has defined a cluster that helps capture this +behavior; this configuration is ideal for devices that need to operate with low +power consumption or do not have a need to always be on the network. Matter +examples on the TI CC13x4 platform can be configured to act as ICDs. + +## Platform Code Changes + +To configure a TI example as an ICD, open up the `args.gni` file of the example +and set the following parameter to true: + +``` +chip_enable_icd_server = true +``` + +TI examples have only been tested with the ICD Server configuration. To enable +the client configuration, set `chip_enable_icd_client` to true. + +Persistent subscriptions allow devices to attempt resuming existing +subscriptions following a device reset. To enable persistent subscriptions, set +the following parameter to true: + +``` +chip_persist_subscriptions = true +``` + +Subscription timeout resumption allows devices to attempt re-establishing +subscriptions that may have expired. This feature is disabled out of box. + +In addition, various ICD parameters such as idle/active mode duration, active +mode threshold, and polling intervals can be configured in +`src/platform/cc13xx_26xx/cc13x4_26x4/CHIPPlatformConfig.h` + +``` +#define CHIP_CONFIG_ICD_ACTIVE_MODE_DURATION_MS 1000 +#define CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS 500 +#define CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC 300 +#define CHIP_DEVICE_CONFIG_ICD_SLOW_POLL_INTERVAL chip::System::Clock::Milliseconds32(5000) +#define CHIP_DEVICE_CONFIG_ICD_FAST_POLL_INTERVAL chip::System::Clock::Milliseconds32(100) +``` + +## ZAP File Changes + +Open up the ZAP file (in `examples//-common`) for +the example being configured as an ICD. Add the ICD Management Cluster for +Endpoint 0. + +Open up the .matter file (in `examples//-common`) +corresponding to the example and add in the ICDManagement cluster. + +In addition, each endpoint has a list of clusters that it supports. Add the +ICDManagement cluster to this list. + +The lock-app example's .matter file can be used as a reference. These additions +allow the ICDManagement cluster's callbacks to be accessed. diff --git a/examples/all-clusters-app/cc13x4_26x4/BUILD.gn b/examples/all-clusters-app/cc13x4_26x4/BUILD.gn index eb118372b7bd33..a20b07b6441f1d 100644 --- a/examples/all-clusters-app/cc13x4_26x4/BUILD.gn +++ b/examples/all-clusters-app/cc13x4_26x4/BUILD.gn @@ -67,9 +67,7 @@ ti_sysconfig("sysconfig") { cflags = [ "-Wno-comment", - "@" + rebase_path("${target_gen_dir}/sysconfig/ti_ble_app_config.opt", - root_build_dir), - "@" + rebase_path("${target_gen_dir}/sysconfig/ti_build_config.opt", + "@" + rebase_path("${target_gen_dir}/sysconfig/ti_utils_build_compiler.opt", root_build_dir), ] } @@ -117,8 +115,14 @@ ti_simplelink_executable("all-clusters-app") { deps += [ "${chip_root}/third_party/openthread/repo:libopenthread-mtd" ] } + defines = [] + if (custom_factory_data) { - defines = [ "CC13XX_26XX_FACTORY_DATA" ] + defines += [ "CC13XX_26XX_FACTORY_DATA" ] + } + + if (chip_enable_icd_server) { + defines += [ "TI_ICD_ENABLE_SERVER" ] } include_dirs = [ diff --git a/examples/all-clusters-app/cc13x4_26x4/args.gni b/examples/all-clusters-app/cc13x4_26x4/args.gni index 35d9666f3ed07c..f6d58510052473 100644 --- a/examples/all-clusters-app/cc13x4_26x4/args.gni +++ b/examples/all-clusters-app/cc13x4_26x4/args.gni @@ -13,6 +13,7 @@ # limitations under the License. import("//build_overrides/chip.gni") +import("//build_overrides/freertos.gni") import("${chip_root}/config/standalone/args.gni") import("${chip_root}/examples/platform/cc13x4_26x4/args.gni") @@ -52,3 +53,10 @@ matter_software_ver = "0x0001" matter_software_ver_str = "1.0.1+1" custom_factory_data = true + +# ICD Default configurations +chip_enable_icd_server = false +chip_persist_subscriptions = false +chip_subscription_timeout_resumption = false + +freertos_root = "//third_party/connectedhomeip/third_party/ti_simplelink_sdk/repo_cc13xx_cc26xx/source/third_party/freertos" diff --git a/examples/all-clusters-app/cc13x4_26x4/main/AppTask.cpp b/examples/all-clusters-app/cc13x4_26x4/main/AppTask.cpp index f82436346fc241..6df3ff32d1862b 100644 --- a/examples/all-clusters-app/cc13x4_26x4/main/AppTask.cpp +++ b/examples/all-clusters-app/cc13x4_26x4/main/AppTask.cpp @@ -55,6 +55,13 @@ #define APP_TASK_PRIORITY 4 #define APP_EVENT_QUEUE_SIZE 10 +#if (CHIP_CONFIG_ENABLE_ICD_SERVER == 1) +#define LED_ENABLE 0 +#else +#define LED_ENABLE 1 +#endif +#define BUTTON_ENABLE 1 + using namespace ::chip; using namespace ::chip::Credentials; using namespace ::chip::DeviceLayer; @@ -164,38 +171,9 @@ int AppTask::StartAppTask() int AppTask::Init() { - LED_Params ledParams; - Button_Params buttonParams; - cc13xx_26xxLogInit(); - // Initialize LEDs - PLAT_LOG("Initialize LEDs"); - LED_init(); - - LED_Params_init(&ledParams); // default PWM LED - sAppRedHandle = LED_open(CONFIG_LED_RED, &ledParams); - LED_setOff(sAppRedHandle); - - LED_Params_init(&ledParams); // default PWM LED - sAppGreenHandle = LED_open(CONFIG_LED_GREEN, &ledParams); - LED_setOff(sAppGreenHandle); - - // Initialize buttons - PLAT_LOG("Initialize buttons"); - Button_init(); - - Button_Params_init(&buttonParams); - buttonParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGCLICKED; - buttonParams.longPressDuration = 1000U; // ms - sAppLeftHandle = Button_open(CONFIG_BTN_LEFT, &buttonParams); - Button_setCallback(sAppLeftHandle, ButtonLeftEventHandler); - - Button_Params_init(&buttonParams); - buttonParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGCLICKED; - buttonParams.longPressDuration = 1000U; // ms - sAppRightHandle = Button_open(CONFIG_BTN_RIGHT, &buttonParams); - Button_setCallback(sAppRightHandle, ButtonRightEventHandler); + uiInit(); // Init Chip memory management before the stack Platform::MemoryInit(); @@ -218,11 +196,12 @@ int AppTask::Init() #if CHIP_DEVICE_CONFIG_THREAD_FTD ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router); -#elif CONFIG_OPENTHREAD_MTD_SED +#elif CHIP_CONFIG_ENABLE_ICD_SERVER ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SleepyEndDevice); #else ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice); #endif + if (ret != CHIP_NO_ERROR) { PLAT_LOG("ConnectivityMgr().SetThreadDeviceType() failed"); @@ -312,46 +291,6 @@ void AppTask::PostEvent(const AppEvent * aEvent) } } -void AppTask::ButtonLeftEventHandler(Button_Handle handle, Button_EventMask events) -{ - AppEvent event; - event.Type = AppEvent::kEventType_ButtonLeft; - - if (events & Button_EV_CLICKED) - { - event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked; - } - else if (events & Button_EV_LONGCLICKED) - { - event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongClicked; - } - // button callbacks are in ISR context - if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS) - { - /* Failed to post the message */ - } -} - -void AppTask::ButtonRightEventHandler(Button_Handle handle, Button_EventMask events) -{ - AppEvent event; - event.Type = AppEvent::kEventType_ButtonRight; - - if (events & Button_EV_CLICKED) - { - event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked; - } - else if (events & Button_EV_LONGCLICKED) - { - event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongClicked; - } - // button callbacks are in ISR context - if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS) - { - /* Failed to post the message */ - } -} - void AppTask::DispatchEvent(AppEvent * aEvent) { switch (aEvent->Type) @@ -405,3 +344,85 @@ void AppTask::DispatchEvent(AppEvent * aEvent) break; } } + +#if (BUTTON_ENABLE == 1) +void AppTask::ButtonLeftEventHandler(Button_Handle handle, Button_EventMask events) +{ + AppEvent event; + event.Type = AppEvent::kEventType_ButtonLeft; + + if (events & Button_EV_CLICKED) + { + event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked; + } + else if (events & Button_EV_LONGCLICKED) + { + event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongClicked; + } + // button callbacks are in ISR context + if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS) + { + /* Failed to post the message */ + } +} + +void AppTask::ButtonRightEventHandler(Button_Handle handle, Button_EventMask events) +{ + AppEvent event; + event.Type = AppEvent::kEventType_ButtonRight; + + if (events & Button_EV_CLICKED) + { + event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked; + } + else if (events & Button_EV_LONGCLICKED) + { + event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongClicked; + } + // button callbacks are in ISR context + if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS) + { + /* Failed to post the message */ + } +} +#endif // BUTTON_ENABLE + +void AppTask::uiInit(void) +{ +#if (LED_ENABLE == 1) + + LED_Params ledParams; + + // Initialize LEDs + PLAT_LOG("Initialize LEDs"); + LED_init(); + + LED_Params_init(&ledParams); // default PWM LED + sAppRedHandle = LED_open(CONFIG_LED_RED, &ledParams); + LED_setOff(sAppRedHandle); + + LED_Params_init(&ledParams); // default PWM LED + sAppGreenHandle = LED_open(CONFIG_LED_GREEN, &ledParams); + LED_setOff(sAppGreenHandle); +#endif // LED ENABLE + +#if (BUTTON_ENABLE == 1) + Button_Params buttonParams; + + // Initialize buttons + PLAT_LOG("Initialize buttons"); + Button_init(); + + Button_Params_init(&buttonParams); + buttonParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGCLICKED; + buttonParams.longPressDuration = 1000U; // ms + sAppLeftHandle = Button_open(CONFIG_BTN_LEFT, &buttonParams); + Button_setCallback(sAppLeftHandle, ButtonLeftEventHandler); + + Button_Params_init(&buttonParams); + buttonParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGCLICKED; + buttonParams.longPressDuration = 1000U; // ms + sAppRightHandle = Button_open(CONFIG_BTN_RIGHT, &buttonParams); + Button_setCallback(sAppRightHandle, ButtonRightEventHandler); +#endif // BUTTON ENABLE +} diff --git a/examples/all-clusters-app/cc13x4_26x4/main/include/AppTask.h b/examples/all-clusters-app/cc13x4_26x4/main/include/AppTask.h index 6ab8ca425ddbdf..55297d715d95ca 100644 --- a/examples/all-clusters-app/cc13x4_26x4/main/include/AppTask.h +++ b/examples/all-clusters-app/cc13x4_26x4/main/include/AppTask.h @@ -48,6 +48,7 @@ class AppTask int Init(); void DispatchEvent(AppEvent * event); + void uiInit(); static void ButtonLeftEventHandler(Button_Handle handle, Button_EventMask events); static void ButtonRightEventHandler(Button_Handle handle, Button_EventMask events); diff --git a/examples/all-clusters-app/cc13x4_26x4/main/main.cpp b/examples/all-clusters-app/cc13x4_26x4/main/main.cpp index 5a7f6a6b8df072..8162d893d5c198 100644 --- a/examples/all-clusters-app/cc13x4_26x4/main/main.cpp +++ b/examples/all-clusters-app/cc13x4_26x4/main/main.cpp @@ -48,14 +48,6 @@ uint32_t heapSize = TOTAL_ICALL_HEAP_SIZE; // ================================================================================ // FreeRTOS Callbacks // ================================================================================ -extern "C" void vApplicationStackOverflowHook(void) -{ - while (1) - { - ; - } -} - /* Wrapper functions for using the queue registry regardless of whether it is enabled or disabled */ extern "C" void vQueueAddToRegistryWrapper(QueueHandle_t xQueue, const char * pcQueueName) { diff --git a/examples/lighting-app/cc13x4_26x4/BUILD.gn b/examples/lighting-app/cc13x4_26x4/BUILD.gn index 02d9b0b8763ee7..6434af621259d4 100644 --- a/examples/lighting-app/cc13x4_26x4/BUILD.gn +++ b/examples/lighting-app/cc13x4_26x4/BUILD.gn @@ -67,9 +67,7 @@ ti_sysconfig("sysconfig") { cflags = [ "-Wno-comment", - "@" + rebase_path("${target_gen_dir}/sysconfig/ti_ble_app_config.opt", - root_build_dir), - "@" + rebase_path("${target_gen_dir}/sysconfig/ti_build_config.opt", + "@" + rebase_path("${target_gen_dir}/sysconfig/ti_utils_build_compiler.opt", root_build_dir), ] } @@ -99,8 +97,14 @@ ti_simplelink_executable("lighting_app") { deps += [ "${chip_root}/third_party/openthread/repo:libopenthread-mtd" ] } + defines = [] + if (custom_factory_data) { - defines = [ "CC13XX_26XX_FACTORY_DATA" ] + defines += [ "CC13XX_26XX_FACTORY_DATA" ] + } + + if (chip_enable_icd_server) { + defines += [ "TI_ICD_ENABLE_SERVER" ] } include_dirs = [ diff --git a/examples/lighting-app/cc13x4_26x4/args.gni b/examples/lighting-app/cc13x4_26x4/args.gni index c9f4b718ec9aca..640bf6ee57003e 100644 --- a/examples/lighting-app/cc13x4_26x4/args.gni +++ b/examples/lighting-app/cc13x4_26x4/args.gni @@ -13,6 +13,7 @@ # limitations under the License. import("//build_overrides/chip.gni") +import("//build_overrides/freertos.gni") import("${chip_root}/config/standalone/args.gni") import("${chip_root}/examples/platform/cc13x4_26x4/args.gni") @@ -29,13 +30,13 @@ lwip_debug = false chip_enable_ota_requestor = true -chip_openthread_ftd = true +chip_openthread_ftd = false openthread_external_platform = "${chip_root}/third_party/openthread/platforms/cc13x4_26x4:libopenthread-cc13x4_cc26x4" # Disable CHIP Logging -#chip_progress_logging = false -#chip_detail_logging = false -#chip_automation_logging = false +chip_progress_logging = true +chip_detail_logging = true +chip_automation_logging = true # BLE options chip_config_network_layer_ble = true @@ -50,3 +51,11 @@ matter_software_ver = "0x0001" matter_software_ver_str = "1.0.1+1" custom_factory_data = true + +# ICD Default configurations +# when enabled the device will be configured as a sleepy end device +chip_enable_icd_server = false +chip_persist_subscriptions = false +chip_subscription_timeout_resumption = false + +freertos_root = "//third_party/connectedhomeip/third_party/ti_simplelink_sdk/repo_cc13xx_cc26xx/source/third_party/freertos" diff --git a/examples/lighting-app/cc13x4_26x4/src/AppTask.cpp b/examples/lighting-app/cc13x4_26x4/src/AppTask.cpp index 94674a1a787a95..bad302bb6b04ff 100644 --- a/examples/lighting-app/cc13x4_26x4/src/AppTask.cpp +++ b/examples/lighting-app/cc13x4_26x4/src/AppTask.cpp @@ -67,6 +67,13 @@ static uint32_t identify_trigger_effect = IDENTIFY_TRIGGER_EFFECT_FINISH_STOP; #define LIGHTING_APPLICATION_IDENTIFY_ENDPOINT 1 +#if (CHIP_CONFIG_ENABLE_ICD_SERVER == 1) +#define LED_ENABLE 0 +#else +#define LED_ENABLE 1 +#endif +#define BUTTON_ENABLE 1 + using namespace ::chip; using namespace ::chip::app; using namespace ::chip::Credentials; @@ -83,6 +90,11 @@ static DeviceInfoProviderImpl sExampleDeviceInfoProvider; AppTask AppTask::sAppTask; +void uiTurnOn(void); +void uiTurnedOn(void); +void uiTurnOff(void); +void uiTurnedOff(void); + #if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR static DefaultOTARequestor sRequestorCore; static DefaultOTARequestorStorage sRequestorStorage; @@ -129,43 +141,26 @@ int AppTask::StartAppTask() return ret; } -// Action initiated callback -void uiTurnOn(void) +// Identify take action +void identify_TakeAction(void) { - PLAT_LOG("Light On initiated"); - LED_setOn(sAppRedHandle, LED_BRIGHTNESS_MAX); - LED_startBlinking(sAppRedHandle, 110 /* ms */, LED_BLINK_FOREVER); +#if (LED_ENABLE == 1) + LED_setOn(sAppGreenHandle, LED_BRIGHTNESS_MAX); + LED_startBlinking(sAppGreenHandle, 1000, LED_BLINK_FOREVER); +#endif // LED_ENABLE } -// Action completed callback -void uiTurnedOn(void) -{ - PLAT_LOG("Light On completed"); - LED_stopBlinking(sAppRedHandle); - LED_setOn(sAppRedHandle, LED_BRIGHTNESS_MAX); -} - -// Action initiated callback -void uiTurnOff(void) -{ - PLAT_LOG("Light Off initiated"); - LED_setOn(sAppRedHandle, LED_BRIGHTNESS_MAX); - LED_startBlinking(sAppRedHandle, 110 /* ms */, LED_BLINK_FOREVER); -} - -// Action completed callback -void uiTurnedOff(void) +// Identify stop action +void identify_StopAction(void) { - PLAT_LOG("Light Off completed"); - LED_stopBlinking(sAppRedHandle); - LED_setOff(sAppRedHandle); +#if (LED_ENABLE == 1) + LED_stopBlinking(sAppGreenHandle); + LED_setOff(sAppGreenHandle); +#endif // LED_ENABLE } int AppTask::Init() { - LED_Params ledParams; - Button_Params buttonParams; - cc13xx_26xxLogInit(); // Init Chip memory management before the stack @@ -188,9 +183,12 @@ int AppTask::Init() } #if CHIP_DEVICE_CONFIG_THREAD_FTD ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router); +#elif CHIP_CONFIG_ENABLE_ICD_SERVER + ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SleepyEndDevice); #else ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice); #endif + if (ret != CHIP_NO_ERROR) { PLAT_LOG("ConnectivityMgr().SetThreadDeviceType() failed"); @@ -238,33 +236,7 @@ int AppTask::Init() Server::GetInstance().Init(initParams); - // Initialize LEDs - PLAT_LOG("Initialize LEDs"); - LED_init(); - - LED_Params_init(&ledParams); // default PWM LED - sAppRedHandle = LED_open(CONFIG_LED_RED, &ledParams); - LED_setOff(sAppRedHandle); - - LED_Params_init(&ledParams); // default PWM LED - sAppGreenHandle = LED_open(CONFIG_LED_GREEN, &ledParams); - LED_setOff(sAppGreenHandle); - - // Initialize buttons - PLAT_LOG("Initialize buttons"); - Button_init(); - - Button_Params_init(&buttonParams); - buttonParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGCLICKED; - buttonParams.longPressDuration = 1000U; // ms - sAppLeftHandle = Button_open(CONFIG_BTN_LEFT, &buttonParams); - Button_setCallback(sAppLeftHandle, ButtonLeftEventHandler); - - Button_Params_init(&buttonParams); - buttonParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGCLICKED; - buttonParams.longPressDuration = 1000U; // ms - sAppRightHandle = Button_open(CONFIG_BTN_RIGHT, &buttonParams); - Button_setCallback(sAppRightHandle, ButtonRightEventHandler); + uiInit(); ret = LightMgr().Init(); @@ -282,6 +254,7 @@ int AppTask::Init() #if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR InitializeOTARequestor(); #endif + // QR code will be used with CHIP Tool PrintOnboardingCodes(RendezvousInformationFlags(RendezvousInformationFlag::kBLE)); @@ -304,46 +277,6 @@ void AppTask::AppTaskMain(void * pvParameter) } } -void AppTask::ButtonLeftEventHandler(Button_Handle handle, Button_EventMask events) -{ - AppEvent event; - event.Type = AppEvent::kEventType_ButtonLeft; - - if (events & Button_EV_CLICKED) - { - event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked; - } - else if (events & Button_EV_LONGCLICKED) - { - event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongClicked; - } - // button callbacks are in ISR context - if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS) - { - /* Failed to post the message */ - } -} - -void AppTask::ButtonRightEventHandler(Button_Handle handle, Button_EventMask events) -{ - AppEvent event; - event.Type = AppEvent::kEventType_ButtonRight; - - if (events & Button_EV_CLICKED) - { - event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked; - } - else if (events & Button_EV_LONGCLICKED) - { - event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongClicked; - } - // button callbacks are in ISR context - if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS) - { - /* Failed to post the message */ - } -} - void AppTask::ActionInitiated(LightingManager::Action_t aAction, int32_t aActor) { if (aAction == LightingManager::ON_ACTION) @@ -458,16 +391,13 @@ void AppTask::DispatchEvent(AppEvent * aEvent) switch (identify_trigger_effect) { case IDENTIFY_TRIGGER_EFFECT_BLINK: - LED_setOn(sAppGreenHandle, LED_BRIGHTNESS_MAX); - LED_startBlinking(sAppGreenHandle, 1000, LED_BLINK_FOREVER); + identify_TakeAction(); break; case IDENTIFY_TRIGGER_EFFECT_BREATHE: - LED_setOn(sAppGreenHandle, LED_BRIGHTNESS_MAX); - LED_startBlinking(sAppGreenHandle, 100, LED_BLINK_FOREVER); + identify_TakeAction(); break; case IDENTIFY_TRIGGER_EFFECT_OKAY: - LED_setOn(sAppGreenHandle, LED_BRIGHTNESS_MAX); - LED_startBlinking(sAppGreenHandle, 500, LED_BLINK_FOREVER); + identify_TakeAction(); break; default: break; @@ -476,8 +406,7 @@ void AppTask::DispatchEvent(AppEvent * aEvent) break; case AppEvent::kEventType_IdentifyStop: - LED_stopBlinking(sAppGreenHandle); - LED_setOff(sAppGreenHandle); + identify_StopAction(); PLAT_LOG("Identify stopped"); break; @@ -544,3 +473,125 @@ void AppTask::TriggerIdentifyEffectHandler(::Identify * identify) PLAT_LOG("No identifier effect"); } } + +// Action initiated callback +void uiTurnOn(void) +{ + PLAT_LOG("Light On initiated"); +#if (LED_ENABLE == 1) + LED_setOn(sAppRedHandle, LED_BRIGHTNESS_MAX); + LED_startBlinking(sAppRedHandle, 110 /* ms */, LED_BLINK_FOREVER); +#endif // LED_ENABLE +} + +// Action completed callback +void uiTurnedOn(void) +{ + PLAT_LOG("Light On completed"); +#if (LED_ENABLE == 1) + LED_stopBlinking(sAppRedHandle); + LED_setOn(sAppRedHandle, LED_BRIGHTNESS_MAX); +#endif // LED_ENABLE +} + +// Action initiated callback +void uiTurnOff(void) +{ + PLAT_LOG("Light Off initiated"); +#if (LED_ENABLE == 1) + LED_setOn(sAppRedHandle, LED_BRIGHTNESS_MAX); + LED_startBlinking(sAppRedHandle, 110 /* ms */, LED_BLINK_FOREVER); +#endif // LED_ENABLE +} + +// Action completed callback +void uiTurnedOff(void) +{ + PLAT_LOG("Light Off completed"); +#if (LED_ENABLE == 1) + LED_stopBlinking(sAppRedHandle); + LED_setOff(sAppRedHandle); +#endif // LED_ENABLE +} + +#if (BUTTON_ENABLE == 1) +void AppTask::ButtonLeftEventHandler(Button_Handle handle, Button_EventMask events) +{ + AppEvent event; + event.Type = AppEvent::kEventType_ButtonLeft; + + if (events & Button_EV_CLICKED) + { + event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked; + } + else if (events & Button_EV_LONGCLICKED) + { + event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongClicked; + } + // button callbacks are in ISR context + if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS) + { + /* Failed to post the message */ + } +} + +void AppTask::ButtonRightEventHandler(Button_Handle handle, Button_EventMask events) +{ + AppEvent event; + event.Type = AppEvent::kEventType_ButtonRight; + + if (events & Button_EV_CLICKED) + { + event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked; + } + else if (events & Button_EV_LONGCLICKED) + { + event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongClicked; + } + // button callbacks are in ISR context + if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS) + { + /* Failed to post the message */ + } +} +#endif // BUTTON_ENABLE + +void AppTask::uiInit(void) +{ +#if (LED_ENABLE == 1) + + LED_Params ledParams; + + // Initialize LEDs + PLAT_LOG("Initialize LEDs"); + LED_init(); + + LED_Params_init(&ledParams); // default PWM LED + sAppRedHandle = LED_open(CONFIG_LED_RED, &ledParams); + LED_setOff(sAppRedHandle); + + LED_Params_init(&ledParams); // default PWM LED + sAppGreenHandle = LED_open(CONFIG_LED_GREEN, &ledParams); + LED_setOff(sAppGreenHandle); +#endif // LED ENABLE + +#if (BUTTON_ENABLE == 1) + Button_Params buttonParams; + + // Initialize buttons + PLAT_LOG("Initialize buttons"); + Button_init(); + + Button_Params_init(&buttonParams); + buttonParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGCLICKED; + buttonParams.longPressDuration = 1000U; // ms + sAppLeftHandle = Button_open(CONFIG_BTN_LEFT, &buttonParams); + Button_setCallback(sAppLeftHandle, ButtonLeftEventHandler); + + Button_Params_init(&buttonParams); + buttonParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGCLICKED; + buttonParams.longPressDuration = 1000U; // ms + sAppRightHandle = Button_open(CONFIG_BTN_RIGHT, &buttonParams); + Button_setCallback(sAppRightHandle, ButtonRightEventHandler); +#endif // BUTTON ENABLE +} diff --git a/examples/lighting-app/cc13x4_26x4/src/AppTask.h b/examples/lighting-app/cc13x4_26x4/src/AppTask.h index c82a122fef4ea8..653d43607a417b 100644 --- a/examples/lighting-app/cc13x4_26x4/src/AppTask.h +++ b/examples/lighting-app/cc13x4_26x4/src/AppTask.h @@ -69,6 +69,7 @@ class AppTask static void ActionCompleted(LightingManager::Action_t aAction); void DispatchEvent(AppEvent * event); + void uiInit(void); static void UpdateClusterState(intptr_t context); static void SingleButtonEventHandler(AppEvent * aEvent); static void ButtonTimerEventHandler(AppEvent * aEvent); diff --git a/examples/lighting-app/cc13x4_26x4/src/main.cpp b/examples/lighting-app/cc13x4_26x4/src/main.cpp index 6cf27cf79a35fb..d2635ed96e2e28 100644 --- a/examples/lighting-app/cc13x4_26x4/src/main.cpp +++ b/examples/lighting-app/cc13x4_26x4/src/main.cpp @@ -48,14 +48,6 @@ uint32_t heapSize = TOTAL_ICALL_HEAP_SIZE; // ================================================================================ // FreeRTOS Callbacks // ================================================================================ -extern "C" void vApplicationStackOverflowHook(void) -{ - while (1) - { - ; - } -} - /* Wrapper functions for using the queue registry regardless of whether it is enabled or disabled */ extern "C" void vQueueAddToRegistryWrapper(QueueHandle_t xQueue, const char * pcQueueName) { diff --git a/examples/lock-app/cc13x4_26x4/BUILD.gn b/examples/lock-app/cc13x4_26x4/BUILD.gn index aed45f85bce94b..ab32881a6f15eb 100644 --- a/examples/lock-app/cc13x4_26x4/BUILD.gn +++ b/examples/lock-app/cc13x4_26x4/BUILD.gn @@ -63,11 +63,17 @@ ti_sysconfig("sysconfig") { cflags = [ "-Wno-comment", - "@" + rebase_path("${target_gen_dir}/sysconfig/ti_ble_app_config.opt", - root_build_dir), - "@" + rebase_path("${target_gen_dir}/sysconfig/ti_build_config.opt", + "@" + rebase_path("${target_gen_dir}/sysconfig/ti_utils_build_compiler.opt", root_build_dir), ] + + include_dirs = [ + "${ti_simplelink_sdk_root}/source/ti/posix/freertos/", + "${ti_simplelink_sdk_root}/kernel/freertos/", + "${freertos_root}", + "${freertos_root}/include", + "${freertos_root}/portable/GCC/ARM_CM33_NTZ/non_secure/", + ] } ti_simplelink_executable("lock_app") { @@ -95,10 +101,15 @@ ti_simplelink_executable("lock_app") { deps += [ "${chip_root}/third_party/openthread/repo:libopenthread-mtd" ] } + defines = [] + if (custom_factory_data) { - defines = [ "CC13XX_26XX_FACTORY_DATA" ] + defines += [ "CC13XX_26XX_FACTORY_DATA" ] } + if (chip_enable_icd_server) { + defines += [ "TI_ICD_ENABLE_SERVER" ] + } include_dirs = [ "${project_dir}", "${chip_root}/examples/providers/", diff --git a/examples/lock-app/cc13x4_26x4/args.gni b/examples/lock-app/cc13x4_26x4/args.gni index d7508aaa640661..1e92a24dab0c3f 100644 --- a/examples/lock-app/cc13x4_26x4/args.gni +++ b/examples/lock-app/cc13x4_26x4/args.gni @@ -13,6 +13,7 @@ # limitations under the License. import("//build_overrides/chip.gni") +import("//build_overrides/freertos.gni") import("${chip_root}/config/standalone/args.gni") import("${chip_root}/examples/platform/cc13x4_26x4/args.gni") @@ -52,3 +53,10 @@ matter_software_ver_str = "1.0.1+1" # should be maj.min.rev+build with later parts optional for MCUBoot custom_factory_data = true + +# ICD Default configurations +chip_enable_icd_server = false +chip_persist_subscriptions = false +chip_subscription_timeout_resumption = false + +freertos_root = "//third_party/connectedhomeip/third_party/ti_simplelink_sdk/repo_cc13xx_cc26xx/source/third_party/freertos" diff --git a/examples/lock-app/cc13x4_26x4/src/AppTask.cpp b/examples/lock-app/cc13x4_26x4/src/AppTask.cpp index c42d06c705d846..1b65334c47f886 100644 --- a/examples/lock-app/cc13x4_26x4/src/AppTask.cpp +++ b/examples/lock-app/cc13x4_26x4/src/AppTask.cpp @@ -57,6 +57,13 @@ #define APP_TASK_PRIORITY 4 #define APP_EVENT_QUEUE_SIZE 10 +#if (CHIP_CONFIG_ENABLE_ICD_SERVER == 1) +#define LED_ENABLE 0 +#else +#define LED_ENABLE 1 +#endif +#define BUTTON_ENABLE 1 + using namespace ::chip; using namespace ::chip::app; using namespace ::chip::Credentials; @@ -70,6 +77,7 @@ static LED_Handle sAppRedHandle; static LED_Handle sAppGreenHandle; static Button_Handle sAppLeftHandle; static Button_Handle sAppRightHandle; + static DeviceInfoProviderImpl sExampleDeviceInfoProvider; AppTask AppTask::sAppTask; @@ -120,47 +128,31 @@ int AppTask::StartAppTask() return ret; } -void uiLocking(void) -{ - PLAT_LOG("Lock initiated"); - LED_setOn(sAppGreenHandle, LED_BRIGHTNESS_MAX); - LED_startBlinking(sAppGreenHandle, 50 /* ms */, LED_BLINK_FOREVER); - LED_setOn(sAppRedHandle, LED_BRIGHTNESS_MAX); - LED_startBlinking(sAppRedHandle, 110 /* ms */, LED_BLINK_FOREVER); -} - -void uiLocked(void) -{ - PLAT_LOG("Lock completed"); - LED_stopBlinking(sAppGreenHandle); - LED_setOff(sAppGreenHandle); - LED_stopBlinking(sAppRedHandle); - LED_setOn(sAppRedHandle, LED_BRIGHTNESS_MAX); -} +void uiLocking(void); +void uiLocked(void); +void uiUnlocking(void); +void uiUnlocked(void); -void uiUnlocking(void) +// Identify take action +void identify_TakeAction(void) { - PLAT_LOG("Unlock initiated"); +#if (LED_ENABLE == 1) LED_setOn(sAppGreenHandle, LED_BRIGHTNESS_MAX); - LED_startBlinking(sAppGreenHandle, 50 /* ms */, LED_BLINK_FOREVER); - LED_setOn(sAppRedHandle, LED_BRIGHTNESS_MAX); - LED_startBlinking(sAppRedHandle, 110 /* ms */, LED_BLINK_FOREVER); + LED_startBlinking(sAppGreenHandle, 1000, LED_BLINK_FOREVER); +#endif // LED_ENABLE } -void uiUnlocked(void) +// Identify stop action +void identify_StopAction(void) { - PLAT_LOG("Unlock completed"); +#if (LED_ENABLE == 1) LED_stopBlinking(sAppGreenHandle); LED_setOff(sAppGreenHandle); - LED_stopBlinking(sAppRedHandle); - LED_setOff(sAppRedHandle); +#endif // LED_ENABLE } int AppTask::Init() { - LED_Params ledParams; - Button_Params buttonParams; - cc13xx_26xxLogInit(); // Init Chip memory management before the stack @@ -183,9 +175,12 @@ int AppTask::Init() } #if CHIP_DEVICE_CONFIG_THREAD_FTD ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router); +#elif CHIP_CONFIG_ENABLE_ICD_SERVER + ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SleepyEndDevice); #else ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice); #endif + if (ret != CHIP_NO_ERROR) { PLAT_LOG("ConnectivityMgr().SetThreadDeviceType() failed"); @@ -233,33 +228,7 @@ int AppTask::Init() Server::GetInstance().Init(initParams); - // Initialize LEDs - PLAT_LOG("Initialize LEDs"); - LED_init(); - - LED_Params_init(&ledParams); // default PWM LED - sAppRedHandle = LED_open(CONFIG_LED_RED, &ledParams); - LED_setOff(sAppRedHandle); - - LED_Params_init(&ledParams); // default PWM LED - sAppGreenHandle = LED_open(CONFIG_LED_GREEN, &ledParams); - LED_setOff(sAppGreenHandle); - - // Initialize buttons - PLAT_LOG("Initialize buttons"); - Button_init(); - - Button_Params_init(&buttonParams); - buttonParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGCLICKED; - buttonParams.longPressDuration = 1000U; // ms - sAppLeftHandle = Button_open(CONFIG_BTN_LEFT, &buttonParams); - Button_setCallback(sAppLeftHandle, ButtonLeftEventHandler); - - Button_Params_init(&buttonParams); - buttonParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGCLICKED; - buttonParams.longPressDuration = 1000U; // ms - sAppRightHandle = Button_open(CONFIG_BTN_RIGHT, &buttonParams); - Button_setCallback(sAppRightHandle, ButtonRightEventHandler); + uiInit(); PlatformMgr().LockChipStack(); { @@ -356,46 +325,6 @@ void AppTask::AppTaskMain(void * pvParameter) } } -void AppTask::ButtonLeftEventHandler(Button_Handle handle, Button_EventMask events) -{ - AppEvent event; - event.Type = AppEvent::kEventType_ButtonLeft; - - if (events & Button_EV_CLICKED) - { - event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked; - } - else if (events & Button_EV_LONGCLICKED) - { - event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongClicked; - } - // button callbacks are in ISR context - if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS) - { - /* Failed to post the message */ - } -} - -void AppTask::ButtonRightEventHandler(Button_Handle handle, Button_EventMask events) -{ - AppEvent event; - event.Type = AppEvent::kEventType_ButtonRight; - - if (events & Button_EV_CLICKED) - { - event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked; - } - else if (events & Button_EV_LONGCLICKED) - { - event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongClicked; - } - // button callbacks are in ISR context - if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS) - { - /* Failed to post the message */ - } -} - void AppTask::ActionInitiated(LockManager::Action_t aAction) { if (aAction == LockManager::LOCK_ACTION) @@ -498,15 +427,12 @@ void AppTask::DispatchEvent(AppEvent * aEvent) break; case AppEvent::kEventType_IdentifyStart: - LED_setOn(sAppGreenHandle, LED_BRIGHTNESS_MAX); - LED_startBlinking(sAppGreenHandle, 500, LED_BLINK_FOREVER); + identify_TakeAction(); PLAT_LOG("Identify started"); break; case AppEvent::kEventType_IdentifyStop: - LED_stopBlinking(sAppGreenHandle); - - LED_setOff(sAppGreenHandle); + identify_StopAction(); PLAT_LOG("Identify stopped"); break; @@ -565,3 +491,129 @@ void AppTask::TriggerIdentifyEffectHandler(::Identify * identify) PLAT_LOG("No identifier effect"); } } + +void uiLocking(void) +{ +#if LED_ENABLE + PLAT_LOG("Lock initiated"); + LED_setOn(sAppGreenHandle, LED_BRIGHTNESS_MAX); + LED_startBlinking(sAppGreenHandle, 50 /* ms */, LED_BLINK_FOREVER); + LED_setOn(sAppRedHandle, LED_BRIGHTNESS_MAX); + LED_startBlinking(sAppRedHandle, 110 /* ms */, LED_BLINK_FOREVER); +#endif +} + +void uiLocked(void) +{ +#if LED_ENABLE + PLAT_LOG("Lock completed"); + LED_stopBlinking(sAppGreenHandle); + LED_setOff(sAppGreenHandle); + LED_stopBlinking(sAppRedHandle); + LED_setOn(sAppRedHandle, LED_BRIGHTNESS_MAX); +#endif +} + +void uiUnlocking(void) +{ +#if LED_ENABLE + PLAT_LOG("Unlock initiated"); + LED_setOn(sAppGreenHandle, LED_BRIGHTNESS_MAX); + LED_startBlinking(sAppGreenHandle, 50 /* ms */, LED_BLINK_FOREVER); + LED_setOn(sAppRedHandle, LED_BRIGHTNESS_MAX); + LED_startBlinking(sAppRedHandle, 110 /* ms */, LED_BLINK_FOREVER); +#endif +} + +void uiUnlocked(void) +{ +#if LED_ENABLE + PLAT_LOG("Unlock completed"); + LED_stopBlinking(sAppGreenHandle); + LED_setOff(sAppGreenHandle); + LED_stopBlinking(sAppRedHandle); + LED_setOff(sAppRedHandle); +#endif +} + +#if (BUTTON_ENABLE == 1) +void AppTask::ButtonLeftEventHandler(Button_Handle handle, Button_EventMask events) +{ + AppEvent event; + event.Type = AppEvent::kEventType_ButtonLeft; + + if (events & Button_EV_CLICKED) + { + event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked; + } + else if (events & Button_EV_LONGCLICKED) + { + event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongClicked; + } + // button callbacks are in ISR context + if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS) + { + /* Failed to post the message */ + } +} + +void AppTask::ButtonRightEventHandler(Button_Handle handle, Button_EventMask events) +{ + AppEvent event; + event.Type = AppEvent::kEventType_ButtonRight; + + if (events & Button_EV_CLICKED) + { + event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked; + } + else if (events & Button_EV_LONGCLICKED) + { + event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongClicked; + } + // button callbacks are in ISR context + if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS) + { + /* Failed to post the message */ + } +} +#endif // BUTTON_ENABLE + +void AppTask::uiInit(void) +{ +#if (LED_ENABLE == 1) + + LED_Params ledParams; + + // Initialize LEDs + PLAT_LOG("Initialize LEDs"); + LED_init(); + + LED_Params_init(&ledParams); // default PWM LED + sAppRedHandle = LED_open(CONFIG_LED_RED, &ledParams); + LED_setOff(sAppRedHandle); + + LED_Params_init(&ledParams); // default PWM LED + sAppGreenHandle = LED_open(CONFIG_LED_GREEN, &ledParams); + LED_setOff(sAppGreenHandle); +#endif // LED ENABLE + +#if (BUTTON_ENABLE == 1) + Button_Params buttonParams; + + // Initialize buttons + PLAT_LOG("Initialize buttons"); + Button_init(); + + Button_Params_init(&buttonParams); + buttonParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGCLICKED; + buttonParams.longPressDuration = 1000U; // ms + sAppLeftHandle = Button_open(CONFIG_BTN_LEFT, &buttonParams); + Button_setCallback(sAppLeftHandle, ButtonLeftEventHandler); + + Button_Params_init(&buttonParams); + buttonParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGCLICKED; + buttonParams.longPressDuration = 1000U; // ms + sAppRightHandle = Button_open(CONFIG_BTN_RIGHT, &buttonParams); + Button_setCallback(sAppRightHandle, ButtonRightEventHandler); +#endif // BUTTON ENABLE +} diff --git a/examples/lock-app/cc13x4_26x4/src/AppTask.h b/examples/lock-app/cc13x4_26x4/src/AppTask.h index 7778fd5f2a5e1f..8f1426933cc725 100644 --- a/examples/lock-app/cc13x4_26x4/src/AppTask.h +++ b/examples/lock-app/cc13x4_26x4/src/AppTask.h @@ -69,7 +69,7 @@ class AppTask static void ActionCompleted(LockManager::Action_t aAction); void DispatchEvent(AppEvent * event); - + void uiInit(void); static void ButtonLeftEventHandler(Button_Handle handle, Button_EventMask events); static void ButtonRightEventHandler(Button_Handle handle, Button_EventMask events); static void TimerEventHandler(void * p_context); diff --git a/examples/lock-app/cc13x4_26x4/src/main.cpp b/examples/lock-app/cc13x4_26x4/src/main.cpp index 6cf27cf79a35fb..35588f6552e484 100644 --- a/examples/lock-app/cc13x4_26x4/src/main.cpp +++ b/examples/lock-app/cc13x4_26x4/src/main.cpp @@ -48,13 +48,6 @@ uint32_t heapSize = TOTAL_ICALL_HEAP_SIZE; // ================================================================================ // FreeRTOS Callbacks // ================================================================================ -extern "C" void vApplicationStackOverflowHook(void) -{ - while (1) - { - ; - } -} /* Wrapper functions for using the queue registry regardless of whether it is enabled or disabled */ extern "C" void vQueueAddToRegistryWrapper(QueueHandle_t xQueue, const char * pcQueueName) diff --git a/examples/pump-app/cc13x4_26x4/BUILD.gn b/examples/pump-app/cc13x4_26x4/BUILD.gn index 8c68ba70066315..d20d2d8a392c64 100644 --- a/examples/pump-app/cc13x4_26x4/BUILD.gn +++ b/examples/pump-app/cc13x4_26x4/BUILD.gn @@ -66,9 +66,7 @@ ti_sysconfig("sysconfig") { cflags = [ "-Wno-comment", - "@" + rebase_path("${target_gen_dir}/sysconfig/ti_ble_app_config.opt", - root_build_dir), - "@" + rebase_path("${target_gen_dir}/sysconfig/ti_build_config.opt", + "@" + rebase_path("${target_gen_dir}/sysconfig/ti_utils_build_compiler.opt", root_build_dir), ] } @@ -99,8 +97,14 @@ ti_simplelink_executable("pump_app") { deps += [ "${chip_root}/third_party/openthread/repo:libopenthread-mtd" ] } + defines = [] + if (custom_factory_data) { - defines = [ "CC13XX_26XX_FACTORY_DATA" ] + defines += [ "CC13XX_26XX_FACTORY_DATA" ] + } + + if (chip_enable_icd_server) { + defines += [ "TI_ICD_ENABLE_SERVER" ] } include_dirs = [ diff --git a/examples/pump-app/cc13x4_26x4/args.gni b/examples/pump-app/cc13x4_26x4/args.gni index 05c67f203ca2a9..94b3913ed26045 100644 --- a/examples/pump-app/cc13x4_26x4/args.gni +++ b/examples/pump-app/cc13x4_26x4/args.gni @@ -13,6 +13,7 @@ # limitations under the License. import("//build_overrides/chip.gni") +import("//build_overrides/freertos.gni") import("${chip_root}/config/standalone/args.gni") import("${chip_root}/examples/platform/cc13x4_26x4/args.gni") @@ -50,3 +51,10 @@ matter_software_ver = "0x0001" matter_software_ver_str = "1.0.1+1" custom_factory_data = true + +# ICD Default configurations +chip_enable_icd_server = false +chip_persist_subscriptions = false +chip_subscription_timeout_resumption = false + +freertos_root = "//third_party/connectedhomeip/third_party/ti_simplelink_sdk/repo_cc13xx_cc26xx/source/third_party/freertos" diff --git a/examples/pump-app/cc13x4_26x4/main/AppTask.cpp b/examples/pump-app/cc13x4_26x4/main/AppTask.cpp index ea094e96767665..402339bf576071 100644 --- a/examples/pump-app/cc13x4_26x4/main/AppTask.cpp +++ b/examples/pump-app/cc13x4_26x4/main/AppTask.cpp @@ -63,6 +63,13 @@ #define ONOFF_CLUSTER_ENDPOINT 1 #define EXTENDED_DISCOVERY_TIMEOUT_SEC 20 +#if (CHIP_CONFIG_ENABLE_ICD_SERVER == 1) +#define LED_ENABLE 0 +#else +#define LED_ENABLE 1 +#endif +#define BUTTON_ENABLE 1 + using namespace chip; using namespace chip::app; using namespace chip::Credentials; @@ -133,9 +140,6 @@ int AppTask::StartAppTask() int AppTask::Init() { - LED_Params ledParams; - Button_Params buttonParams; - cc13xx_26xxLogInit(); // Init Chip memory management before the stack @@ -159,11 +163,12 @@ int AppTask::Init() #if CHIP_DEVICE_CONFIG_THREAD_FTD ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router); -#elif CONFIG_OPENTHREAD_MTD_SED +#elif CHIP_CONFIG_ENABLE_ICD_SERVER ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SleepyEndDevice); #else ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice); #endif + if (ret != CHIP_NO_ERROR) { PLAT_LOG("ConnectivityMgr().SetThreadDeviceType() failed"); @@ -179,33 +184,7 @@ int AppTask::Init() ; } - // Initialize LEDs - PLAT_LOG("Initialize LEDs"); - LED_init(); - - LED_Params_init(&ledParams); // default PWM LED - sAppRedHandle = LED_open(CONFIG_LED_RED, &ledParams); - LED_setOff(sAppRedHandle); - - LED_Params_init(&ledParams); // default PWM LED - sAppGreenHandle = LED_open(CONFIG_LED_GREEN, &ledParams); - LED_setOff(sAppGreenHandle); - - // Initialize buttons - PLAT_LOG("Initialize buttons"); - Button_init(); - - Button_Params_init(&buttonParams); - buttonParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGPRESSED; - buttonParams.longPressDuration = 5000U; // ms - sAppLeftHandle = Button_open(CONFIG_BTN_LEFT, &buttonParams); - Button_setCallback(sAppLeftHandle, ButtonLeftEventHandler); - - Button_Params_init(&buttonParams); - buttonParams.buttonEventMask = Button_EV_CLICKED; - buttonParams.longPressDuration = 1000U; // ms - sAppRightHandle = Button_open(CONFIG_BTN_RIGHT, &buttonParams); - Button_setCallback(sAppRightHandle, ButtonRightEventHandler); + uiInit(); // Initialize device attestation config #ifdef CC13X4_26X4_ATTESTATION_CREDENTIALS @@ -280,42 +259,6 @@ void AppTask::PostEvent(const AppEvent * aEvent) } } -void AppTask::ButtonLeftEventHandler(Button_Handle handle, Button_EventMask events) -{ - AppEvent event; - event.Type = AppEvent::kEventType_ButtonLeft; - - if (events & Button_EV_CLICKED) - { - event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked; - } - else if (events & Button_EV_LONGPRESSED) - { - event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongPressed; - } - // button callbacks are in ISR context - if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS) - { - /* Failed to post the message */ - } -} - -void AppTask::ButtonRightEventHandler(Button_Handle handle, Button_EventMask events) -{ - AppEvent event; - event.Type = AppEvent::kEventType_ButtonRight; - - if (events & Button_EV_CLICKED) - { - event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked; - } - // button callbacks are in ISR context - if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS) - { - /* Failed to post the message */ - } -} - void AppTask::ActionInitiated(PumpManager::Action_t aAction, int32_t aActor) { // If the action has been initiated by the pump, update the pump trait @@ -330,11 +273,12 @@ void AppTask::ActionInitiated(PumpManager::Action_t aAction, int32_t aActor) PLAT_LOG("Stop initiated"); ; // TODO } - +#if (LED_ENABLE == 1) LED_setOn(sAppGreenHandle, LED_BRIGHTNESS_MAX); LED_startBlinking(sAppGreenHandle, 50 /* ms */, LED_BLINK_FOREVER); LED_setOn(sAppRedHandle, LED_BRIGHTNESS_MAX); LED_startBlinking(sAppRedHandle, 110 /* ms */, LED_BLINK_FOREVER); +#endif } void AppTask::ActionCompleted(PumpManager::Action_t aAction, int32_t aActor) @@ -345,20 +289,24 @@ void AppTask::ActionCompleted(PumpManager::Action_t aAction, int32_t aActor) if (aAction == PumpManager::START_ACTION) { PLAT_LOG("Pump start completed"); +#if (LED_ENABLE == 1) LED_stopBlinking(sAppGreenHandle); LED_setOn(sAppGreenHandle, LED_BRIGHTNESS_MAX); LED_stopBlinking(sAppRedHandle); LED_setOn(sAppRedHandle, LED_BRIGHTNESS_MAX); +#endif // Signal to the PCC cluster, that the pump is running sAppTask.UpdateClusterState(); } else if (aAction == PumpManager::STOP_ACTION) { PLAT_LOG("Pump stop completed"); +#if (LED_ENABLE == 1) LED_stopBlinking(sAppGreenHandle); LED_setOff(sAppGreenHandle); LED_stopBlinking(sAppRedHandle); LED_setOff(sAppRedHandle); +#endif // Signal to the PCC cluster, that the pump is NOT running sAppTask.UpdateClusterState(); } @@ -421,14 +369,16 @@ void AppTask::DispatchEvent(AppEvent * aEvent) break; case AppEvent::kEventType_IdentifyStart: +#if (LED_ENABLE == 1) LED_setOn(sAppGreenHandle, LED_BRIGHTNESS_MAX); LED_startBlinking(sAppGreenHandle, sIdentifyBlinkRateMs, LED_BLINK_FOREVER); +#endif PLAT_LOG("Identify started"); break; case AppEvent::kEventType_IdentifyStop: +#if (LED_ENABLE == 1) LED_stopBlinking(sAppGreenHandle); - if (!PumpMgr().IsStopped()) { LED_setOn(sAppGreenHandle, LED_BRIGHTNESS_MAX); @@ -437,6 +387,7 @@ void AppTask::DispatchEvent(AppEvent * aEvent) { LED_setOff(sAppGreenHandle); } +#endif PLAT_LOG("Identify stopped"); break; @@ -680,3 +631,85 @@ void AppTask::TriggerIdentifyEffectHandler(::Identify * identify) PLAT_LOG("No identifier effect"); } } + +#if (BUTTON_ENABLE == 1) +void AppTask::ButtonLeftEventHandler(Button_Handle handle, Button_EventMask events) +{ + AppEvent event; + event.Type = AppEvent::kEventType_ButtonLeft; + + if (events & Button_EV_CLICKED) + { + event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked; + } + else if (events & Button_EV_LONGCLICKED) + { + event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongClicked; + } + // button callbacks are in ISR context + if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS) + { + /* Failed to post the message */ + } +} + +void AppTask::ButtonRightEventHandler(Button_Handle handle, Button_EventMask events) +{ + AppEvent event; + event.Type = AppEvent::kEventType_ButtonRight; + + if (events & Button_EV_CLICKED) + { + event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked; + } + else if (events & Button_EV_LONGCLICKED) + { + event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongClicked; + } + // button callbacks are in ISR context + if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS) + { + /* Failed to post the message */ + } +} +#endif // BUTTON_ENABLE + +void AppTask::uiInit(void) +{ +#if (LED_ENABLE == 1) + + LED_Params ledParams; + + // Initialize LEDs + PLAT_LOG("Initialize LEDs"); + LED_init(); + + LED_Params_init(&ledParams); // default PWM LED + sAppRedHandle = LED_open(CONFIG_LED_RED, &ledParams); + LED_setOff(sAppRedHandle); + + LED_Params_init(&ledParams); // default PWM LED + sAppGreenHandle = LED_open(CONFIG_LED_GREEN, &ledParams); + LED_setOff(sAppGreenHandle); +#endif // LED ENABLE + +#if (BUTTON_ENABLE == 1) + Button_Params buttonParams; + + // Initialize buttons + PLAT_LOG("Initialize buttons"); + Button_init(); + + Button_Params_init(&buttonParams); + buttonParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGCLICKED; + buttonParams.longPressDuration = 1000U; // ms + sAppLeftHandle = Button_open(CONFIG_BTN_LEFT, &buttonParams); + Button_setCallback(sAppLeftHandle, ButtonLeftEventHandler); + + Button_Params_init(&buttonParams); + buttonParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGCLICKED; + buttonParams.longPressDuration = 1000U; // ms + sAppRightHandle = Button_open(CONFIG_BTN_RIGHT, &buttonParams); + Button_setCallback(sAppRightHandle, ButtonRightEventHandler); +#endif // BUTTON ENABLE +} diff --git a/examples/pump-app/cc13x4_26x4/main/include/AppTask.h b/examples/pump-app/cc13x4_26x4/main/include/AppTask.h index 47b4fd56f2d671..ceba04b3c88cb5 100644 --- a/examples/pump-app/cc13x4_26x4/main/include/AppTask.h +++ b/examples/pump-app/cc13x4_26x4/main/include/AppTask.h @@ -64,6 +64,7 @@ class AppTask static void UpdateCluster(intptr_t context); void DispatchEvent(AppEvent * event); + void uiInit(void); static void ButtonLeftEventHandler(Button_Handle handle, Button_EventMask events); static void ButtonRightEventHandler(Button_Handle handle, Button_EventMask events); diff --git a/examples/pump-app/cc13x4_26x4/main/main.cpp b/examples/pump-app/cc13x4_26x4/main/main.cpp index ba98379ecc741a..84b66b755d1850 100644 --- a/examples/pump-app/cc13x4_26x4/main/main.cpp +++ b/examples/pump-app/cc13x4_26x4/main/main.cpp @@ -48,14 +48,6 @@ uint32_t heapSize = TOTAL_ICALL_HEAP_SIZE; // ================================================================================ // FreeRTOS Callbacks // ================================================================================ -extern "C" void vApplicationStackOverflowHook(void) -{ - while (true) - { - ; - } -} - /* Wrapper functions for using the queue registry regardless of whether it is enabled or disabled */ extern "C" void vQueueAddToRegistryWrapper(QueueHandle_t xQueue, const char * pcQueueName) { diff --git a/examples/pump-controller-app/cc13x4_26x4/BUILD.gn b/examples/pump-controller-app/cc13x4_26x4/BUILD.gn index 289b10de001294..61aa833752ed47 100644 --- a/examples/pump-controller-app/cc13x4_26x4/BUILD.gn +++ b/examples/pump-controller-app/cc13x4_26x4/BUILD.gn @@ -67,9 +67,7 @@ ti_sysconfig("sysconfig") { cflags = [ "-Wno-comment", - "@" + rebase_path("${target_gen_dir}/sysconfig/ti_ble_app_config.opt", - root_build_dir), - "@" + rebase_path("${target_gen_dir}/sysconfig/ti_build_config.opt", + "@" + rebase_path("${target_gen_dir}/sysconfig/ti_utils_build_compiler.opt", root_build_dir), ] } @@ -98,8 +96,14 @@ ti_simplelink_executable("pump_controller_app") { deps += [ "${chip_root}/third_party/openthread/repo:libopenthread-mtd" ] } + defines = [] + if (custom_factory_data) { - defines = [ "CC13XX_26XX_FACTORY_DATA" ] + defines += [ "CC13XX_26XX_FACTORY_DATA" ] + } + + if (chip_enable_icd_server) { + defines += [ "TI_ICD_ENABLE_SERVER" ] } include_dirs = [ diff --git a/examples/pump-controller-app/cc13x4_26x4/args.gni b/examples/pump-controller-app/cc13x4_26x4/args.gni index e2beed52434bcf..0aecbe27208f5e 100644 --- a/examples/pump-controller-app/cc13x4_26x4/args.gni +++ b/examples/pump-controller-app/cc13x4_26x4/args.gni @@ -13,6 +13,7 @@ # limitations under the License. import("//build_overrides/chip.gni") +import("//build_overrides/freertos.gni") import("${chip_root}/config/standalone/args.gni") import("${chip_root}/examples/platform/cc13x4_26x4/args.gni") @@ -50,3 +51,10 @@ matter_software_ver = "0x0001" matter_software_ver_str = "1.0.1+1" custom_factory_data = true + +# ICD Default configurations +chip_enable_icd_server = false +chip_persist_subscriptions = false +chip_subscription_timeout_resumption = false + +freertos_root = "//third_party/connectedhomeip/third_party/ti_simplelink_sdk/repo_cc13xx_cc26xx/source/third_party/freertos" diff --git a/examples/pump-controller-app/cc13x4_26x4/chip.syscfg b/examples/pump-controller-app/cc13x4_26x4/chip.syscfg index e4ae2b6acfbbd2..d0cdc696f0e832 100644 --- a/examples/pump-controller-app/cc13x4_26x4/chip.syscfg +++ b/examples/pump-controller-app/cc13x4_26x4/chip.syscfg @@ -175,6 +175,7 @@ LED2.$hardware = system.deviceData.board.components.LED_GREEN; LED2.gpioPin.$name = "CONFIG_GPIO_GLED"; LED2.gpioPin.mode = "Output"; + /* Debug UART */ UART2.$hardware = system.deviceData.board.components.XDS110UART; UART2.$name = "CONFIG_UART2_DEBUG"; diff --git a/examples/pump-controller-app/cc13x4_26x4/main/AppTask.cpp b/examples/pump-controller-app/cc13x4_26x4/main/AppTask.cpp index a8a61bda096d22..2a499a9fd89a54 100644 --- a/examples/pump-controller-app/cc13x4_26x4/main/AppTask.cpp +++ b/examples/pump-controller-app/cc13x4_26x4/main/AppTask.cpp @@ -55,6 +55,13 @@ #define APP_TASK_PRIORITY 4 #define APP_EVENT_QUEUE_SIZE 10 +#if (CHIP_CONFIG_ENABLE_ICD_SERVER == 1) +#define LED_ENABLE 0 +#else +#define LED_ENABLE 1 +#endif +#define BUTTON_ENABLE 1 + using namespace ::chip; using namespace ::chip::app; using namespace ::chip::Credentials; @@ -119,11 +126,26 @@ int AppTask::StartAppTask() return ret; } -int AppTask::Init() +// Identify take action +void identify_TakeAction(void) { - LED_Params ledParams; - Button_Params buttonParams; +#if (LED_ENABLE == 1) + LED_setOn(sAppGreenHandle, LED_BRIGHTNESS_MAX); + LED_startBlinking(sAppGreenHandle, 1000, LED_BLINK_FOREVER); +#endif // LED_ENABLE +} +// Identify stop action +void identify_StopAction(void) +{ +#if (LED_ENABLE == 1) + LED_stopBlinking(sAppGreenHandle); + LED_setOff(sAppGreenHandle); +#endif // LED_ENABLE +} + +int AppTask::Init() +{ cc13xx_26xxLogInit(); // Init Chip memory management before the stack @@ -147,7 +169,7 @@ int AppTask::Init() #if CHIP_DEVICE_CONFIG_THREAD_FTD ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router); -#elif CONFIG_OPENTHREAD_MTD_SED +#elif CHIP_CONFIG_ENABLE_ICD_SERVER ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SleepyEndDevice); #else ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice); @@ -195,33 +217,7 @@ int AppTask::Init() (void) initParams.InitializeStaticResourcesBeforeServerInit(); chip::Server::GetInstance().Init(initParams); - // Initialize LEDs - PLAT_LOG("Initialize LEDs"); - LED_init(); - - LED_Params_init(&ledParams); // default PWM LED - sAppRedHandle = LED_open(CONFIG_LED_RED, &ledParams); - LED_setOff(sAppRedHandle); - - LED_Params_init(&ledParams); // default PWM LED - sAppGreenHandle = LED_open(CONFIG_LED_GREEN, &ledParams); - LED_setOff(sAppGreenHandle); - - // Initialize buttons - PLAT_LOG("Initialize buttons"); - Button_init(); - - Button_Params_init(&buttonParams); - buttonParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGPRESSED; - buttonParams.longPressDuration = 5000U; // ms - sAppLeftHandle = Button_open(CONFIG_BTN_LEFT, &buttonParams); - Button_setCallback(sAppLeftHandle, ButtonLeftEventHandler); - - Button_Params_init(&buttonParams); - buttonParams.buttonEventMask = Button_EV_CLICKED; - buttonParams.longPressDuration = 1000U; // ms - sAppRightHandle = Button_open(CONFIG_BTN_RIGHT, &buttonParams); - Button_setCallback(sAppRightHandle, ButtonRightEventHandler); + uiInit(); // Initialize Pump module PLAT_LOG("Initialize Pump"); @@ -265,42 +261,6 @@ void AppTask::PostEvent(const AppEvent * aEvent) } } -void AppTask::ButtonLeftEventHandler(Button_Handle handle, Button_EventMask events) -{ - AppEvent event; - event.Type = AppEvent::kEventType_ButtonLeft; - - if (events & Button_EV_CLICKED) - { - event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked; - } - else if (events & Button_EV_LONGPRESSED) - { - event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongPressed; - } - // button callbacks are in ISR context - if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS) - { - /* Failed to post the message */ - } -} - -void AppTask::ButtonRightEventHandler(Button_Handle handle, Button_EventMask events) -{ - AppEvent event; - event.Type = AppEvent::kEventType_ButtonRight; - - if (events & Button_EV_CLICKED) - { - event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked; - } - // button callbacks are in ISR context - if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS) - { - /* Failed to post the message */ - } -} - void AppTask::ActionInitiated(PumpManager::Action_t aAction, int32_t aActor) { // If the action has been initiated by the pump, update the pump trait @@ -315,11 +275,12 @@ void AppTask::ActionInitiated(PumpManager::Action_t aAction, int32_t aActor) PLAT_LOG("Stop initiated"); ; // TODO } - +#if (LED_ENABLE == 1) LED_setOn(sAppGreenHandle, LED_BRIGHTNESS_MAX); LED_startBlinking(sAppGreenHandle, 50 /* ms */, LED_BLINK_FOREVER); LED_setOn(sAppRedHandle, LED_BRIGHTNESS_MAX); LED_startBlinking(sAppRedHandle, 110 /* ms */, LED_BLINK_FOREVER); +#endif } void AppTask::ActionCompleted(PumpManager::Action_t aAction, int32_t aActor) @@ -330,18 +291,22 @@ void AppTask::ActionCompleted(PumpManager::Action_t aAction, int32_t aActor) if (aAction == PumpManager::START_ACTION) { PLAT_LOG("Pump start completed"); +#if (LED_ENABLE == 1) LED_stopBlinking(sAppGreenHandle); LED_setOn(sAppGreenHandle, LED_BRIGHTNESS_MAX); LED_stopBlinking(sAppRedHandle); LED_setOn(sAppRedHandle, LED_BRIGHTNESS_MAX); +#endif } else if (aAction == PumpManager::STOP_ACTION) { PLAT_LOG("Pump stop completed"); +#if (LED_ENABLE == 1) LED_stopBlinking(sAppGreenHandle); LED_setOff(sAppGreenHandle); LED_stopBlinking(sAppRedHandle); LED_setOff(sAppRedHandle); +#endif } if (aActor == AppEvent::kEventType_ButtonLeft) { @@ -397,12 +362,12 @@ void AppTask::DispatchEvent(AppEvent * aEvent) break; case AppEvent::kEventType_IdentifyStart: - LED_setOn(sAppGreenHandle, LED_BRIGHTNESS_MAX); - LED_startBlinking(sAppGreenHandle, sIdentifyBlinkRateMs, LED_BLINK_FOREVER); + identify_TakeAction(); PLAT_LOG("Identify started"); break; case AppEvent::kEventType_IdentifyStop: +#if (LED_ENABLE == 1) LED_stopBlinking(sAppGreenHandle); if (!PumpMgr().IsStopped()) @@ -413,6 +378,7 @@ void AppTask::DispatchEvent(AppEvent * aEvent) { LED_setOff(sAppGreenHandle); } +#endif PLAT_LOG("Identify stopped"); break; @@ -473,3 +439,85 @@ void AppTask::TriggerIdentifyEffectHandler(::Identify * identify) PLAT_LOG("No identifier effect"); } } + +#if (BUTTON_ENABLE == 1) +void AppTask::ButtonLeftEventHandler(Button_Handle handle, Button_EventMask events) +{ + AppEvent event; + event.Type = AppEvent::kEventType_ButtonLeft; + + if (events & Button_EV_CLICKED) + { + event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked; + } + else if (events & Button_EV_LONGCLICKED) + { + event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongClicked; + } + // button callbacks are in ISR context + if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS) + { + /* Failed to post the message */ + } +} + +void AppTask::ButtonRightEventHandler(Button_Handle handle, Button_EventMask events) +{ + AppEvent event; + event.Type = AppEvent::kEventType_ButtonRight; + + if (events & Button_EV_CLICKED) + { + event.ButtonEvent.Type = AppEvent::kAppEventButtonType_Clicked; + } + else if (events & Button_EV_LONGCLICKED) + { + event.ButtonEvent.Type = AppEvent::kAppEventButtonType_LongClicked; + } + // button callbacks are in ISR context + if (xQueueSendFromISR(sAppEventQueue, &event, NULL) != pdPASS) + { + /* Failed to post the message */ + } +} +#endif // BUTTON_ENABLE + +void AppTask::uiInit(void) +{ +#if (LED_ENABLE == 1) + + LED_Params ledParams; + + // Initialize LEDs + PLAT_LOG("Initialize LEDs"); + LED_init(); + + LED_Params_init(&ledParams); // default PWM LED + sAppRedHandle = LED_open(CONFIG_LED_RED, &ledParams); + LED_setOff(sAppRedHandle); + + LED_Params_init(&ledParams); // default PWM LED + sAppGreenHandle = LED_open(CONFIG_LED_GREEN, &ledParams); + LED_setOff(sAppGreenHandle); +#endif // LED ENABLE + +#if (BUTTON_ENABLE == 1) + Button_Params buttonParams; + + // Initialize buttons + PLAT_LOG("Initialize buttons"); + Button_init(); + + Button_Params_init(&buttonParams); + buttonParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGCLICKED; + buttonParams.longPressDuration = 1000U; // ms + sAppLeftHandle = Button_open(CONFIG_BTN_LEFT, &buttonParams); + Button_setCallback(sAppLeftHandle, ButtonLeftEventHandler); + + Button_Params_init(&buttonParams); + buttonParams.buttonEventMask = Button_EV_CLICKED | Button_EV_LONGCLICKED; + buttonParams.longPressDuration = 1000U; // ms + sAppRightHandle = Button_open(CONFIG_BTN_RIGHT, &buttonParams); + Button_setCallback(sAppRightHandle, ButtonRightEventHandler); +#endif // BUTTON ENABLE +} diff --git a/examples/pump-controller-app/cc13x4_26x4/main/include/AppTask.h b/examples/pump-controller-app/cc13x4_26x4/main/include/AppTask.h index bb815585471add..b53663a19684c5 100644 --- a/examples/pump-controller-app/cc13x4_26x4/main/include/AppTask.h +++ b/examples/pump-controller-app/cc13x4_26x4/main/include/AppTask.h @@ -60,6 +60,7 @@ class AppTask static void ActionCompleted(PumpManager::Action_t aAction, int32_t aActor); void DispatchEvent(AppEvent * event); + void uiInit(void); static void ButtonLeftEventHandler(Button_Handle handle, Button_EventMask events); static void ButtonRightEventHandler(Button_Handle handle, Button_EventMask events); diff --git a/examples/pump-controller-app/cc13x4_26x4/main/main.cpp b/examples/pump-controller-app/cc13x4_26x4/main/main.cpp index ba98379ecc741a..84b66b755d1850 100644 --- a/examples/pump-controller-app/cc13x4_26x4/main/main.cpp +++ b/examples/pump-controller-app/cc13x4_26x4/main/main.cpp @@ -48,14 +48,6 @@ uint32_t heapSize = TOTAL_ICALL_HEAP_SIZE; // ================================================================================ // FreeRTOS Callbacks // ================================================================================ -extern "C" void vApplicationStackOverflowHook(void) -{ - while (true) - { - ; - } -} - /* Wrapper functions for using the queue registry regardless of whether it is enabled or disabled */ extern "C" void vQueueAddToRegistryWrapper(QueueHandle_t xQueue, const char * pcQueueName) { diff --git a/examples/shell/cc13x4_26x4/BUILD.gn b/examples/shell/cc13x4_26x4/BUILD.gn index 2480f085783384..9a2e3f2f3263ce 100644 --- a/examples/shell/cc13x4_26x4/BUILD.gn +++ b/examples/shell/cc13x4_26x4/BUILD.gn @@ -63,9 +63,7 @@ ti_sysconfig("sysconfig") { cflags = [ "-Wno-comment", - "@" + rebase_path("${target_gen_dir}/sysconfig/ti_ble_app_config.opt", - root_build_dir), - "@" + rebase_path("${target_gen_dir}/sysconfig/ti_build_config.opt", + "@" + rebase_path("${target_gen_dir}/sysconfig/ti_utils_build_compiler.opt", root_build_dir), ] } @@ -98,8 +96,14 @@ ti_simplelink_executable("shell_app") { deps += [ "${chip_root}/third_party/openthread/repo:libopenthread-mtd" ] } + defines = [] + if (custom_factory_data) { - defines = [ "CC13XX_26XX_FACTORY_DATA" ] + defines += [ "CC13XX_26XX_FACTORY_DATA" ] + } + + if (chip_enable_icd_server) { + defines += [ "TI_ICD_ENABLE_SERVER" ] } include_dirs = [ diff --git a/examples/shell/cc13x4_26x4/args.gni b/examples/shell/cc13x4_26x4/args.gni index 6726b735b8e43a..21f752427ef41a 100644 --- a/examples/shell/cc13x4_26x4/args.gni +++ b/examples/shell/cc13x4_26x4/args.gni @@ -13,6 +13,7 @@ # limitations under the License. import("//build_overrides/chip.gni") +import("//build_overrides/freertos.gni") import("${chip_root}/examples/platform/cc13x4_26x4/args.gni") ti_simplelink_sdk_target = get_label_info(":sdk", "label_no_toolchain") @@ -51,3 +52,10 @@ matter_software_ver = "0x0001" matter_software_ver_str = "1.0.1+1" custom_factory_data = true + +# ICD Default configurations +chip_enable_icd_server = false +chip_persist_subscriptions = false +chip_subscription_timeout_resumption = false + +freertos_root = "//third_party/connectedhomeip/third_party/ti_simplelink_sdk/repo_cc13xx_cc26xx/source/third_party/freertos" diff --git a/examples/shell/cc13x4_26x4/main/AppTask.cpp b/examples/shell/cc13x4_26x4/main/AppTask.cpp index 2c6aadaef69772..83684b0fbcd592 100644 --- a/examples/shell/cc13x4_26x4/main/AppTask.cpp +++ b/examples/shell/cc13x4_26x4/main/AppTask.cpp @@ -122,7 +122,7 @@ CHIP_ERROR AppTask::Init() ; } -#ifdef CONFIG_OPENTHREAD_MTD_SED +#ifdef CHIP_CONFIG_ENABLE_ICD_SERVER ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SleepyEndDevice); #elif CONFIG_OPENTHREAD_MTD ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice); diff --git a/examples/shell/cc13x4_26x4/main/main.cpp b/examples/shell/cc13x4_26x4/main/main.cpp index 93b5f9115428be..5f1e200546a5c3 100644 --- a/examples/shell/cc13x4_26x4/main/main.cpp +++ b/examples/shell/cc13x4_26x4/main/main.cpp @@ -48,14 +48,6 @@ uint32_t heapSize = TOTAL_ICALL_HEAP_SIZE; // ================================================================================ // FreeRTOS Callbacks // ================================================================================ -extern "C" void vApplicationStackOverflowHook(void) -{ - while (true) - { - ; - } -} - /* Wrapper functions for using the queue registry regardless of whether it is enabled or disabled */ extern "C" void vQueueAddToRegistryWrapper(QueueHandle_t xQueue, const char * pcQueueName) { diff --git a/src/platform/cc13xx_26xx/BLEManagerImpl.cpp b/src/platform/cc13xx_26xx/BLEManagerImpl.cpp index 5d5d9d3d9dc8ba..4d0c009eef1f39 100644 --- a/src/platform/cc13xx_26xx/BLEManagerImpl.cpp +++ b/src/platform/cc13xx_26xx/BLEManagerImpl.cpp @@ -395,7 +395,7 @@ void BLEManagerImpl::ConfigureAdvertisements(void) .primChanMap = GAP_ADV_CHAN_ALL, .peerAddrType = PEER_ADDRTYPE_PUBLIC_OR_PUBLIC_ID, .peerAddr = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa }, - .filterPolicy = GAP_ADV_WL_POLICY_ANY_REQ, + .filterPolicy = GAP_ADV_AL_POLICY_ANY_REQ, .txPower = GAP_ADV_TX_POWER_NO_PREFERENCE, .primPhy = GAP_ADV_PRIM_PHY_1_MBPS, .secPhy = GAP_ADV_SEC_PHY_1_MBPS, @@ -1309,7 +1309,7 @@ CHIP_ERROR BLEManagerImpl::ProcessParamUpdate(uint16_t connHandle) BLEMGR_LOG("BLEMGR: ProcessParamUpdate"); req.connectionHandle = connHandle; - req.connLatency = DEFAULT_DESIRED_SLAVE_LATENCY; + req.connLatency = DEFAULT_DESIRED_PERIPHERAL_LATENCY; req.connTimeout = DEFAULT_DESIRED_CONN_TIMEOUT; req.intervalMin = DEFAULT_DESIRED_MIN_CONN_INTERVAL; req.intervalMax = DEFAULT_DESIRED_MAX_CONN_INTERVAL; diff --git a/src/platform/cc13xx_26xx/cc13x4_26x4/BLEManagerImpl.h b/src/platform/cc13xx_26xx/cc13x4_26x4/BLEManagerImpl.h index 34c517ed1c166b..b4cf4e26766835 100644 --- a/src/platform/cc13xx_26xx/cc13x4_26x4/BLEManagerImpl.h +++ b/src/platform/cc13xx_26xx/cc13x4_26x4/BLEManagerImpl.h @@ -279,7 +279,7 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla CHIPoBLEServiceMode mServiceMode; char mDeviceName[GAP_DEVICE_NAME_LEN]; - ConnRec_t connList[MAX_NUM_BLE_CONNS]; + ConnRec_t connList[LL_MAX_NUM_BLE_CONNS]; // List to store connection handles for queued param updates List_List paramUpdateList; diff --git a/src/platform/cc13xx_26xx/cc13x4_26x4/CHIPPlatformConfig.h b/src/platform/cc13xx_26xx/cc13x4_26x4/CHIPPlatformConfig.h index 70d524af217635..60226ab76b2723 100644 --- a/src/platform/cc13xx_26xx/cc13x4_26x4/CHIPPlatformConfig.h +++ b/src/platform/cc13xx_26xx/cc13x4_26x4/CHIPPlatformConfig.h @@ -18,7 +18,7 @@ /** * @file * Platform-specific configuration overrides for CHIP on - * the Texas Instruments CC1352 platform. + * the Texas Instruments CC1354 platform. * * NOTE: currently a bare-bones implementation to allow for building. */ @@ -67,3 +67,12 @@ #ifndef CHIP_CONFIG_MAX_FABRICS #define CHIP_CONFIG_MAX_FABRICS 5 #endif + +#ifdef TI_ICD_ENABLE_SERVER +// If ICD server is enabled the device is configured as a sleepy device +#define CHIP_CONFIG_ICD_ACTIVE_MODE_DURATION_MS 3000 +#define CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS 500 +#define CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC 360 +#define CHIP_DEVICE_CONFIG_ICD_SLOW_POLL_INTERVAL chip::System::Clock::Milliseconds32(5000) +#define CHIP_DEVICE_CONFIG_ICD_FAST_POLL_INTERVAL chip::System::Clock::Milliseconds32(500) +#endif // TI_ICD_ENABLE_SERVER diff --git a/src/platform/cc13xx_26xx/cc13x4_26x4/ble_user_config.c b/src/platform/cc13xx_26xx/cc13x4_26x4/ble_user_config.c index d5579bff75cb66..91ef114b51fe81 100644 --- a/src/platform/cc13xx_26xx/cc13x4_26x4/ble_user_config.c +++ b/src/platform/cc13xx_26xx/cc13x4_26x4/ble_user_config.c @@ -312,7 +312,7 @@ const stackSpecific_t bleStackConfig = { .maxNumConns = MAX_NUM_BLE_CONNS .maxPduSize = 0, .maxNumPSM = L2CAP_NUM_PSM, .maxNumCoChannels = L2CAP_NUM_CO_CHANNELS, - .maxWhiteListElems = MAX_NUM_WL_ENTRIES, + .maxAcceptListElems = MAX_NUM_AL_ENTRIES, .maxResolvListElems = CFG_MAX_NUM_RL_ENTRIES, .pfnBMAlloc = &pfnBMAlloc, .pfnBMFree = &pfnBMFree, diff --git a/src/platform/cc13xx_26xx/chipOBleProfile.c b/src/platform/cc13xx_26xx/chipOBleProfile.c index b506dc3715cd50..e768b080dbda6b 100644 --- a/src/platform/cc13xx_26xx/chipOBleProfile.c +++ b/src/platform/cc13xx_26xx/chipOBleProfile.c @@ -169,7 +169,8 @@ bStatus_t CHIPoBLEProfile_AddService(uint32 services) uint8 status; // Allocate Client Characteristic Configuration tables - chipOBleProfileTxStateDataConfig = (gattCharCfg_t *) ICall_malloc((uint_least16_t) (sizeof(gattCharCfg_t) * MAX_NUM_BLE_CONNS)); + chipOBleProfileTxStateDataConfig = + (gattCharCfg_t *) ICall_malloc((uint_least16_t) (sizeof(gattCharCfg_t) * LL_MAX_NUM_BLE_CONNS)); if (chipOBleProfileTxStateDataConfig == NULL) { return bleMemAllocError; diff --git a/third_party/ti_simplelink_sdk/BUILD.gn b/third_party/ti_simplelink_sdk/BUILD.gn index 79f2e205b069ac..e7040b16c4667b 100644 --- a/third_party/ti_simplelink_sdk/BUILD.gn +++ b/third_party/ti_simplelink_sdk/BUILD.gn @@ -99,13 +99,13 @@ config("ti_simplelink_freertos_config") { include_dirs = [ "${chip_root}/src/platform/cc13xx_26xx", "${chip_root}/src/platform/cc13xx_26xx/cc13x2_26x2", - "${freertos_root}/repo/portable/GCC/ARM_CM4F", + "${freertos_root}/portable/GCC/ARM_CM4F", ] } else if (ti_simplelink_device_family == "cc13x4_26x4") { include_dirs = [ "${chip_root}/src/platform/cc13xx_26xx/cc13x4_26x4", - "${freertos_root}/repo/portable/GCC/ARM_CM33_NTZ", - "${freertos_root}/repo/portable/GCC/ARM_CM33_NTZ/non_secure", + "${freertos_root}/portable/GCC/ARM_CM33_NTZ", + "${freertos_root}/portable/GCC/ARM_CM33_NTZ/non_secure", "${chip_root}/src/platform/cc13xx_26xx", ] } else if (ti_simplelink_device_family == "cc32xx") { @@ -129,12 +129,12 @@ config("ti_simplelink_posix_config") { freertos_target("freertos") { if (ti_simplelink_device_family == "cc13x2_26x2" || ti_simplelink_device_family == "cc13x2x7_26x2x7") { - sources = [ "${freertos_root}/repo/portable/GCC/ARM_CM4F/port.c" ] + sources = [ "${freertos_root}/portable/GCC/ARM_CM4F/port.c" ] } else if (ti_simplelink_device_family == "cc13x4_26x4" || ti_simplelink_device_family == "cc13x4_26x4") { sources = [ - "${freertos_root}/repo/portable/GCC/ARM_CM33_NTZ/non_secure/port.c", - "${freertos_root}/repo/portable/GCC/ARM_CM33_NTZ/non_secure/portasm.c", + "${freertos_root}/portable/GCC/ARM_CM33_NTZ/non_secure/port.c", + "${freertos_root}/portable/GCC/ARM_CM33_NTZ/non_secure/portasm.c", ] } else if (ti_simplelink_device_family == "cc32xx") { sources = [ diff --git a/third_party/ti_simplelink_sdk/repo_cc13xx_cc26xx b/third_party/ti_simplelink_sdk/repo_cc13xx_cc26xx index 93adb547344293..374a26a45a5b05 160000 --- a/third_party/ti_simplelink_sdk/repo_cc13xx_cc26xx +++ b/third_party/ti_simplelink_sdk/repo_cc13xx_cc26xx @@ -1 +1 @@ -Subproject commit 93adb5473442932cdd056e20770ce1326bd8afb7 +Subproject commit 374a26a45a5b05cd87c62d9a5da04d9e6d0ed319 diff --git a/third_party/ti_simplelink_sdk/run_sdk_drivers_gen.py b/third_party/ti_simplelink_sdk/run_sdk_drivers_gen.py index fbdf81b0dfd8fa..44284f794cad74 100644 --- a/third_party/ti_simplelink_sdk/run_sdk_drivers_gen.py +++ b/third_party/ti_simplelink_sdk/run_sdk_drivers_gen.py @@ -16,7 +16,8 @@ parser = argparse.ArgumentParser() parser.add_argument('--sdk', help="TI SDK root") parser.add_argument('--chip-root', help="CHIP Root") -parser.add_argument('--src-path', help="the path where the built drivers exist") +parser.add_argument('--src-path-drivers', help="the path where the built drivers exist") +parser.add_argument('--src-path-driverlib', help="the path where the built driverlib exist") parser.add_argument('--dest-path', help="path where drivers will be copied to") args = parser.parse_args() @@ -34,21 +35,26 @@ print("Compiler Path is invalid: " + GCC_ARMCOMPILER_PATH) sys.exit(2) -source_file = args.sdk + args.src_path +source_file_drivers = args.sdk + args.src_path_drivers +source_file_driverlib = args.sdk + args.src_path_driverlib dest_path = args.dest_path make_command = ["make", "-C", args.sdk, "CMAKE=cmake", "GCC_ARMCOMPILER=" + GCC_ARMCOMPILER_PATH, "IAR_ARMCOMPILER=", "TICLANG_ARMCOMPILER=", "GENERATOR=Ninja"] - pid = os.fork() if pid: status = os.wait() - if os.path.exists(source_file): - shutil.copy(source_file, dest_path) + if os.path.exists(source_file_drivers): + shutil.copy(source_file_drivers, dest_path) else: print("Driver does not exist or path is incorrect.") sys.exit(2) + if os.path.exists(source_file_driverlib): + shutil.copy(source_file_driverlib, dest_path) + else: + print("Driverlib does not exist or path is incorrect.") + sys.exit(2) else: make_command = ["make", "-C", args.sdk, "CMAKE=cmake", "GCC_ARMCOMPILER=" + GCC_ARMCOMPILER_PATH, "IAR_ARMCOMPILER=", "TICLANG_ARMCOMPILER=", "GENERATOR=Ninja"] diff --git a/third_party/ti_simplelink_sdk/ti_simplelink_board.gni b/third_party/ti_simplelink_sdk/ti_simplelink_board.gni index e1828c9f88f302..146e3dbfb07257 100644 --- a/third_party/ti_simplelink_sdk/ti_simplelink_board.gni +++ b/third_party/ti_simplelink_sdk/ti_simplelink_board.gni @@ -40,6 +40,7 @@ assert(ti_simplelink_board != "", "ti_simplelink_board must be specified") # XXX: Can we do an array with a case statement? if (ti_simplelink_board == "CC1352R1_LAUNCHXL") { ti_simplelink_device_family = "cc13x2_26x2" + ti_simplelink_device_family_driverlib = "cc13x2_cc26x2" ti_simplelink_soc_family = "cc13x2" ti_simplelink_isa = "m4f" @@ -48,6 +49,7 @@ if (ti_simplelink_board == "CC1352R1_LAUNCHXL") { ti_simplelink_bim_name = "cc1352r1lp" } else if (ti_simplelink_board == "CC2652R1_LAUNCHXL") { ti_simplelink_device_family = "cc13x2_26x2" + ti_simplelink_device_family_driverlib = "cc13x2_cc26x2" ti_simplelink_soc_family = "cc26x2" ti_simplelink_isa = "m4f" @@ -57,16 +59,19 @@ if (ti_simplelink_board == "CC1352R1_LAUNCHXL") { } else if (ti_simplelink_board == "LP_EM_CC1354P10_6" || ti_simplelink_board == "LP_EM_CC1354P10_1") { ti_simplelink_device_family = "cc13x4_26x4" + ti_simplelink_device_family_driverlib = "cc13x4_cc26x4" ti_simplelink_soc_family = "cc13x4" ti_simplelink_isa = "m33f" ti_simplelink_soc = "cc1354p10" ti_simplelink_bim_name = "cc1354p10" } else if (ti_simplelink_board == "CC2674") { ti_simplelink_device_family = "cc13x4_26x4" #driverlib paths + ti_simplelink_device_family_driverlib = "cc13x4_cc26x4" ti_simplelink_soc_family = "cc13x4" #ble path ti_simplelink_isa = "m33f" } else if (ti_simplelink_board == "LP_CC2652R7") { ti_simplelink_device_family = "cc13x2x7_26x2x7" + ti_simplelink_device_family_driverlib = "cc13x2x7_cc26x2x7" ti_simplelink_soc_family = "cc26x2x7" ti_simplelink_isa = "m4f" diff --git a/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni b/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni index 1da4bbb0e76763..e0a848a079c3f9 100644 --- a/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni +++ b/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni @@ -280,31 +280,14 @@ template("ti_simplelink_executable") { "-da", matter_ota_digest, ] - + } else { args += [ - "-v", - matter_device_vid, - "-p", - matter_device_pid, - "-vn", - matter_software_ver, - "-vs", - matter_software_ver_str, + "-da", + "sha256", ] - if (defined(invoker.ota_digest)) { - args += [ - "-da", - matter_ota_digest, - ] - } else { - args += [ - "-da", - "sha256", - ] - } - if (defined(invoker.ota_args)) { - args += invoker.ota_args - } + } + if (defined(invoker.ota_args)) { + args += invoker.ota_args } } } else if (ti_simplelink_device_family == "cc13x4_26x4") { @@ -428,15 +411,18 @@ template("ti_simplelink_executable") { ] } - # build MCUBoot bootloader - config("${simplelink_target_name}_mcubootloader_config") { - libs = [ "${ti_simplelink_sdk_root}/source/ti/devices/cc13x4_cc26x4/driverlib/bin/gcc/driverlib.lib" ] - } + #build MCUBoot bootloader + # config("${simplelink_target_name}_mcubootloader_config") { + # # libs = [ "${ti_simplelink_sdk_root}/source/ti/devices/cc13x4_cc26x4/driverlib/bin/gcc/driverlib.lib" ] + # } flashable_executable("${simplelink_target_name}_mcubootloader") { output_name = "${output_base_name}.mcubootloader.out" output_dir = root_out_dir - deps = [ ":${simplelink_target_name}_mcuboot.syscfg" ] - public_configs = [ ":${simplelink_target_name}_mcubootloader_config" ] + deps = [ + ":${simplelink_target_name}_mcuboot.syscfg", + ":build_external_library", + ] + public_configs = [ ":external_library_config" ] ldscript = "${ti_simplelink_sdk_build_root}/mcuboot/mcuboot_cc13x4_cc26x4.lds" objcopy_image_name = "${output_base_name}.mcubootloader.hex" diff --git a/third_party/ti_simplelink_sdk/ti_simplelink_sdk.gni b/third_party/ti_simplelink_sdk/ti_simplelink_sdk.gni index 98a6acb916d30e..326d2b7e88540f 100644 --- a/third_party/ti_simplelink_sdk/ti_simplelink_sdk.gni +++ b/third_party/ti_simplelink_sdk/ti_simplelink_sdk.gni @@ -14,18 +14,19 @@ import("//build_overrides/build.gni") import("//build_overrides/chip.gni") + import("//build_overrides/freertos.gni") import("//build_overrides/mbedtls.gni") import("//build_overrides/openthread.gni") import("//build_overrides/pigweed.gni") import("//build_overrides/ti_simplelink_sdk.gni") +import("${chip_root}/src/app/icd/icd.gni") import("${chip_root}/src/platform/device.gni") import("${dir_pw_build}/python.gni") -import("${freertos_root}/freertos.gni") + import("${mbedtls_root}/mbedtls.gni") import("ti_simplelink_board.gni") - declare_args() { # Location of the TI SimpleLink SDK. @@ -73,6 +74,8 @@ template("ti_sysconfig") { "-fno-exceptions", "-fno-unwind-tables", ] + + cflags = [ "-Wno-sign-compare" ] defines = [ "DeviceFamily_CC26X2X7" ] } @@ -82,6 +85,7 @@ template("ti_sysconfig") { "-fno-exceptions", "-fno-unwind-tables", ] + cflags = [ "-Wno-sign-compare" ] if (ti_simplelink_device == "") { defines = [ "DeviceFamily_CC13X4" ] } else { @@ -91,6 +95,7 @@ template("ti_sysconfig") { config("cc32xx_${target_name}_config") { ldflags = [ "-nostartfiles" ] + cflags = [ "-Wno-sign-compare" ] defines = [ "CC32XXWARE" ] } @@ -176,21 +181,30 @@ template("ti_simplelink_sdk") { assert(ti_simplelink_sdk_root != "", "ti_simplelink_sdk_root must be specified") - action("build_external_library") { - script = "${ti_simplelink_sdk_build_root}/run_sdk_drivers_gen.py" - outputs = [ "${target_gen_dir}/drivers_${ti_simplelink_soc_family}.a" ] - args = [ - "--sdk", - rebase_path(ti_simplelink_sdk_root), - "--chip-root", - rebase_path(chip_root), - "--src-path", - "/source/ti/drivers/lib/gcc/${ti_simplelink_isa}/drivers_${ti_simplelink_soc_family}.a", - "--dest-path", - rebase_path(target_gen_dir), - ] + if (ti_simplelink_device_family == "cc13x2_26x2" || + ti_simplelink_device_family == "cc13x2x7_26x2x7" || + ti_simplelink_device_family == "cc13x4_26x4") { + action("build_external_library") { + script = "${ti_simplelink_sdk_build_root}/run_sdk_drivers_gen.py" + outputs = [ + "${target_gen_dir}/drivers_${ti_simplelink_soc_family}.a", + "${target_gen_dir}/driverlib.lib", + ] + args = [ + "--sdk", + rebase_path(ti_simplelink_sdk_root), + "--chip-root", + rebase_path(chip_root), + "--src-path-drivers", + "/source/ti/drivers/lib/gcc/${ti_simplelink_isa}/drivers_${ti_simplelink_soc_family}.a", + "--src-path-driverlib", + "/source/ti/devices/${ti_simplelink_device_family_driverlib}/driverlib/bin/gcc/driverlib.lib", + + "--dest-path", + rebase_path(target_gen_dir), + ] + } } - if (defined(invoker.ti_simplelink_sdk_root)) { ti_simplelink_sdk_root = invoker.ti_simplelink_sdk_root } @@ -198,26 +212,17 @@ template("ti_simplelink_sdk") { sdk_target_name = target_name config("cc13x2_26x2_sdk_config") { - libs = [ - "${ti_simplelink_sdk_root}/source/ti/drivers/rf/lib/gcc/${ti_simplelink_isa}/rf_multiMode_${ti_simplelink_soc_family}.a", - "${ti_simplelink_sdk_root}/source/ti/devices/cc13x2_cc26x2/driverlib/bin/gcc/driverlib.lib", - ] + libs = [ "${ti_simplelink_sdk_root}/source/ti/drivers/rf/lib/gcc/${ti_simplelink_isa}/rf_multiMode_${ti_simplelink_soc_family}.a" ] defines = [ "DeviceFamily_CC13X2_CC26X2" ] } config("cc13x2x7_26x2x7_sdk_config") { - libs = [ - "${ti_simplelink_sdk_root}/source/ti/drivers/rf/lib/gcc/${ti_simplelink_isa}/rf_multiMode_${ti_simplelink_soc_family}.a", - "${ti_simplelink_sdk_root}/source/ti/devices/cc13x2x7_cc26x2x7/driverlib/bin/gcc/driverlib.lib", - ] + libs = [ "${ti_simplelink_sdk_root}/source/ti/drivers/rf/lib/gcc/${ti_simplelink_isa}/rf_multiMode_cc26x2.a" ] defines = [ "DeviceFamily_CC13X2X7_CC26X2X7" ] } config("cc13x4_26x4_sdk_config") { - libs = [ - "${ti_simplelink_sdk_root}/source/ti/drivers/rf/lib/gcc/${ti_simplelink_isa}/rf_multiMode_${ti_simplelink_soc_family}.a", - "${ti_simplelink_sdk_root}/source/ti/devices/cc13x4_cc26x4/driverlib/bin/gcc/driverlib.lib", - ] + libs = [ "${ti_simplelink_sdk_root}/source/ti/drivers/rf/lib/gcc/${ti_simplelink_isa}/rf_multiMode_${ti_simplelink_soc_family}.a" ] defines = [ "FLASH_ONLY_BUILD" ] if (ti_simplelink_device == "") { defines += [ "DeviceFamily_CC13X4" ] @@ -248,13 +253,20 @@ template("ti_simplelink_sdk") { ] } - config("external_library_config") { - libs = [ "${target_gen_dir}/drivers_cc13x4.a" ] - } + if (ti_simplelink_device_family == "cc13x2_26x2" || + ti_simplelink_device_family == "cc13x2x7_26x2x7" || + ti_simplelink_device_family == "cc13x4_26x4") { + config("external_library_config") { + libs = [ + "${target_gen_dir}/drivers_${ti_simplelink_soc_family}.a", + "${target_gen_dir}/driverlib.lib", + ] + } - group("external_library") { - public_configs = [ ":external_library_config" ] - deps = [ ":build_external_library" ] + group("external_library") { + public_configs = [ ":external_library_config" ] + deps = [ ":build_external_library" ] + } } config("${sdk_target_name}_config") { @@ -268,8 +280,6 @@ template("ti_simplelink_sdk") { include_dirs += invoker.include_dirs } - forward_variables_from(invoker, [ "defines" ]) - configs = [ ":${ti_simplelink_device_family}_sdk_config" ] } @@ -358,7 +368,10 @@ template("ti_simplelink_sdk") { "${ti_simplelink_sdk_root}/source/ti/posix/freertos/timer.c", ] - public_deps = [ ":${sdk_target_name}_dpl" ] + public_deps = [ + ":${sdk_target_name}_dpl", + "${chip_root}/third_party/ti_simplelink_sdk:ti_simplelink_sysconfig", + ] public_configs = [ ":${sdk_target_name}_config" ] } @@ -766,7 +779,6 @@ template("ti_simplelink_sdk") { public_deps = [ ":${sdk_target_name}_dpl", ":${sdk_target_name}_freertos", - ":build_external_library", ] if (ti_simplelink_device_family == "cc13x2_26x2" || ti_simplelink_device_family == "cc13x2x7_26x2x7" || @@ -774,11 +786,60 @@ template("ti_simplelink_sdk") { public_deps += [ ":${sdk_target_name}_dmm", ":${sdk_target_name}_nvocmp", + ":build_external_library", ] } if (defined(invoker.public_configs)) { public_configs = invoker.public_configs - public_configs += [ ":external_library_config" ] + if (ti_simplelink_device_family == "cc13x2_26x2" || + ti_simplelink_device_family == "cc13x2x7_26x2x7" || + ti_simplelink_device_family == "cc13x4_26x4") { + public_configs += [ ":external_library_config" ] + } } } } + +template("freertos_target") { + freertos_target_name = target_name + + if (ti_simplelink_device_family == "cc13x2_26x2" || + ti_simplelink_device_family == "cc13x2x7_26x2x7" || + ti_simplelink_device_family == "cc13x4_26x4") { + _freertos_root = "${freertos_root}" + } else { + _freertos_root = "${freertos_root}/repo" + } + + config("${freertos_target_name}_config") { + include_dirs = [ "${_freertos_root}/include" ] + } + + source_set(freertos_target_name) { + forward_variables_from(invoker, "*") + + if (!defined(sources)) { + sources = [] + } + + sources += [ + "${_freertos_root}/croutine.c", + "${_freertos_root}/event_groups.c", + "${_freertos_root}/list.c", + "${_freertos_root}/queue.c", + "${_freertos_root}/stream_buffer.c", + "${_freertos_root}/tasks.c", + "${_freertos_root}/timers.c", + ] + + if (!defined(configs)) { + configs = [] + } + + if (!defined(public_configs)) { + public_configs = [] + } + + public_configs += [ ":${freertos_target_name}_config" ] + } +}