Add missing files
This commit is contained in:
parent
bf9e310360
commit
36aa1c2958
2 changed files with 88 additions and 0 deletions
20
driver_fw/.gdbinit
Normal file
20
driver_fw/.gdbinit
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
target extended-remote 192.168.1.93:2022
|
||||
set print pretty on
|
||||
set print elements 512
|
||||
|
||||
# Update GDB's Python paths with the `sys.path` values of the local Python installation,
|
||||
# whether that is brew'ed Python, a virtualenv, or another system python.
|
||||
|
||||
# Convert GDB to interpret in Python
|
||||
python
|
||||
import os,subprocess,sys
|
||||
# Execute a Python using the user's shell and pull out the sys.path (for site-packages)
|
||||
paths = subprocess.check_output('python -c "import os,sys;print(os.linesep.join(sys.path).strip())"',shell=True).decode("utf-8").split()
|
||||
# Extend GDB's Python's search path
|
||||
sys.path.extend(paths)
|
||||
end
|
||||
|
||||
source ~/ref/PyCortexMDebug/cmdebug/svd_gdb.py
|
||||
svd_load ~/ref/stm32square/svd/STM32G070.svd
|
||||
|
||||
68
driver_fw/tools/template_wave_tables.py
Normal file
68
driver_fw/tools/template_wave_tables.py
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from pathlib import Path
|
||||
import datetime
|
||||
import math
|
||||
import numpy as np
|
||||
import uuid
|
||||
|
||||
def transition(n):
|
||||
return (1 - np.cos(np.linspace(0, np.pi, n)))/2
|
||||
|
||||
def template_var(ctype, name, value):
|
||||
value = list(value)
|
||||
yield f'const {ctype} {name}[{len(value)}] = {{'
|
||||
for elem in value:
|
||||
yield f' {elem},'
|
||||
yield '};'
|
||||
|
||||
def quantize(fun, maxval):
|
||||
for val in fun:
|
||||
yield round(val*maxval)
|
||||
|
||||
def template(ctype, n, erange):
|
||||
yield ''
|
||||
yield '/* AUTO-GENERATED SOURCE! DO NOT MODIFY! */'
|
||||
yield f'/* Generated on {datetime.datetime.now()} by {Path(__file__).name} */'
|
||||
yield ''
|
||||
yield "#include <stdint.h>"
|
||||
yield ''
|
||||
vals = [x for e in transition(n) for x in [e, e]]
|
||||
yield from template_var(ctype, 'waveform_zero_one', quantize(vals, erange))
|
||||
yield ''
|
||||
vals = reversed(vals)
|
||||
yield from template_var(ctype, 'waveform_one_zero', quantize(vals, erange))
|
||||
yield ''
|
||||
|
||||
def header(ctype, n, erange):
|
||||
macro = f'__GEN_WAVE_TABLES_{str(uuid.uuid4()).upper().replace("-", "_")}__'
|
||||
yield f'#ifndef {macro}'
|
||||
yield f'#define {macro}'
|
||||
yield ''
|
||||
yield '/* AUTO-GENERATED SOURCE! DO NOT MODIFY! */'
|
||||
yield f'/* Generated on {datetime.datetime.now()} by {Path(__file__).name} */'
|
||||
yield ''
|
||||
yield "#include <stdint.h>"
|
||||
yield ''
|
||||
yield f'#define WAVEFORM_CONST_ZERO {0}'
|
||||
yield f'#define WAVEFORM_CONST_ONE 0x{erange:x}'
|
||||
yield ''
|
||||
yield f'extern const {ctype} waveform_zero_one[{2*n}];'
|
||||
yield f'extern const {ctype} waveform_one_zero[{2*n}];'
|
||||
yield ''
|
||||
yield f'#endif /* {macro} */'
|
||||
|
||||
if __name__ == '__main__':
|
||||
import argparse
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--table-size', type=int, default=256)
|
||||
parser.add_argument('--range', type=int, default=256)
|
||||
parser.add_argument('--header', action='store_true')
|
||||
parser.add_argument('--storage-type', type=str, default='uint16_t')
|
||||
parser.add_argument('outfile', type=argparse.FileType('w'))
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.header:
|
||||
args.outfile.write('\n'.join(header(args.storage_type, args.table_size, args.range)) + '\n')
|
||||
else:
|
||||
args.outfile.write('\n'.join(template(args.storage_type, args.table_size, args.range)) + '\n')
|
||||
Loading…
Add table
Add a link
Reference in a new issue