TuyaOS Hardware Vibe Coding
TuyaOS-only. Separate from TuyaOpen hardware-vibe-coding (TDD/TDL /
board-context.md). Do not load or copy TuyaOpen peripheral skills here.
Architecture (TuyaOS)
App code calls TKL / TAL drivers directly:
App (apps/<app>/src/*.c)
→ tkl_* (GPIO / I2C / SPI / PWM / ADC / timer / audio / video …)
→ tal_* (log / thread / system / watchdog …)
There is no board_register_hardware(), no tdl_* device layer, and
no .tuyaopen/board-context.md on TuyaOS projects.
Read these first
- Project root —
tuya.json+software/TuyaOS/. - Active app —
.tuyaos/status.json→activeApp, or user-named app undersoftware/TuyaOS/apps/<app>/. - App sources —
apps/<app>/src/, headers ininclude/or beside sources. apps/<app>/local.mk— how sources/headers are registered (seetuyaos-build).- Reference demos (always prefer reading the real file over inventing APIs):
software/TuyaOS/apps/tuyaos_demo_examples/src/examples/
driver_gpio/ driver_i2c/ driver_pwm/ driver_adc/
driver_spi/ driver_timer/ driver_mic/ driver_speaker/
driver_dvp/ os_watchdog/ os_wifi/ os_ble/
service_ble_remote/ service_ffc_master/ service_ffc_slaver/
If the demo app is not in the current tree, still use the same API names from the sub-skills below; pin numbers must come from the user / board schematic.
Rules (must follow)
- Confirm pins / instance before code. Ask which GPIO / PWM id / I2C port / SPI id / ADC channel when the user did not specify. Do not invent board pins.
- Match existing app style. If the app uses
STATIC/VOID/TAL_PR_*, keep that; if it uses POSIX C, keep that. Prefer the style already intuya_app_main.c. - Wire new files in
local.mk. New.cunderapps/<app>/must appear inLOCAL_SRC_FILES; new header dirs inLOCAL_TUYA_SDK_INCorLOCAL_TUYA_SDK_CFLAGS += -I.... Paths outside the app (e.g.vendor/) use$(LOCAL_PATH)/../../vendor/...— seetuyaos-build. - Never use TuyaOpen-only APIs here:
tdl_*,board_register_hardware(),board_com_api.h,app_default.configTuyaOpen Kconfig,.tuyaopen/*. - Build with
tuyaos-build(build_app.sh), nottos.py. - Serial / 串口 is ambiguous → ask: log/
TAL_PR_*vs dedicated UART (tal_uart/tkl_uartif present on the platform). Do not assume.
Step flow
- Confirm this is a TuyaOS tree (
software/TuyaOS/build_app.sh). - Resolve
appName+ openlocal.mk+ main entry (tuya_app_main.cor similar). - Confirm peripheral type + pins/ids with the user.
- Open the matching sub-skill under
peripheral-drivers/. - Optionally open the matching
tuyaos_demo_examplessource and adapt it. - Write code under
apps/<app>/src/…; updatelocal.mkif new files/dirs. - Build via
tuyaos-buildskill commands.
Route table
| User intent | Sub-skill | Demo path under …/examples/ |
|---|---|---|
| GPIO in/out/IRQ, 拉高拉低 | peripheral-drivers/gpio/SKILL.md |
driver_gpio/ |
| Software bit-bang I2C | peripheral-drivers/sw-i2c/SKILL.md |
driver_gpio/ (example_driver_sw_i2c.c) |
| Hardware I2C master | peripheral-drivers/i2c/SKILL.md |
driver_i2c/ |
| PWM dimming / tone | peripheral-drivers/pwm/SKILL.md |
driver_pwm/ |
| ADC / 电压采样 | peripheral-drivers/adc/SKILL.md |
driver_adc/ |
| SPI master | peripheral-drivers/spi/SKILL.md |
driver_spi/ |
| Hardware timer | peripheral-drivers/timer/SKILL.md |
driver_timer/ |
| Watchdog / 喂狗 | peripheral-drivers/watchdog/SKILL.md |
os_watchdog/ |
| Mic / 录音 | peripheral-drivers/mic/SKILL.md |
driver_mic/ |
| Speaker / 播放 | peripheral-drivers/speaker/SKILL.md |
driver_speaker/ |
| DVP camera / 采集编码 | peripheral-drivers/dvp/SKILL.md |
driver_dvp/ |
| Wi-Fi STA/AP/scan/LP / 联网 | peripheral-drivers/wifi/SKILL.md |
os_wifi/ (+ service_ffc_* for FFC remote) |
| BLE peripheral/central / 蓝牙 | peripheral-drivers/ble/SKILL.md |
os_ble/ (+ service_ble_remote/ for remotes) |
Not listed (KV/OTA/HTTP/thread/queue/…) → read the matching
tuyaos_demo_examples/src/examples/<name>/ demo; do not invent APIs.
Code organisation (TuyaOS app)
apps/<app>/
local.mk
include/ # optional public headers
src/
tuya_app_main.c # entry — keep thin
app_<feature>.c/.h # new feature modules
- Prefer a new
app_<feature>.c+ header; call init from main. - If
local.mkalready doesfind $(LOCAL_PATH)/src …, new files undersrc/may auto-pick up; otherwiseLOCAL_SRC_FILES += …explicitly. - Vendor / out-of-app sources: must edit
local.mk(seetuyaos-build).
Related skills
tuyaos-build— build/clean +local.mkpath wiringtyutool-cli— flash after a successful buildsmart-product-dev— product/DP orchestration (not a driver skill)
Maintained in tuyaopen-ide-manifests. TuyaOS-only (sdks: [tuyaos]).