SDK สำหรับ TESAIoT Dev Kit
คู่มืออ้างอิง API และ Tutorial (ModusToolbox)
Loading...
Searching...
No Matches

Functions

bool deepcraft_task_init (void)
 เรียกหลัง cm55_ipc_communication_setup(); ตัวควบคุมจอแสดงผลที่อยู่ใน archive เรียกให้อยู่แล้ว
void deepcraft_task_request (bool start)
 สั่งให้ model link เริ่มหรือหยุด เหมือนกับที่ไคลเอนต์ MicroPython สั่งทุกประการ
void deepcraft_task_select (uint32_t n)
 เปิดใช้งานโมเดล n ใน registry เหมือน edge_ai.select(n) ทุกประการ; ไม่มีผู้เรียกเลยทั้ง workspace
void deepcraft_task_watchdog (void)
 พา model-link task กลับสู่สถานะ Ready; เรียกที่ประมาณ 1 Hz จาก context ที่ไม่บล็อกเลย

Detailed Description

DEEPCRAFT™ เป็นเครื่องหมายการค้าของ Infineon Technologies โมดูลนี้เป็น model link ฝั่ง CM55 ที่ TESAIoT เขียนขึ้น ส่วนโมเดลที่ปลายทางของ link นี้เป็นผลงานของ Imagimob AB ซึ่งเป็นบริษัทในเครือ Infineon Technologies (ดู Edge AI (libbento_edge_ai.a))

Header: deepcraft_task.h ตัวโค้ดจริง: deepcraft_task.c ที่อยู่ใน archive (libbento_cm55.a) เป็นปลายฝั่ง CM55 ของ DEEPCRAFT model link คือเป็นเจ้าของคิวคำสั่งที่ทั้ง edge_ai.* ของ MicroPython และหน้า Edge AI บนจอต่างส่งคำสั่งเข้ามา การแตะบนจอกับสคริปต์จึงให้เหตุการณ์ READY / STOPPED ชุดเดียวกัน และเปลี่ยนอัตราเซนเซอร์ที่ CM33 เหมือนกัน ทุกวันนี้ฟังก์ชันทั้ง 4 ตัวถูกเรียกจากภายใน archive เท่านั้น ตัวอย่างทุกตัวเป็นตัวอย่างที่เขียนขึ้นเอง

variant ที่ใช้ได้
mtb-mpy และ mtb-only

Function Documentation

◆ deepcraft_task_init()

bool deepcraft_task_init ( void )

เรียกหลัง cm55_ipc_communication_setup(); ตัวควบคุมจอแสดงผลที่อยู่ใน archive เรียกให้อยู่แล้ว

Create the model-link task + register the pipe client. Call AFTER cm55_ipc_communication_setup().

ข้อกำหนดการเรียกใช้
"Call AFTER \c cm55_ipc_communication_setup()" (deepcraft_task.h:24) ผู้เรียกเพียงรายเดียวคือตัวควบคุมจอแสดงผลที่อยู่ใน archive (.a คือไฟล์ไลบรารีแบบสแตติก) ที่ tesaiot_display.c:231 โดยมี BENTO_HAS_MODEL_LINK เป็นตัวกัน (guard) และมีกฎลำดับในซอร์สที่คัดมาตามตัวอักษรว่า "model-link peer — after pipe setup (ordering rule)" — คือหลังจาก cm55_ipc_communication_setup(), ipc_sensorhub_init() และ ipc_service_init() สร้าง task ขึ้นมาและลงทะเบียน pipe client ตอนนี้อยู่ภายในไบนารีแล้ว ผู้ใช้ไลบรารีที่ใช้ตัวควบคุมจอแสดงผลที่ส่งมอบมาจึงไม่เคยเรียกมันเอง ตัวอย่างที่เขียนขึ้นเองบันทึกลำดับนี้ไว้สำหรับการเปิดใช้งานแบบกำหนดเอง
variant ที่ใช้ได้
mtb-mpy และ mtb-only
ตัวอย่าง (เขียนขึ้นเอง — ไม่มี call site ในของที่ส่งมอบจริง)
static void bento_ex_deepcraft_task_init(void)
{
cm55_ipc_communication_setup(); /* FIRST — pipe endpoints */
(void)ipc_sensorhub_init(); /* sibling pipe clients next */
#if defined(BENTO_HAS_MODEL_LINK) && (BENTO_HAS_MODEL_LINK == 1)
if (!deepcraft_task_init()) { /* model-link peer — LAST */
/* AI is optional: a failed model link must not cost the screen —
* continue the bring-up. */
}
#endif
}

◆ deepcraft_task_request()

void deepcraft_task_request ( bool start)

สั่งให้ model link เริ่มหรือหยุด เหมือนกับที่ไคลเอนต์ MicroPython สั่งทุกประการ

Ask the model link to start or stop, exactly as a MicroPython client would. The on-screen page uses this instead of poking the inference engine directly, so the link emits its usual READY / STOPPED events and everything downstream – not least CM33 raising the accelerometer to the model's training rate – happens for a tap just as it does for a script.

ข้อกำหนดการเรียกใช้
"Ask the model link to start or stop, exactly as a MicroPython client would" (deepcraft_task.h) — หน้าจอใช้ฟังก์ชันนี้แทนการไปแตะ engine โดยตรง link จึงส่งเหตุการณ์ตามปกติของมันออกมา และ CM33 ยกอัตราของ accelerometer ขึ้นไปที่อัตราที่ใช้ฝึกโมเดล ทั้งกรณีที่มาจากการแตะจอและกรณีที่มาจากสคริปต์เหมือนกัน ผู้เรียกทั้งสองรายอยู่ใน archive (page_edge_ai.c:361, :367) รูปแบบที่ควรยึดเป็นแบบจริง ๆ คือ อยู่ภายใน callback ของปุ่ม LVGL จับคู่กับ ai_engine_stop() / ai_engine_start(sel) และมี gate (ด่านกั้น) เป็นเงื่อนไข ai_engine_stack_words() != 0 (ค่า 0 หมายความว่า engine ไม่เคยเริ่มทำงานเลย)
variant ที่ใช้ได้
mtb-mpy และ mtb-only
ตัวอย่าง (เขียนขึ้นเอง — ไม่มี call site ในของที่ส่งมอบจริง)
static void bento_ex_deepcraft_task_request(void)
{
if (ai_engine_stack_words() == 0u) {
return; /* engine never started — no target */
}
uint32_t sel = 0u; /* registry index from the UI */
int active = ai_engine_active();
if (active >= 0 && (int)sel == active) {
ai_engine_stop(); /* stop the running model... */
deepcraft_task_request(false); /* ...and tell the link, so it
* emits STOPPED + rate walk-down */
} else {
ai_engine_start(sel); /* clean registry switch */
deepcraft_task_request(true); /* link emits READY + training rate */
}
}

◆ deepcraft_task_select()

void deepcraft_task_select ( uint32_t n)

เปิดใช้งานโมเดล n ใน registry เหมือน edge_ai.select(n) ทุกประการ; ไม่มีผู้เรียกเลยทั้ง workspace

Edge AI menu: activate registry model n (clean switch, no reload) exactly as a MicroPython edge_ai.select(n) does. On-screen parity with the dropdown on the Edge AI page — posts SELECT(0x90+n) on the model link's command queue.

ข้อกำหนดการเรียกใช้
เปิดใช้งานโมเดล n ใน registry (สลับแบบสะอาด ไม่มีการโหลดใหม่) เหมือนที่ edge_ai.select(n) ทำทุกประการ ด้วยการส่ง SELECT(0x90+n) เข้าคิวคำสั่งของ link ไม่มีผู้เรียกเลยทั้ง workspace (มีนิยาม 3 ชุดและ stub ของ host-sim อีก 2 ชุด) เป็นตัวอย่างที่เขียนขึ้นเอง
variant ที่ใช้ได้
mtb-mpy และ mtb-only
ตัวอย่าง (เขียนขึ้นเอง — ไม่มี call site ในของที่ส่งมอบจริง)
static void bento_ex_deepcraft_task_select(void)
{
if (ai_engine_stack_words() == 0u) {
return; /* engine never started */
}
uint32_t n = 1u; /* registry index to activate */
deepcraft_task_select(n); /* queued — returns immediately */
/* Confirm later via ai_engine_requested() == (int)n (the REQUESTED
* index answers immediately; ACTIVE follows after the cold-init). */
}

◆ deepcraft_task_watchdog()

void deepcraft_task_watchdog ( void )

พา model-link task กลับสู่สถานะ Ready; เรียกที่ประมาณ 1 Hz จาก context ที่ไม่บล็อกเลย

Return the model-link task to Ready if it has stopped draining its command queue. Call at about 1 Hz from a context that never blocks. Does nothing on a healthy board; see the definition for what it does and does not fix.

ข้อกำหนดการเรียกใช้
"Return the model-link task to Ready if it has stopped draining its command queue. Call at about 1 Hz from a context that never blocks" (deepcraft_task.h) ผู้เรียกเพียงรายเดียวอยู่ภายใน: deepcraft_task.c:1000 จาก callback ของ software timer ของ FreeRTOS โดยมี WD_STRIKES = 2 — ต้องเห็น task ค้างติดกัน 2 tick ก่อน watchdog จึงจะลงมือ tick ที่หายไป 1 ครั้งยังไม่นับเป็น strike ไม่ทำอะไรเลยบนบอร์ดที่ปกติดี
variant ที่ใช้ได้
mtb-mpy และ mtb-only
ตัวอย่าง (เขียนขึ้นเอง — ไม่มี call site ในของที่ส่งมอบจริง)
static void bento_ex_dc_wd_timer_cb(TimerHandle_t t)
{
(void)t;
deepcraft_task_watchdog(); /* no-op while healthy */
}
static void bento_ex_deepcraft_task_watchdog(void)
{
TimerHandle_t wd = xTimerCreate("dc_wd",
pdMS_TO_TICKS(1000u), /* ~1 Hz */
pdTRUE, /* auto-reload */
NULL,
bento_ex_dc_wd_timer_cb);
if (wd != NULL) {
(void)xTimerStart(wd, 0);
}
}