SDK สำหรับ TESAIoT Dev Kit
คู่มืออ้างอิง API และ Tutorial (MTB & µPython)
Loading...
Searching...
No Matches
bento_link.h
Go to the documentation of this file.
1/*******************************************************************************
2 * File Name : bento_link.h
3 *
4 * Description : BENTO transport-agnostic link layer — ONE interface for
5 * the sensor/model data plane over pluggable backends:
6 * "ipc" (CM33<->CM55 pipe), "usb" (TACP serial), "ble"
7 * (NUS), "wifi" (TCP socket). v1 ships the ipc backend.
8 *
9 * Two planes:
10 * - CONTROL: u8 cmd + u32 value — DEEPCraft-compatible, so
11 * the vendored deepcraft_engine.c drives it through a
12 * ~40-line adapter (first-member vtable cast pattern,
13 * see common/deepcraft/deepcraft_interface.h).
14 * - DATA: framed byte streams (stream_id + seq), for bulk
15 * capture (mic PCM, IMU, model scores). v1: reserved.
16 *
17 * Backends self-register by name; availability follows the
18 * board persona (compile-time BSP flags), so Python-side
19 * deepcraft.links() reflects the real board automatically.
20 *
21 * Design reference : TESAIoT_PLAN/2026-7/MPY_Sensor_DEEPCraft_Integration/
22 *******************************************************************************/
23
24#ifndef BENTO_LINK_H
25#define BENTO_LINK_H
26
27#include <stdint.h>
28#include <stdbool.h>
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34/* Capability flags */
35#define BL_F_LOSSY (1u << 0) /* frames may drop (no retransmit) */
36#define BL_F_BULK_RING (1u << 1) /* supports negotiated shared-memory bulk */
37
39
41 /* CONTROL PLANE — u8 cmd + u32 value. Must be callable from task context;
42 * returns false if the transport is busy/unavailable. */
43 bool (*send_ctrl)(bento_link_t *self, uint8_t cmd, uint32_t value);
44
45 /* DATA PLANE — framed stream chunk (<= mtu). v1: ipc backend returns
46 * false (bulk rides the negotiated SOCMEM ring in a later phase). */
47 bool (*send_data)(bento_link_t *self, uint8_t stream_id,
48 const void *buf, uint16_t len);
49
50 /* Receive callbacks. Backends MUST invoke these OFF interrupt context
51 * (each backend trampolines: ISR -> queue -> delivery task). */
53 void (*ctrl_cb)(uint8_t cmd, uint32_t value),
54 void (*data_cb)(uint8_t stream_id, const void *buf,
55 uint16_t len, uint16_t seq));
56
57 /* Capability advertisement — callers adapt, never assume. */
58 const char *name; /* "ipc" | "usb" | "ble" | "wifi" */
59 uint16_t mtu; /* max data-plane payload per frame */
60 uint32_t bandwidth_bps; /* honest sustained budget for the data plane */
61 uint8_t flags; /* BL_F_* */
62};
63
64/* ── Registry ────────────────────────────────────────────────────────────── */
65
66#define BENTO_LINK_MAX_BACKENDS (4u)
67
70
72bento_link_t *bento_link_get(const char *name);
73
75bento_link_t *bento_link_at(uint32_t index);
76
77#ifdef __cplusplus
78}
79#endif
80
81#endif /* BENTO_LINK_H */