|
46 | 46 | rtc_slow_get_binary/0, |
47 | 47 | rtc_slow_set_binary/1, |
48 | 48 | freq_hz/0, |
49 | | - get_mac/1 |
| 49 | + get_mac/1, |
| 50 | + task_wdt_init/1, |
| 51 | + task_wdt_reconfigure/1, |
| 52 | + task_wdt_deinit/0, |
| 53 | + task_wdt_add_user/1, |
| 54 | + task_wdt_reset_user/1, |
| 55 | + task_wdt_delete_user/1 |
50 | 56 | ]). |
51 | 57 |
|
52 | 58 | -deprecated([ |
|
101 | 107 | -type interface() :: wifi_sta | wifi_softap. |
102 | 108 | -type mac() :: binary(). |
103 | 109 |
|
| 110 | +-type task_wdt_config() :: { |
| 111 | + TimeoutMS :: pos_integer(), |
| 112 | + IdleCoreMask :: non_neg_integer(), |
| 113 | + TriggerPanic :: boolean() |
| 114 | +}. |
| 115 | +-opaque task_wdt_user_handle() :: binary(). |
| 116 | + |
| 117 | +-export_type( |
| 118 | + [ |
| 119 | + esp_partition/0, |
| 120 | + esp_partition_type/0, |
| 121 | + esp_partition_subtype/0, |
| 122 | + esp_partition_address/0, |
| 123 | + esp_partition_size/0, |
| 124 | + esp_partition_props/0, |
| 125 | + task_wdt_config/0, |
| 126 | + task_wdt_user_handle/0 |
| 127 | + ] |
| 128 | +). |
| 129 | + |
104 | 130 | -define(ATOMVM_NVS_NS, atomvm). |
105 | 131 |
|
106 | 132 | %%----------------------------------------------------------------------------- |
@@ -387,3 +413,69 @@ freq_hz() -> |
387 | 413 | -spec get_mac(Interface :: interface()) -> mac(). |
388 | 414 | get_mac(_Interface) -> |
389 | 415 | erlang:nif_error(undefined). |
| 416 | + |
| 417 | +%%----------------------------------------------------------------------------- |
| 418 | +%% @param Config configuration for the watchdog timer |
| 419 | +%% @returns ok or an error tuple |
| 420 | +%% @doc Initialize the task watchdog timer with a configuration |
| 421 | +%% Available with ESP-IDF 5.0 or higher. |
| 422 | +%% @end |
| 423 | +%%----------------------------------------------------------------------------- |
| 424 | +-spec task_wdt_init(Config :: task_wdt_config()) -> ok | {error, already_started} | {error, any()}. |
| 425 | +task_wdt_init(_Config) -> |
| 426 | + erlang:nif_error(undefined). |
| 427 | + |
| 428 | +%%----------------------------------------------------------------------------- |
| 429 | +%% @param Config configuration for the watchdog timer |
| 430 | +%% @returns ok or an error tuple |
| 431 | +%% @doc Update the configuration of the task watchdog timer |
| 432 | +%% Available with ESP-IDF 5.0 or higher. |
| 433 | +%% @end |
| 434 | +%%----------------------------------------------------------------------------- |
| 435 | +-spec task_wdt_reconfigure(Config :: task_wdt_config()) -> ok | {error, noproc} | {error, any()}. |
| 436 | +task_wdt_reconfigure(_Config) -> |
| 437 | + erlang:nif_error(undefined). |
| 438 | + |
| 439 | +%%----------------------------------------------------------------------------- |
| 440 | +%% @returns ok or an error tuple if tasks are subscribed (beyond idle tasks) or |
| 441 | +%% if the timer is not initialized |
| 442 | +%% @doc Deinitialize the task watchdog timer |
| 443 | +%% Available with ESP-IDF 5.0 or higher. |
| 444 | +%% @end |
| 445 | +%%----------------------------------------------------------------------------- |
| 446 | +-spec task_wdt_deinit() -> ok | {error, any()}. |
| 447 | +task_wdt_deinit() -> |
| 448 | + erlang:nif_error(undefined). |
| 449 | + |
| 450 | +%%----------------------------------------------------------------------------- |
| 451 | +%% @param Username name of the user |
| 452 | +%% @returns the handle to use with `task_wdt_reset_user/1' or an error tuple. |
| 453 | +%% @doc Register a user of the task watchdog timer. |
| 454 | +%% Available with ESP-IDF 5.0 or higher. |
| 455 | +%% @end |
| 456 | +%%----------------------------------------------------------------------------- |
| 457 | +-spec task_wdt_add_user(Username :: iodata()) -> {ok, task_wdt_user_handle()} | {error, any()}. |
| 458 | +task_wdt_add_user(_Username) -> |
| 459 | + erlang:nif_error(undefined). |
| 460 | + |
| 461 | +%%----------------------------------------------------------------------------- |
| 462 | +%% @param UserHandle handle for the user, obtained from `task_wdt_add_user/1' |
| 463 | +%% @returns ok or an error tuple |
| 464 | +%% @doc Reset the timer a previously registered user. |
| 465 | +%% Available with ESP-IDF 5.0 or higher. |
| 466 | +%% @end |
| 467 | +%%----------------------------------------------------------------------------- |
| 468 | +-spec task_wdt_reset_user(UserHandle :: task_wdt_user_handle()) -> ok | {error, any()}. |
| 469 | +task_wdt_reset_user(_UserHandle) -> |
| 470 | + erlang:nif_error(undefined). |
| 471 | + |
| 472 | +%%----------------------------------------------------------------------------- |
| 473 | +%% @param UserHandle handle for the user, obtained from `task_wdt_add_user/1' |
| 474 | +%% @returns ok or an error tuple |
| 475 | +%% @doc Unsubscribe a given user from the task watchdog timer. |
| 476 | +%% Available with ESP-IDF 5.0 or higher. |
| 477 | +%% @end |
| 478 | +%%----------------------------------------------------------------------------- |
| 479 | +-spec task_wdt_delete_user(UserHandle :: task_wdt_user_handle()) -> ok | {error, any()}. |
| 480 | +task_wdt_delete_user(_UserHandle) -> |
| 481 | + erlang:nif_error(undefined). |
0 commit comments