Skip to content

Commit 0df8162

Browse files
committed
add dma assigments for serial ports
1 parent 472c3d8 commit 0df8162

File tree

130 files changed

+2913
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+2913
-0
lines changed

CLAUDE.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
This is a target configuration management system for the QUICKSILVER Flight Controller Firmware. It manages hardware target definitions for 500+ FPV flight controller boards, converting Betaflight unified targets to QUICKSILVER-compatible YAML format and generating target indices.
8+
9+
## Development Commands
10+
11+
```bash
12+
# Convert Betaflight configs to staging targets
13+
npm run translate
14+
15+
# Build target index and validate configurations
16+
npx vite-node src/index.ts
17+
18+
# Sync specific fields between staging and production targets
19+
npx vite-node src/sync.ts
20+
21+
# Install dependencies
22+
npm install
23+
```
24+
25+
## Architecture Overview
26+
27+
**Core Components:**
28+
- `src/translate.ts` - Converts Betaflight `config.h` files to QUICKSILVER YAML format
29+
- `src/index.ts` - Processes all target YAML files and generates consolidated indices
30+
- `src/dma.ts` - Automatically assigns DMA channels and prevents hardware conflicts
31+
- `src/sync.ts` - Syncs specific fields between staging and production targets
32+
33+
**Directory Structure:**
34+
- `targets/` - Production target configurations (500+ YAML files)
35+
- `staging/` - Converted Betaflight targets awaiting validation
36+
- `betaflight/` - Git submodule with upstream Betaflight configurations
37+
- `mcu/` - MCU-specific pin and DMA definitions (stm32f405, stm32f411, etc.)
38+
- `manufacturers.yaml` - Manufacturer database with codes and metadata
39+
40+
**Target Configuration Format:**
41+
Each target YAML contains hardware definitions: MCU type, pin mappings, serial/SPI ports, gyro configuration, motor outputs, and DMA assignments. Files are validated against `src/schema/target.json`.
42+
43+
**MCU Support:**
44+
STM32F405/F411/F722/F745/F765/H743, STM32G473, AT32F435 with MCU-specific pin definitions in `mcu/{type}/gpio.yaml` and DMA mappings in `mcu/{type}/dma.yaml`.
45+
46+
**CI/CD Pipeline:**
47+
Automated builds on master push generate target indices and deploy to the `targets` branch for consumption by QUICKSILVER firmware builds.

src/dma.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,34 @@ export function findDmaAssigments(target: target_t): target_t {
164164
}
165165
}
166166

167+
const supportsSwapping = !mcu.startsWith('stm32f4');
168+
169+
for (const serial of target.serial_ports) {
170+
if (gpio[serial.rx]) {
171+
const rxFuncs = supportsSwapping ? ['rx', 'tx'] : ['rx'];
172+
for (const func of rxFuncs) {
173+
const rx = gpio[serial.rx].filter(g => g.tag.type == 'serial' && g.tag.index == serial.index && g.tag.func == func);
174+
for (const r of rx) {
175+
if (addDmaAssigment(`SERIAL${serial.index}_RX`, r.tag))
176+
break;
177+
}
178+
if (rx.length > 0) break;
179+
}
180+
}
181+
182+
if (gpio[serial.tx]) {
183+
const txFuncs = supportsSwapping ? ['tx', 'rx'] : ['tx'];
184+
for (const func of txFuncs) {
185+
const tx = gpio[serial.tx].filter(g => g.tag.type == 'serial' && g.tag.index == serial.index && g.tag.func == func);
186+
for (const t of tx) {
187+
if (addDmaAssigment(`SERIAL${serial.index}_TX`, t.tag))
188+
break;
189+
}
190+
if (tx.length > 0) break;
191+
}
192+
}
193+
}
194+
167195
const entries = {}
168196
for (const ass of dma_assigments) {
169197
const ignore = ["res", "dev"];

src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ export interface target_t {
103103

104104
vbat_scale?: number;
105105
ibat_scale?: number;
106+
dma?: any;
107+
timers?: any;
106108
}
107109

108110
export const target_keys = [

targets/afng-alienflightngf7.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@ dma:
7272
channel: 6
7373
dma: DMA2_STREAM1
7474
tag: TIMER1_CH1
75+
SERIAL1_TX:
76+
channel: 4
77+
dma: DMA2_STREAM7
78+
tag: SERIAL1_TX
79+
SERIAL2_TX:
80+
channel: 4
81+
dma: DMA1_STREAM6
82+
tag: SERIAL2_TX
83+
SERIAL4_RX:
84+
channel: 4
85+
dma: DMA1_STREAM2
86+
tag: SERIAL4_RX
7587
SPI1_RX:
7688
channel: 3
7789
dma: DMA2_STREAM0

targets/aiko-aikonf4.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,22 @@ dma:
6969
channel: 2
7070
dma: DMA1_STREAM0
7171
tag: TIMER4_CH1
72+
SERIAL1_RX:
73+
channel: 4
74+
dma: DMA2_STREAM2
75+
tag: SERIAL1_RX
76+
SERIAL1_TX:
77+
channel: 4
78+
dma: DMA2_STREAM7
79+
tag: SERIAL1_TX
80+
SERIAL2_TX:
81+
channel: 4
82+
dma: DMA1_STREAM6
83+
tag: SERIAL2_TX
84+
SERIAL3_RX:
85+
channel: 4
86+
dma: DMA1_STREAM1
87+
tag: SERIAL3_RX
7288
SPI1_RX:
7389
channel: 3
7490
dma: DMA2_STREAM0

targets/aiko-aikonf7.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,26 @@ dma:
6868
channel: 3
6969
dma: DMA1_STREAM5
7070
tag: TIMER2_CH1
71+
SERIAL1_RX:
72+
channel: 4
73+
dma: DMA2_STREAM2
74+
tag: SERIAL1_RX
75+
SERIAL1_TX:
76+
channel: 4
77+
dma: DMA2_STREAM7
78+
tag: SERIAL1_TX
79+
SERIAL2_TX:
80+
channel: 4
81+
dma: DMA1_STREAM6
82+
tag: SERIAL2_TX
83+
SERIAL3_RX:
84+
channel: 4
85+
dma: DMA1_STREAM1
86+
tag: SERIAL3_RX
87+
SERIAL4_RX:
88+
channel: 4
89+
dma: DMA1_STREAM2
90+
tag: SERIAL4_RX
7191
SPI1_RX:
7292
channel: 3
7393
dma: DMA2_STREAM0

targets/airb-airbotg4aio.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,34 @@ dma:
6666
dma: DMA1_STREAM1
6767
request: 67
6868
tag: TIMER4_CH1
69+
SERIAL1_RX:
70+
dma: DMA1_STREAM7
71+
request: 24
72+
tag: SERIAL1_RX
73+
SERIAL1_TX:
74+
dma: DMA1_STREAM8
75+
request: 25
76+
tag: SERIAL1_TX
77+
SERIAL2_RX:
78+
dma: DMA2_STREAM1
79+
request: 26
80+
tag: SERIAL2_RX
81+
SERIAL2_TX:
82+
dma: DMA2_STREAM2
83+
request: 27
84+
tag: SERIAL2_TX
85+
SERIAL3_RX:
86+
dma: DMA2_STREAM3
87+
request: 29
88+
tag: SERIAL3_TX
89+
SERIAL4_RX:
90+
dma: DMA2_STREAM4
91+
request: 30
92+
tag: SERIAL4_RX
93+
SERIAL4_TX:
94+
dma: DMA2_STREAM5
95+
request: 31
96+
tag: SERIAL4_TX
6997
SPI1_RX:
7098
dma: DMA1_STREAM3
7199
request: 10

targets/airb-nox.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,18 @@ dma:
5757
channel: 3
5858
dma: DMA1_STREAM5
5959
tag: TIMER2_CH1
60+
SERIAL1_RX:
61+
channel: 4
62+
dma: DMA2_STREAM5
63+
tag: SERIAL1_RX
64+
SERIAL1_TX:
65+
channel: 4
66+
dma: DMA2_STREAM7
67+
tag: SERIAL1_TX
68+
SERIAL2_TX:
69+
channel: 4
70+
dma: DMA1_STREAM6
71+
tag: SERIAL2_TX
6072
SPI1_RX:
6173
channel: 3
6274
dma: DMA2_STREAM0

targets/airb-omnibusf4.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,26 @@ dma:
6767
channel: 3
6868
dma: DMA1_STREAM6
6969
tag: TIMER2_CH2
70+
SERIAL1_RX:
71+
channel: 4
72+
dma: DMA2_STREAM5
73+
tag: SERIAL1_RX
74+
SERIAL1_TX:
75+
channel: 4
76+
dma: DMA2_STREAM7
77+
tag: SERIAL1_TX
78+
SERIAL3_RX:
79+
channel: 4
80+
dma: DMA1_STREAM1
81+
tag: SERIAL3_RX
82+
SERIAL4_RX:
83+
channel: 4
84+
dma: DMA1_STREAM2
85+
tag: SERIAL4_RX
86+
SERIAL6_TX:
87+
channel: 5
88+
dma: DMA2_STREAM6
89+
tag: SERIAL6_TX
7090
SPI1_RX:
7191
channel: 3
7292
dma: DMA2_STREAM0

targets/airb-omnibusf4sd.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,22 @@ dma:
6969
channel: 2
7070
dma: DMA1_STREAM0
7171
tag: TIMER4_CH1
72+
SERIAL1_RX:
73+
channel: 4
74+
dma: DMA2_STREAM5
75+
tag: SERIAL1_RX
76+
SERIAL1_TX:
77+
channel: 4
78+
dma: DMA2_STREAM7
79+
tag: SERIAL1_TX
80+
SERIAL3_RX:
81+
channel: 4
82+
dma: DMA1_STREAM1
83+
tag: SERIAL3_RX
84+
SERIAL6_TX:
85+
channel: 5
86+
dma: DMA2_STREAM6
87+
tag: SERIAL6_TX
7288
SPI1_RX:
7389
channel: 3
7490
dma: DMA2_STREAM0

0 commit comments

Comments
 (0)