big refactoring and features added

This commit is contained in:
Ayzen
2026-04-24 16:51:15 +03:00
parent eafc328caa
commit ea1fbb071d
184 changed files with 35336 additions and 75480 deletions

View File

@ -0,0 +1,70 @@
SD card example layout
Firmware expects a plain FAT volume handled by FatFs. In this project `exFAT` is disabled in [ffconf.h](/home/europa/Desktop/RadioPhotonic_PCB_software/Inc/ffconf.h:213), so the safe choice is `FAT32` with a standard MBR partition.
Recommended card preparation:
1. Format the card as `FAT32`.
2. Copy the files from this directory to the root of the SD card, or keep the same relative folder structure.
3. Make sure `profiles.csv` is present at the root path expected by the firmware.
Expected file set:
- `profiles.csv`
- `profiles/profile_1_saw.ini`
- `profiles/profile_2_custom_wave.ini`
- `waves/wave_custom.csv`
`profiles.csv` format:
- One profile per line.
- Columns: `display_name, profile_ini_path, optional_waveform_csv_path`
- Empty lines are ignored.
- Lines starting with `#` or `;` are ignored.
Example:
```csv
Factory Saw,profiles/profile_1_saw.ini,
Custom SRAM,profiles/profile_2_custom_wave.ini,waves/wave_custom.csv
```
Profile `.ini` format:
- One `key=value` pair per line.
- Empty lines are ignored.
- Lines starting with `#` or `;` are ignored.
- Unknown keys are ignored.
Additional profile-controlled devices:
- `AD9102` waveform settings are stored through the `waveform_*` keys.
- `AD9833` settings are stored through `ad9833_enable`, `ad9833_triangle`, and `ad9833_frequency_word`.
- STM32 internal DAC settings are stored through `stm32_dac_enable` and `stm32_dac_code`.
- `DS1809` is stored as an absolute target above the minimum tap using `ds1809_apply` and `ds1809_position_from_min`.
Notes:
- `ad9833_frequency_word` uses the same raw 28-bit tuning word that the old serial command accepted.
- `ds1809_position_from_min` is clamped to the valid `0..63` range by the firmware.
- When `ds1809_apply=true`, the firmware first drives the potentiometer fully down and then steps it up to the requested absolute position.
Waveform file format:
- The firmware scans the file with `strtol()`.
- Any integer token found in the file becomes one AD9102 SRAM sample.
- Separators may be commas, spaces, tabs, or newlines.
- Do not put comments or stray digits into the waveform file, because any parsed integer will be treated as a sample.
Supported `waveform_mode` values:
- `saw`
- `generated_sram`
- `custom_sram`
Minimal boot behavior:
- On startup the firmware loads the first valid line from `profiles.csv`.
- It then loads the referenced profile `.ini`.
- If `boot_enabled=true`, the profile is activated.
- If `auto_run=true`, the board immediately enters `WORK` mode.

View File

@ -0,0 +1,3 @@
# display_name, profile_ini_path, optional_waveform_csv_path
Factory Saw,profiles/prof1.ini,
Custom SRAM,profiles/prof2.ini,waves/wave1.csv
1 # display_name profile_ini_path optional_waveform_csv_path
2 Factory Saw profiles/prof1.ini
3 Custom SRAM profiles/prof2.ini waves/wave1.csv

View File

@ -0,0 +1,47 @@
# Profile 1: standard saw waveform, immediate boot and auto-run.
profile_name=Factory Saw
boot_enabled=true
auto_run=true
work_enable=1
u5v1_enable=1
u5v2_enable=1
ld1_enable=1
ld2_enable=1
ref1_enable=1
ref2_enable=1
tec1_enable=1
tec2_enable=1
ts1_enable=1
ts2_enable=1
pid1_from_host=1
pid2_from_host=1
averages=16
message_id=100
laser1_target_temp=2500
laser2_target_temp=2520
laser1_current=1200
laser2_current=1180
laser1_pid_p=10.0
laser1_pid_i=0.01
laser2_pid_p=10.0
laser2_pid_i=0.01
waveform_mode=saw
waveform_enable=1
waveform_triangle=0
waveform_saw_step=4
waveform_pat_base=2
waveform_pat_period=65535
ad9833_enable=0
ad9833_triangle=0
ad9833_frequency_word=0
stm32_dac_enable=0
stm32_dac_code=0
ds1809_apply=true
ds1809_position_from_min=0

View File

@ -0,0 +1,51 @@
# Profile 2: custom waveform loaded from a separate CSV file.
profile_name=Custom SRAM
boot_enabled=true
auto_run=true
work_enable=1
u5v1_enable=1
u5v2_enable=1
ld1_enable=1
ld2_enable=0
ref1_enable=1
ref2_enable=0
tec1_enable=1
tec2_enable=0
ts1_enable=1
ts2_enable=0
pid1_from_host=1
pid2_from_host=1
averages=16
message_id=200
laser1_target_temp=2480
laser2_target_temp=0
laser1_current=1350
laser2_current=0
laser1_pid_p=9.5
laser1_pid_i=0.02
laser2_pid_p=0.0
laser2_pid_i=0.0
waveform_mode=custom_sram
waveform_enable=1
waveform_triangle=0
waveform_saw_step=1
waveform_pat_base=2
waveform_pat_period=65535
waveform_sample_count=16
waveform_hold_cycles=8
waveform_amplitude=4095
waveform_source=waves/wave1.csv
ad9833_enable=1
ad9833_triangle=0
ad9833_frequency_word=0x00123456
stm32_dac_enable=1
stm32_dac_code=2048
ds1809_apply=true
ds1809_position_from_min=18

View File

@ -0,0 +1,16 @@
0,
512,
1024,
1536,
2048,
3072,
4095,
3072,
2048,
1024,
0,
-1024,
-2048,
-1024,
0,
512
Can't render this file because it has a wrong number of fields in line 16.