@turingcode/cli 0.3.21 → 0.3.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/mods/claude/turingcode-skills/skills/turingcode/SKILL.md +18 -11
- package/mods/claude/turingcode-skills/skills/turingcode/references/{app-startup.md → app-main-and-startup.md} +1 -1
- package/mods/claude/turingcode-skills/skills/turingcode/references/driver/driver.md +2 -13
- package/mods/claude/turingcode-skills/skills/turingcode/references/fact-check.md +14 -0
- package/package.json +1 -1
|
@@ -1,31 +1,38 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: turingcode
|
|
3
|
-
description:
|
|
3
|
+
description: STM32 firmware with the turingcode CLI: writing or reviewing C/C++ code, and creating, building, flashing, debugging or analyzing a project.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
# TuringCode Skill
|
|
7
7
|
|
|
8
8
|
- These rules outrank speed: when a rule conflicts with a faster solution, follow the rule and report it.
|
|
9
9
|
- A project's `AGENTS.md` overrides this skill wherever it is more specific (layout, shared helpers, generator markers, tests).
|
|
10
10
|
|
|
11
|
+
## TuringCode CLI
|
|
12
|
+
|
|
13
|
+
- when building, flashing and debugging, ... on stm32, use `turingcode --help` to get started.
|
|
14
|
+
|
|
15
|
+
## Embedded C/C++ rules
|
|
16
|
+
|
|
11
17
|
- some names in the references (`crc32`, `flash_*`, `COM_Driver`, ...) are placeholders for the project's own functions and helpers. Use the existing ones.
|
|
12
18
|
- add a missing helper once to the project's shared helper location (or `Utils/` if it has none), never inline.
|
|
13
19
|
|
|
14
|
-
|
|
20
|
+
### Read the matching references
|
|
15
21
|
|
|
16
22
|
| Read | When changing or making |
|
|
17
23
|
|---|---|
|
|
18
24
|
| `references/init-pins.md` | when a new project is created and we need to decide about pin connections and what pins to use, or when a user asks about where and how to connect the board pins |
|
|
19
25
|
| `references/newproject.md` | Only when the user asks for a new project |
|
|
26
|
+
| `references/fact-check.md` | To check facts about mcu and ic (eg: registers,timing, chip-id, ...) |
|
|
20
27
|
| `references/driver/driver.md` | a driver for an external IC or bus protocol |
|
|
21
28
|
| `references/registers-and-units.md` | datasheet registers, bit fields, signedness, units, conversions |
|
|
22
29
|
| `references/tasks-and-interrupts.md` | ISRs, HAL callbacks, the main loop, RTOS tasks and their wakeups, DMA, shared data |
|
|
23
|
-
| `references/app-startup.md` | `main.c` hook, `extern "C"` entry, init order, tasks, µs time base |
|
|
30
|
+
| `references/app-main-and-startup.md` | `main.c` hook, `extern "C"` entry, init order, tasks, µs time base |
|
|
24
31
|
| `references/storage.md` | saving settings, calibration or data to flash/EEPROM |
|
|
25
32
|
| `references/host-protocol.md` | host frames, command dispatch, register writes, replies/telemetry |
|
|
26
33
|
| `references/M_StatusEnum.md` | no `M_Status.hpp`, or how to return and combine statuses |
|
|
27
34
|
|
|
28
|
-
|
|
35
|
+
### Generated code
|
|
29
36
|
|
|
30
37
|
- In generated files (`main.c`, peripheral init, ...), write only inside
|
|
31
38
|
`/* USER CODE BEGIN/END */` blocks and leave the markers alone. CubeMX
|
|
@@ -35,14 +42,14 @@ description: Coding rules for embedded C/C++ firmware on STM32. Use whenever wri
|
|
|
35
42
|
one (often in `main.c` or `stm32xxxx_it.c`), call your handler from its
|
|
36
43
|
USER CODE block.
|
|
37
44
|
|
|
38
|
-
|
|
45
|
+
### Application Code Location
|
|
39
46
|
|
|
40
47
|
- Keep `main.c` thin: it only calls `App/app.h` (`app_init()`, `app_loop()`),
|
|
41
48
|
which needs `extern "C"` guards.
|
|
42
49
|
- All application code lives in `<Project>/App/`, generic code lives in the project's shared helper location (or `App/Utils/`/`App/Math/`).
|
|
43
50
|
- A shared library or SDK inside `App/` is not a Code Area: use it, don't restructure it, ask before changing it.
|
|
44
51
|
|
|
45
|
-
|
|
52
|
+
### File layout
|
|
46
53
|
|
|
47
54
|
- put source (c,cpp) and header (h,hpp) files in the same folder with the same base name.
|
|
48
55
|
- Include project headers by file name only (`#include "com_spi.hpp"`), never with a folder or `../` path.
|
|
@@ -63,7 +70,7 @@ description: Coding rules for embedded C/C++ firmware on STM32. Use whenever wri
|
|
|
63
70
|
| `Math/` | numeric types and linear algebra |
|
|
64
71
|
| `Utils/` | domain-free helpers |
|
|
65
72
|
|
|
66
|
-
|
|
73
|
+
### House style
|
|
67
74
|
|
|
68
75
|
- **Methods**: lowerCamelCase
|
|
69
76
|
- **Members**:
|
|
@@ -97,7 +104,7 @@ description: Coding rules for embedded C/C++ firmware on STM32. Use whenever wri
|
|
|
97
104
|
*/
|
|
98
105
|
```
|
|
99
106
|
|
|
100
|
-
|
|
107
|
+
### Typical loop
|
|
101
108
|
|
|
102
109
|
1. Edit the code, run `turingcode project sync -b` and fix the reported errors.
|
|
103
110
|
- Before finishing a change, run `turingcode project sync -b -a` for static analysis.
|
|
@@ -105,13 +112,13 @@ description: Coding rules for embedded C/C++ firmware on STM32. Use whenever wri
|
|
|
105
112
|
3. Verify it runs without looking at the board: read a register the program changes a few times with `turingcode probe read` and check that it changes as expected.
|
|
106
113
|
4. On a crash, run `turingcode probe faults`, or `turingcode debug start` with breakpoints to find the cause.
|
|
107
114
|
|
|
108
|
-
|
|
115
|
+
### Code Safety rules
|
|
109
116
|
|
|
110
117
|
1. **Never drop a status.** Check or accumulate every status, `HAL_StatusTypeDef` and RTOS return. Never return `M_OK` after fallible steps; if ignoring one is safe, write in comments why.
|
|
111
118
|
2. **Every wait has a timeout and an error path.** No unbounded hardware loops, no retry count where 0 means "forever"; fail visibly instead of hanging boot.
|
|
112
119
|
3. **Budget memory.** No `new`/`delete` in periodic/per-transaction paths; preallocate as members or statics; keep KB-sized objects off task stacks and size each stack.
|
|
113
120
|
|
|
114
|
-
|
|
121
|
+
### Tool Safety rules
|
|
115
122
|
|
|
116
123
|
- Don't ever write debug registers by hand (DHCSR, DEMCR, DCRSR, DCRDR, FPB). doing so may brick the mcu.
|
|
117
124
|
- Halt, step and breakpoints go through `turingcode debug`, which releases the debug state on exit.
|
|
@@ -31,19 +31,8 @@ After correctly determining what drivers are needed we can go onto the next step
|
|
|
31
31
|
|
|
32
32
|
### 3 Source of truth - IMPORTANT
|
|
33
33
|
|
|
34
|
-
-
|
|
35
|
-
|
|
36
|
-
- ALWAYS save result of the knowledge base calls into a file the grep it.
|
|
37
|
-
|
|
38
|
-
- ALWAYS take every register, reset value, timing, encoding and other facts about parts that you write in code take them from datasheet, errata or application notes.
|
|
39
|
-
- For values that you find from references cite them: `// [CITE: ABC]` in the code.
|
|
40
|
-
- For values that you guessed or did not find from reference files mark them with a `// [GUESS]` in the code and list them in the end.
|
|
41
|
-
- Timeouts and poll counts are not guesses: compute them from the cited timing (transfer length × slowest clock, worst-case reset or conversion time) plus a stated margin, and write the calculation in the comment, e.g. `// [CALC: 7 B at 1 MHz = 56 us; 1 ms tick -> 2 ms]`. Use `[GUESS]` only when there is no timing to compute from.
|
|
42
|
-
- Register writes are not retried: a read-back mismatch is an error (tries = 1) unless the project gives a reason to retry.
|
|
43
|
-
- timing and margin checks use the datasheet's worst-case (min/max) values, not typical when a setting depends on a margin, cite it.
|
|
44
|
-
|
|
45
|
-
- NEVER skip this step to go faster, the time it takes to debug a faulty register value because you guessed it is much longer than first reading it from the proper source.
|
|
46
|
-
|
|
34
|
+
- When writing driver code make sure to read `references/fact-check.md`
|
|
35
|
+
|
|
47
36
|
#### 3.1 Facts to check
|
|
48
37
|
|
|
49
38
|
Check at least these facts, plus any others that apply to the part and project,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
## Fact Check
|
|
2
|
+
|
|
3
|
+
- Turingcode tools have a knowledge base tool that should be used to find these information (see: `turingcode tool list`)
|
|
4
|
+
- when using the knowledge base tool first list file names then search on related files
|
|
5
|
+
- ALWAYS save result of the knowledge base calls into a file the grep it.
|
|
6
|
+
|
|
7
|
+
- ALWAYS take every register, reset value, timing, encoding and other facts about parts that you write in code take them from datasheet, errata or application notes.
|
|
8
|
+
- For values that you find from references cite them: `// [CITE: ABC]` in the code.
|
|
9
|
+
- For values that you guessed or did not find from reference files mark them with a `// [GUESS]` in the code and list them in the end.
|
|
10
|
+
- Timeouts and poll counts are not guesses: compute them from the cited timing (transfer length × slowest clock, worst-case reset or conversion time) plus a stated margin, and write the calculation in the comment, e.g. `// [CALC: 7 B at 1 MHz = 56 us; 1 ms tick -> 2 ms]`. Use `[GUESS]` only when there is no timing to compute from.
|
|
11
|
+
- Register writes are not retried: a read-back mismatch is an error (tries = 1) unless the project gives a reason to retry.
|
|
12
|
+
- timing and margin checks use the datasheet's worst-case (min/max) values, not typical when a setting depends on a margin, cite it.
|
|
13
|
+
|
|
14
|
+
- NEVER skip this step to go faster, the time it takes to debug a faulty register value because you guessed it is much longer than first reading it from the proper source.
|
package/package.json
CHANGED