SDK for TESAIoT Dev Kit
API reference & tutorials (ModusToolbox)
Loading...
Searching...
No Matches

Functions

void ai_engine_set_sensor_rate (uint32_t interval_ms)
 Set the accelerometer feed interval; the only legal sender on s_rate_msg.
void ai_engine_resume_sensor (void)
 Standalone resume of the default cadence; never back-to-back with a rate set.

Detailed Description

Two functions that share one CY_SECTION_SHAREDMEM message buffer (s_rate_msg) and one asynchronous Cy_IPC_Pipe_SendMessage. That single fact is the whole contract of this topic.

Variant
mtb-mpy and mtb-only

Function Documentation

◆ ai_engine_set_sensor_rate()

void ai_engine_set_sensor_rate ( uint32_t interval_ms)

Set the accelerometer feed interval; the only legal sender on s_rate_msg.

Set the accelerometer feed interval (20 = 50 Hz model rate, 100 = 10 Hz dashboard). Eva Kit drives a local LVGL timer; AI Kit sends an IPC rate request to CM33. Callable from any CM55 task.

Contract
Sets the accelerometer feed interval — 20 (50 Hz model rate) or 100 (10 Hz dashboard). AI Kit sends an op=2 IPC rate request to CM33; Eva Kit drives a local LVGL timer. Callable from any CM55 task. It must be the only IPC sender on the shared s_rate_msg buffer — never call it back-to-back with ai_engine_resume_sensor(): the send is asynchronous, CM33 reads the buffer by pointer after the call returns, and resume's leading memset zeroes an in-flight op=2 so CM33 reads data[0] == 0 = PAUSE (ai_engine.c:522-536). All five shipped call sites (deepcraft_task.c:665,:688,:765,:805,:822) pass the value derived by dc_desired_sensor_rate(), which walks the active set and raises to 50 Hz if any member is AI_SENSOR_IMU. The rate is asserted only inside the ai_engine_start() success branch, walked down on every ai_engine_stop(), and re-asserted every 2 s as self-healing.
Variant
mtb-mpy and mtb-only
Origin
Lifted from deepcraft_task.c:805 and the re-assert at :816-823 (compiled into the prebuilt archive; not shipped as source).

◆ ai_engine_resume_sensor()

void ai_engine_resume_sensor ( void )

Standalone resume of the default cadence; never back-to-back with a rate set.

Restore the default sensor cadence after a model session.

Contract
Restores the default sensor cadence after a model session by sending an op=1 resume message. No caller exists anywhere in shipped firmware (absent from consumer_must_provide.txt; the sim stub sim_ai_engine_stub.c:121 is a definition, not a call). Its own definition comment is an explicit anti-usage rule: "DO NOT call this immediately after ai_engine_set_sensor_rate()" — the shared-buffer hazard above froze the pure-MicroPython Edge AI feed (result() == None) on real hardware. It is also unnecessary after a rate change: set_sensor_rate's CM33 handler already clears the pause and resumes the push task atomically. The correct use is a standalone send with nothing else in flight on s_rate_msg (a page-leave path that wants no rate change). CM55 task context.
Variant
mtb-mpy and mtb-only
Example (authored — no shipped call site)

The example below teaches the anti-pattern: the boxed WRONG sequence is what not to write, and the single call that follows is the only legal shape.

static void bento_ex_ai_engine_resume_sensor(void)
{
/* WRONG — the shared-buffer hazard (see the box above):
*
* ai_engine_set_sensor_rate(100u); // op=2, in flight...
* ai_engine_resume_sensor(); // memset kills it -> PAUSE
*
* RIGHT — set_sensor_rate alone already resumes the push task:
*
* ai_engine_set_sensor_rate(100u); // walk down to dashboard rate
*
* RIGHT — resume as a standalone message, nothing else in flight
* on s_rate_msg (page-leave path, no rate change wanted): */
}