peakrdl-python 0.7.3__tar.gz → 0.7.5__tar.gz
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.
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/.github/workflows/action.yaml +18 -2
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/PKG-INFO +7 -6
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/README.md +3 -3
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/docs/api.rst +2 -2
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/docs/api_components.rst +3 -2
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/docs/command_line.rst +1 -1
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/docs/customisation.rst +1 -1
- peakrdl_python-0.7.5/docs/design_decisions.rst +23 -0
- peakrdl_python-0.7.5/docs/design_tools.rst +11 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/docs/generated_package.rst +82 -39
- peakrdl_python-0.7.5/docs/index.rst +167 -0
- peakrdl_python-0.7.5/docs/installation.rst +31 -0
- peakrdl_python-0.7.5/example/enumerated_fields/demo_enumerated_fields.py +39 -0
- peakrdl_python-0.7.5/example/enumerated_fields/enumerated_fields.rdl +35 -0
- peakrdl_python-0.7.5/example/optimised_access/demo_optimised_array_access.py +102 -0
- peakrdl_python-0.7.5/example/optimised_access/optimised_array_access.rdl +17 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/example/simulating_callbacks/flashing_the_LED.py +2 -2
- peakrdl_python-0.7.5/example/why_ral/gpio.rdl +46 -0
- peakrdl_python-0.7.5/example/why_ral/hardware_sim.py +25 -0
- peakrdl_python-0.7.5/example/why_ral/with_hal.py +63 -0
- peakrdl_python-0.7.5/example/why_ral/with_ral.py +21 -0
- peakrdl_python-0.7.5/example/why_ral/without_ral.py +17 -0
- peakrdl_python-0.7.5/generate_and_test.py +236 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/generate_testcases.py +20 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/pyproject.toml +4 -3
- peakrdl_python-0.7.5/src/peakrdl_python/__about__.py +20 -0
- peakrdl_python-0.7.5/src/peakrdl_python/__init__.py +19 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/src/peakrdl_python/__peakrdl__.py +18 -2
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/src/peakrdl_python/_node_walkers.py +17 -18
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/src/peakrdl_python/exporter.py +33 -1
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/src/peakrdl_python/lib/__init__.py +44 -14
- peakrdl_python-0.7.5/src/peakrdl_python/lib/async_register.py +886 -0
- peakrdl_python-0.7.5/src/peakrdl_python/lib/base.py +892 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/src/peakrdl_python/lib/callbacks.py +18 -2
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/src/peakrdl_python/lib/fields.py +48 -24
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/src/peakrdl_python/lib/memory.py +292 -76
- peakrdl_python-0.7.5/src/peakrdl_python/lib/register.py +1063 -0
- peakrdl_python-0.7.5/src/peakrdl_python/lib/utility_functions.py +61 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/src/peakrdl_python/safe_name_utility.py +16 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/src/peakrdl_python/systemrdl_node_utility_functions.py +16 -0
- peakrdl_python-0.7.5/src/peakrdl_python/templates/__init__.py +20 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/src/peakrdl_python/templates/addrmap.py.jinja +82 -41
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/src/peakrdl_python/templates/addrmap_field.py.jinja +18 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/src/peakrdl_python/templates/addrmap_memory.py.jinja +23 -16
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/src/peakrdl_python/templates/addrmap_register.py.jinja +32 -28
- peakrdl_python-0.7.5/src/peakrdl_python/templates/addrmap_simulation.py.jinja +17 -0
- peakrdl_python-0.7.5/src/peakrdl_python/templates/addrmap_simulation_tb.jinja +17 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/src/peakrdl_python/templates/addrmap_tb.py.jinja +101 -11
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/src/peakrdl_python/templates/baseclass_tb.py.jinja +20 -2
- peakrdl_python-0.7.5/src/peakrdl_python/templates/header.py.jinja +23 -0
- peakrdl_python-0.7.5/src/peakrdl_python/templates/header_tb.py.jinja +22 -0
- peakrdl_python-0.7.5/src/peakrdl_python/templates/reg_definitions.py.jinja +61 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/src/peakrdl_python.egg-info/PKG-INFO +7 -6
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/src/peakrdl_python.egg-info/SOURCES.txt +21 -1
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/src/peakrdl_python.egg-info/requires.txt +3 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/testcases/addr_map.rdl +2 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/testcases/regfile_and_arrays.rdl +1 -1
- peakrdl_python-0.7.5/tests/testcases/sizes_registers_array.rdl +23 -0
- peakrdl_python-0.7.5/tests/unit_tests/__init__.py +4 -0
- peakrdl_python-0.7.5/tests/unit_tests/simple_components.py +372 -0
- peakrdl_python-0.7.5/tests/unit_tests/test_array_indexing.py +261 -0
- peakrdl_python-0.7.5/tests/unit_tests/test_optimised_reg_array.py +359 -0
- peakrdl_python-0.7.5/tests/unit_tests/test_reg.py +510 -0
- peakrdl-python-0.7.3/docs/index.rst +0 -53
- peakrdl-python-0.7.3/src/peakrdl_python/__about__.py +0 -4
- peakrdl-python-0.7.3/src/peakrdl_python/__init__.py +0 -4
- peakrdl-python-0.7.3/src/peakrdl_python/lib/base.py +0 -527
- peakrdl-python-0.7.3/src/peakrdl_python/lib/register.py +0 -876
- peakrdl-python-0.7.3/src/peakrdl_python/templates/__init__.py +0 -4
- peakrdl-python-0.7.3/src/peakrdl_python/templates/addrmap_simulation.py.jinja +0 -0
- peakrdl-python-0.7.3/src/peakrdl_python/templates/addrmap_simulation_tb.jinja +0 -0
- peakrdl-python-0.7.3/src/peakrdl_python/templates/header.py.jinja +0 -6
- peakrdl-python-0.7.3/src/peakrdl_python/templates/header_tb.py.jinja +0 -5
- peakrdl-python-0.7.3/src/peakrdl_python/templates/reg_definitions.py.jinja +0 -84
- peakrdl-python-0.7.3/tests/unit_tests/test_array_indexing.py +0 -242
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/.gitignore +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/.readthedocs.yaml +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/LICENSE +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/MANIFEST.in +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/docs/conf.py +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/docs/genindex.rst +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/docs/requirements.txt +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/example/array_access/array_access.rdl +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/example/array_access/demo_array_access.py +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/example/optimised_access/demo_optimised_access.py +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/example/optimised_access/optimised_access.rdl +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/example/overridden_names/over_ridden_names.py +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/example/overridden_names/overridden_names.rdl +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/example/simulating_callbacks/chip_with_a_GPIO.rdl +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/example/tranversing_address_map/chip_with_registers.rdl +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/example/tranversing_address_map/dumping_register_state_to_json_file.py +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/example/tranversing_address_map/reg_dump.json +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/example/tranversing_address_map/reseting_registers.py +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/example/tranversing_address_map/writing_register_state_from_json_file.py +0 -0
- {peakrdl-python-0.7.3/tests/unit_tests → peakrdl_python-0.7.5/example/why_ral}/__init__.py +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/setup.cfg +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/src/peakrdl_python/.coveragerc +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/src/peakrdl_python.egg-info/dependency_links.txt +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/src/peakrdl_python.egg-info/entry_points.txt +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/src/peakrdl_python.egg-info/top_level.txt +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/.mypy.ini +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/alternative_template_toml/peakrdl.toml +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/alternative_templates/header.py.jinja +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/alternative_templates/header_tb.py.jinja +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/pylint.rc +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/testcases/RDLFormatCode_example.rdl +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/testcases/all_register_access_types.rdl +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/testcases/basic.rdl +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/testcases/block_a.xml +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/testcases/block_b.xml +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/testcases/different_array_types.rdl +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/testcases/enum_example.rdl +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/testcases/example_issue_106.rdl +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/testcases/field_scope.rdl +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/testcases/field_with_overridden_reset.rdl +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/testcases/fields_with_HW_write.rdl +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/testcases/fields_with_reset_values.rdl +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/testcases/memories.rdl +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/testcases/memories_with_registers.rdl +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/testcases/msb0_and_lsb0.rdl +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/testcases/multi_block.rdl +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/testcases/multifile.rdl +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/testcases/name_clash.rdl +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/testcases/overridden_python_name.rdl +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/testcases/parametrised_readonly_and_readwrite.rdl +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/testcases/same_but_different_enum.rdl +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/testcases/signals_definitions_at_various_levels.rdl +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/testcases/simple.rdl +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/testcases/simple.xml +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/testcases/sizes_registers.rdl +0 -0
- {peakrdl-python-0.7.3 → peakrdl_python-0.7.5}/tests/testcases/write_only_enum_with_undefined_reset.rdl +0 -0
|
@@ -36,6 +36,7 @@ jobs:
|
|
|
36
36
|
python -m pip install -U pylint
|
|
37
37
|
|
|
38
38
|
- name: Run Lint
|
|
39
|
+
#run: pylint --rcfile tests/pylint.rc src/peakrdl_python tests/unit_tests
|
|
39
40
|
run: pylint --rcfile tests/pylint.rc src/peakrdl_python
|
|
40
41
|
|
|
41
42
|
mypy:
|
|
@@ -59,6 +60,7 @@ jobs:
|
|
|
59
60
|
needs:
|
|
60
61
|
- mypy
|
|
61
62
|
- lint
|
|
63
|
+
|
|
62
64
|
runs-on: ubuntu-latest
|
|
63
65
|
strategy:
|
|
64
66
|
matrix:
|
|
@@ -77,10 +79,9 @@ jobs:
|
|
|
77
79
|
python -m pip install --upgrade pip
|
|
78
80
|
python -m pip install .
|
|
79
81
|
|
|
80
|
-
|
|
81
82
|
- name: Run Unit Tests
|
|
82
83
|
run: |
|
|
83
|
-
python -m unittest discover -s tests/unit_tests
|
|
84
|
+
python -m unittest discover -s tests/unit_tests -t .
|
|
84
85
|
|
|
85
86
|
- name: Generate testcases
|
|
86
87
|
run: |
|
|
@@ -150,6 +151,21 @@ jobs:
|
|
|
150
151
|
python -m demo_array_access
|
|
151
152
|
|
|
152
153
|
cd ../..
|
|
154
|
+
|
|
155
|
+
cd example/enumerated_fields/
|
|
156
|
+
peakrdl python enumerated_fields.rdl -o .
|
|
157
|
+
python -m demo_enumerated_fields
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
cd ../..
|
|
161
|
+
|
|
162
|
+
cd example/why_ral/
|
|
163
|
+
peakrdl python gpio.rdl -o .
|
|
164
|
+
python -m without_ral
|
|
165
|
+
python -m with_ral
|
|
166
|
+
python -m with_hal
|
|
167
|
+
|
|
168
|
+
cd ../..
|
|
153
169
|
#-------------------------------------------------------------------------------
|
|
154
170
|
build:
|
|
155
171
|
needs:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: peakrdl-python
|
|
3
|
-
Version: 0.7.
|
|
4
|
-
Summary: Generate
|
|
3
|
+
Version: 0.7.5
|
|
4
|
+
Summary: Generate Python Register Access Layer (RAL) from SystemRDL
|
|
5
5
|
Author: Keith Brady
|
|
6
6
|
License: GNU GENERAL PUBLIC LICENSE
|
|
7
7
|
Version 3, 29 June 2007
|
|
@@ -682,7 +682,7 @@ Project-URL: Source, https://github.com/krcb197/PeakRDL-python
|
|
|
682
682
|
Project-URL: Tracker, https://github.com/krcb197/PeakRDL-python/issues
|
|
683
683
|
Project-URL: Documentation, https://peakrdl-python.readthedocs.io/
|
|
684
684
|
Project-URL: Changelog, https://github.com/krcb197/PeakRDL-python/releases
|
|
685
|
-
Keywords:
|
|
685
|
+
Keywords: SystemRDL,PeakRDL,CSR,compiler,tool,registers,generator,Python
|
|
686
686
|
Classifier: Development Status :: 4 - Beta
|
|
687
687
|
Classifier: Programming Language :: Python
|
|
688
688
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -703,16 +703,17 @@ License-File: LICENSE
|
|
|
703
703
|
Requires-Dist: systemrdl-compiler>=1.24.0
|
|
704
704
|
Requires-Dist: jinja2
|
|
705
705
|
Requires-Dist: asynctest; python_version < "3.8"
|
|
706
|
+
Requires-Dist: typing-extensions; python_version < "3.11"
|
|
706
707
|
|
|
707
708
|

|
|
708
709
|
[](https://pypi.org/project/peakrdl-python)
|
|
709
710
|
[](https://peakrdl-python.readthedocs.io/en/latest/?badge=latest)
|
|
710
711
|
[](https://pepy.tech/project/peakrdl-python)
|
|
711
712
|
|
|
712
|
-
#
|
|
713
|
-
Generate Python
|
|
713
|
+
# peakrdl-python
|
|
714
|
+
Generate Python Register Access Layer (RAL) from SystemRDL
|
|
714
715
|
|
|
715
716
|
## Documentation
|
|
716
|
-
See the [
|
|
717
|
+
See the [peakrdl-python Documentation](https://peakrdl-python.readthedocs.io/) for more details
|
|
717
718
|
|
|
718
719
|
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
[](https://peakrdl-python.readthedocs.io/en/latest/?badge=latest)
|
|
4
4
|
[](https://pepy.tech/project/peakrdl-python)
|
|
5
5
|
|
|
6
|
-
#
|
|
7
|
-
Generate Python
|
|
6
|
+
# peakrdl-python
|
|
7
|
+
Generate Python Register Access Layer (RAL) from SystemRDL
|
|
8
8
|
|
|
9
9
|
## Documentation
|
|
10
|
-
See the [
|
|
10
|
+
See the [peakrdl-python Documentation](https://peakrdl-python.readthedocs.io/) for more details
|
|
11
11
|
|
|
12
12
|
|
|
@@ -16,7 +16,7 @@ Example
|
|
|
16
16
|
=======
|
|
17
17
|
|
|
18
18
|
The following example shows the compiling an SystemRDL file and then generating
|
|
19
|
-
the python register
|
|
19
|
+
the python register access layer using PeakRDL Python.
|
|
20
20
|
|
|
21
21
|
.. code-block:: python
|
|
22
22
|
|
|
@@ -28,7 +28,7 @@ the python register abstraction layer using PeakRDL Python.
|
|
|
28
28
|
rdlc.compile_file('basic.rdl')
|
|
29
29
|
spec = rdlc.elaborate(top_def_name='basic').top
|
|
30
30
|
|
|
31
|
-
# generate the python package register
|
|
31
|
+
# generate the python package register access layer
|
|
32
32
|
exporter = PythonExporter()
|
|
33
33
|
exporter.export(node=spec, path='generated_code')
|
|
34
34
|
|
|
@@ -65,7 +65,7 @@ Memories
|
|
|
65
65
|
:inherited-members:
|
|
66
66
|
|
|
67
67
|
Registers
|
|
68
|
-
|
|
68
|
+
=========
|
|
69
69
|
|
|
70
70
|
.. autoclass:: peakrdl_python.lib.register.RegReadOnly
|
|
71
71
|
:members:
|
|
@@ -93,6 +93,7 @@ Registers
|
|
|
93
93
|
|
|
94
94
|
Register Fields
|
|
95
95
|
^^^^^^^^^^^^^^^
|
|
96
|
+
A register will always have fields within it
|
|
96
97
|
|
|
97
98
|
.. autoclass:: peakrdl_python.lib.fields.FieldReadOnly
|
|
98
99
|
:members:
|
|
@@ -116,4 +117,4 @@ Register Fields
|
|
|
116
117
|
|
|
117
118
|
.. autoclass:: peakrdl_python.lib.fields.FieldEnumReadWrite
|
|
118
119
|
:members:
|
|
119
|
-
:inherited-members:
|
|
120
|
+
:inherited-members:
|
|
@@ -4,7 +4,7 @@ Command Line Interface
|
|
|
4
4
|
PeakRDL Python can either be run from within another Python script or using the
|
|
5
5
|
command line program via the PeakRDL suite
|
|
6
6
|
|
|
7
|
-
In order to use the PeakRDL Suite it must be installed:
|
|
7
|
+
In order to use the PeakRDL Suite it must be installed first, see :ref:`peakrdl_installation`.
|
|
8
8
|
|
|
9
9
|
.. code-block:: bash
|
|
10
10
|
|
|
@@ -46,7 +46,7 @@ The path to the folder of alternative templates must be ``PythonExporter`` is in
|
|
|
46
46
|
rdlc.compile_file('basic.rdl')
|
|
47
47
|
spec = rdlc.elaborate(top_def_name='basic').top
|
|
48
48
|
|
|
49
|
-
# generate the python package register
|
|
49
|
+
# generate the python package register access layer
|
|
50
50
|
exporter = PythonExporter(user_template_dir='my_company_headers')
|
|
51
51
|
exporter.export(node=spec, path='generated_code')
|
|
52
52
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Design Decisions
|
|
2
|
+
****************
|
|
3
|
+
|
|
4
|
+
A collection of notes to explain some of the design decisions to potential developers and
|
|
5
|
+
advanced users
|
|
6
|
+
|
|
7
|
+
'Pure' Python
|
|
8
|
+
=============
|
|
9
|
+
|
|
10
|
+
The peakrdl-python RAL was designed to have very limited dependencies on other packages once
|
|
11
|
+
deployed, this includes the peakrdl-python packages itself, so the library classes are copied
|
|
12
|
+
into the generated package.
|
|
13
|
+
|
|
14
|
+
It does need a few packages inorder to build it:
|
|
15
|
+
|
|
16
|
+
* systemrdl-compiler
|
|
17
|
+
* jinja2
|
|
18
|
+
|
|
19
|
+
Integer Data Types
|
|
20
|
+
===================
|
|
21
|
+
|
|
22
|
+
All the APIs present memory, register and field entries as python integers. This abstracts, the
|
|
23
|
+
complexity of byte ordering and reversed registers.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Design Tools
|
|
2
|
+
************
|
|
3
|
+
|
|
4
|
+
In order to assist developers peakrdl-python can be run from a script. This means the
|
|
5
|
+
peakrdl-python package does not need to be installed and uninstalled during development.
|
|
6
|
+
|
|
7
|
+
See ``generate_and_test.py``
|
|
8
|
+
|
|
9
|
+
.. code-block:: bash
|
|
10
|
+
|
|
11
|
+
python -m generate_and_test --RDL_source_file "tests\testcases\basic.rdl" --root_node "basic"
|
|
@@ -3,9 +3,9 @@ Generated Package
|
|
|
3
3
|
|
|
4
4
|
Output Structure
|
|
5
5
|
================
|
|
6
|
-
PeakRDL Python generates a python
|
|
7
|
-
|
|
8
|
-
with the package was generated
|
|
6
|
+
PeakRDL Python generates a python Register Access Layer (RAL) from a System RDL design. The
|
|
7
|
+
generated python code is contained in a package, structured as shown below. The ``root_name``
|
|
8
|
+
will be based on the top level address map name with the package was generated
|
|
9
9
|
|
|
10
10
|
| ``<root_name>``
|
|
11
11
|
| ├── ``lib``
|
|
@@ -16,11 +16,9 @@ with the package was generated
|
|
|
16
16
|
|
|
17
17
|
In the folder structure above:
|
|
18
18
|
|
|
19
|
-
- ``<root_name>.py`` - This is the register
|
|
20
|
-
- ``lib`` - This is a package of base classes used by the register
|
|
21
|
-
- ``test_<root_name>.py`` - This is a set of autogenerated unittests to verify the register
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
- ``<root_name>.py`` - This is the register access layer code for the design
|
|
20
|
+
- ``lib`` - This is a package of base classes used by the register access layer
|
|
21
|
+
- ``test_<root_name>.py`` - This is a set of autogenerated unittests to verify the register access layer
|
|
24
22
|
|
|
25
23
|
|
|
26
24
|
Running the Unit Tests
|
|
@@ -32,18 +30,18 @@ included in the Python standard installation.
|
|
|
32
30
|
Callbacks
|
|
33
31
|
=========
|
|
34
32
|
|
|
35
|
-
The Register
|
|
33
|
+
The Register Access Layer will typically interfaced to a driver that
|
|
36
34
|
allows accesses the chip. However, it can also be interfaced to a simulation
|
|
37
35
|
of the device.
|
|
38
36
|
|
|
39
|
-
In order to operate the register
|
|
37
|
+
In order to operate the register access layer typically requires the following:
|
|
40
38
|
|
|
41
39
|
- A callback for a single register write, this not required if there is no writable register in
|
|
42
|
-
the register
|
|
40
|
+
the register access layer
|
|
43
41
|
- A callback for a single register read, this not required if there is no writable register in
|
|
44
|
-
the register
|
|
42
|
+
the register access layer
|
|
45
43
|
|
|
46
|
-
In addition the register
|
|
44
|
+
In addition the register access layer can make use of block operations where a block of the
|
|
47
45
|
address space is read in a single transaction. Not all drivers support these
|
|
48
46
|
|
|
49
47
|
The examples of these two methods are included within the generated register
|
|
@@ -97,16 +95,16 @@ In addition there is also an option to use ``async`` callbacks if the package is
|
|
|
97
95
|
Callback Set
|
|
98
96
|
------------
|
|
99
97
|
|
|
100
|
-
The callbacks are passed into the register
|
|
98
|
+
The callbacks are passed into the register access layer using either:
|
|
101
99
|
|
|
102
100
|
* ``NormalCallbackSet`` for standard python function callbacks
|
|
103
101
|
* ``AsyncCallbackSet`` for async python function callbacks, these are called from the library using
|
|
104
102
|
``await``
|
|
105
103
|
|
|
106
|
-
Using the Register
|
|
107
|
-
|
|
104
|
+
Using the Register Access Layer
|
|
105
|
+
===============================
|
|
108
106
|
|
|
109
|
-
The register
|
|
107
|
+
The register access layer package is intended to integrated into another
|
|
110
108
|
piece of code. That code could be a simple test script for blinking an LED on a
|
|
111
109
|
GPIO or it could be a more complex application with a GUI.
|
|
112
110
|
|
|
@@ -131,7 +129,7 @@ a file called ``chip_with_a_GPIO.rdl``:
|
|
|
131
129
|
|
|
132
130
|
.. tip:: It is always good practice to run the unittests on the generated code.
|
|
133
131
|
|
|
134
|
-
Once the register
|
|
132
|
+
Once the register access layer has been generated and it can be used. The following example
|
|
135
133
|
does not actually use a device driver. Instead it chip simulator with a a Tkinter GUI,
|
|
136
134
|
incorporating a RED circle to represent the LED. The chip simulator has read and write methods (
|
|
137
135
|
equivalent to those offered by a device driver), these look at the address of the write and update
|
|
@@ -141,9 +139,56 @@ simulator.
|
|
|
141
139
|
.. literalinclude :: ../example/simulating_callbacks/flashing_the_LED.py
|
|
142
140
|
:language: python
|
|
143
141
|
|
|
142
|
+
Enumerated Fields
|
|
143
|
+
-----------------
|
|
144
|
+
|
|
145
|
+
Enumerations are a good practice to implicitly encode that have special meanings which can not be
|
|
146
|
+
easily understood from the field name. The SystemRDL enumerations are implemented using python
|
|
147
|
+
|
|
148
|
+
.. literalinclude :: ../example/enumerated_fields/enumerated_fields.rdl
|
|
149
|
+
:language: systemrdl
|
|
150
|
+
|
|
151
|
+
This systemRDL code can be built using the command line tool as follows (assuming it is stored in
|
|
152
|
+
a file called ``enumerated_fields.rdl``):
|
|
153
|
+
|
|
154
|
+
.. code-block:: bash
|
|
155
|
+
|
|
156
|
+
peakrdl python enumerated_fields.rdl -o .
|
|
157
|
+
|
|
158
|
+
The following example shows the usage of the enumeration
|
|
159
|
+
|
|
160
|
+
.. note::
|
|
161
|
+
In order to set the value of an enumerated field, using the ``write()`` method. The correct
|
|
162
|
+
enumerated class is needed. This can be retrieved from the field itself with the ``enum_cls``
|
|
163
|
+
property
|
|
164
|
+
|
|
165
|
+
.. literalinclude :: ../example/enumerated_fields/demo_enumerated_fields.py
|
|
166
|
+
:language: python
|
|
167
|
+
|
|
168
|
+
Array Access
|
|
169
|
+
------------
|
|
170
|
+
|
|
171
|
+
SystemRDL supports multi-dimensional arrays, the following example shows an definition with an 1D and 3D array with various methods to access individual elements of the array and use of the iterators to walk through elements in loops
|
|
172
|
+
|
|
173
|
+
.. literalinclude :: ../example/array_access/array_access.rdl
|
|
174
|
+
:language: systemrdl
|
|
175
|
+
|
|
176
|
+
This systemRDL code can be built using the command line tool as follows (assuming it is stored in
|
|
177
|
+
a file called ``array_access.rdl``):
|
|
178
|
+
|
|
179
|
+
.. code-block:: bash
|
|
180
|
+
|
|
181
|
+
peakrdl python array_access.rdl -o .
|
|
182
|
+
|
|
183
|
+
.. literalinclude :: ../example/array_access/demo_array_access.py
|
|
184
|
+
:language: python
|
|
185
|
+
|
|
144
186
|
Optimised Access
|
|
145
187
|
----------------
|
|
146
188
|
|
|
189
|
+
Working with individual registers
|
|
190
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
191
|
+
|
|
147
192
|
Each time the ``read`` or ``write`` method for a register field is accessed the hardware is read
|
|
148
193
|
and or written (a write to a field will normally require a preceding read). When accessing multiple
|
|
149
194
|
fields in the same register, it may be desirable to use one of the optimised access methods.
|
|
@@ -164,10 +209,27 @@ Both demonstrated in the following code example:
|
|
|
164
209
|
.. literalinclude :: ../example/optimised_access/demo_optimised_access.py
|
|
165
210
|
:language: python
|
|
166
211
|
|
|
212
|
+
Working with registers arrays
|
|
213
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
214
|
+
|
|
215
|
+
In many systems it is more efficient to read and write in block operations rather than using
|
|
216
|
+
individual register access.
|
|
217
|
+
|
|
218
|
+
Consider the following example of an GPIO block with 8 GPIO pins (configured in a 8 registers):
|
|
219
|
+
|
|
220
|
+
.. literalinclude :: ../example/optimised_access/optimised_array_access.rdl
|
|
221
|
+
:language: systemrdl
|
|
222
|
+
|
|
223
|
+
In order to configure all the GPIOs a range of operations are shown with the use of the context
|
|
224
|
+
managers to make more efficient operations
|
|
225
|
+
|
|
226
|
+
.. literalinclude :: ../example/optimised_access/demo_optimised_array_access.py
|
|
227
|
+
:language: python
|
|
228
|
+
|
|
167
229
|
Walking the Structure
|
|
168
230
|
---------------------
|
|
169
231
|
|
|
170
|
-
The following two example show how to use the generators within the register
|
|
232
|
+
The following two example show how to use the generators within the register access layer
|
|
171
233
|
package to traverse the structure.
|
|
172
234
|
|
|
173
235
|
Both examples use the following register set which has a number of features to demonstrate the
|
|
@@ -177,7 +239,7 @@ structures
|
|
|
177
239
|
:language: systemrdl
|
|
178
240
|
|
|
179
241
|
This systemRDL code can be built using the command line tool as follows (assuming it is stored in
|
|
180
|
-
a file called ``chip_with_registers.rdl
|
|
242
|
+
a file called ``chip_with_registers.rdl``):
|
|
181
243
|
|
|
182
244
|
.. code-block:: bash
|
|
183
245
|
|
|
@@ -286,25 +348,6 @@ worry if they are in an array or not.
|
|
|
286
348
|
.. literalinclude :: ../example/tranversing_address_map/reseting_registers.py
|
|
287
349
|
:language: python
|
|
288
350
|
|
|
289
|
-
|
|
290
|
-
Array Access
|
|
291
|
-
------------
|
|
292
|
-
|
|
293
|
-
SystemRDL supports multi-dimensional arrays, the following example shows an definition with an 1D and 3D array with various methods to access individual elements of the array and use of the iterators to walk through elements in loops
|
|
294
|
-
|
|
295
|
-
.. literalinclude :: ../example/array_access/array_access.rdl
|
|
296
|
-
:language: systemrdl
|
|
297
|
-
|
|
298
|
-
This systemRDL code can be built using the command line tool as follows (assuming it is stored in
|
|
299
|
-
a file called ``array_access.rdl``:
|
|
300
|
-
|
|
301
|
-
.. code-block:: bash
|
|
302
|
-
|
|
303
|
-
peakrdl python array_access.rdl -o .
|
|
304
|
-
|
|
305
|
-
.. literalinclude :: ../example/array_access/demo_array_access.py
|
|
306
|
-
:language: python
|
|
307
|
-
|
|
308
351
|
Python Safe Names
|
|
309
352
|
=================
|
|
310
353
|
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
PeakRDL Python
|
|
2
|
+
##############
|
|
3
|
+
|
|
4
|
+
Introduction
|
|
5
|
+
============
|
|
6
|
+
|
|
7
|
+
PeakRDL Python is a python package which can be used to generate a register
|
|
8
|
+
access layer python package from a SystemRDL definition.
|
|
9
|
+
|
|
10
|
+
SystemRDL and control & status register (CSR) generator toolchain
|
|
11
|
+
=================================================================
|
|
12
|
+
|
|
13
|
+
SystemRDL, more accurately `SystemRDL 2.0 <https://www.accellera.org/images/downloads/standards/systemrdl/SystemRDL_2.0_Jan2018.pdf>`_
|
|
14
|
+
is a description language that describes the registers in a device, for example an FPGA or
|
|
15
|
+
Integrated Circuit (IC). Using this technology allows other parts of the design flow to be
|
|
16
|
+
automatically generated, avoiding mistakes with inconsistencies and speeding up the design flow.
|
|
17
|
+
|
|
18
|
+
The suite of tools needed for this flow are called a control & status register (CSR) generator.
|
|
19
|
+
|
|
20
|
+
.. note:: This documentation does not attempt to explain all the good reasons for wanted a
|
|
21
|
+
CSR generator, other people have done a far better job.
|
|
22
|
+
|
|
23
|
+
PeakRDl Python is intended to be part of CSR generator flow.
|
|
24
|
+
|
|
25
|
+
What is a Register Access Layer (RAL)
|
|
26
|
+
=====================================
|
|
27
|
+
|
|
28
|
+
A Register Access Layer is a software component to make writing scripts and software to control
|
|
29
|
+
a device with hardware registers easier.
|
|
30
|
+
|
|
31
|
+
Hardware Abstraction Layer (HAL) versus Register Access Layer (RAL)
|
|
32
|
+
*******************************************************************
|
|
33
|
+
|
|
34
|
+
.. note:: The Register Access Layer (RAL) is aimed at people who understand the registers in the
|
|
35
|
+
device.
|
|
36
|
+
|
|
37
|
+
At some point another software component called a Hardware Abstraction Layer (HAL) will often
|
|
38
|
+
get produced that abstracts the device function providing functions to do more useful things.
|
|
39
|
+
The RAL could be used as part of a HAL.
|
|
40
|
+
|
|
41
|
+
.. note:: The Hardware Abstraction Layer (HAL) provides abstact functionality and allows
|
|
42
|
+
people to use the device without needing a full knowledge of how it works.
|
|
43
|
+
|
|
44
|
+
What does it do
|
|
45
|
+
***************
|
|
46
|
+
|
|
47
|
+
The use of a RAL is best shown with an example
|
|
48
|
+
|
|
49
|
+
Imagine a script to carry out a simple task on a IC, configure an GPIO Pin as an output and
|
|
50
|
+
set the state to `1`. The device has 8 GPIO pins controlled from two registers.
|
|
51
|
+
|
|
52
|
+
+----------+---------+-------------------------------------------------------------------------------------------------------+------------------------+
|
|
53
|
+
| Register | Address | Bit | Function |
|
|
54
|
+
| | +------------+------------+------------+------------+------------+------------+------------+------------+ |
|
|
55
|
+
| | | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |
|
|
56
|
+
+==========+=========+============+============+============+============+============+============+============+============+========================+
|
|
57
|
+
| DIR | 0x100 | GPIO_7_DIR | GPIO_6_DIR | GPIO_5_DIR | GPIO_4_DIR | GPIO_3_DIR | GPIO_2_DIR | GPIO_1_DIR | GPIO_0_DIR | Sets direction of GPIO |
|
|
58
|
+
| | | | | | | | | | | +-------+---------+ |
|
|
59
|
+
| | | | | | | | | | | | Value | Meaning | |
|
|
60
|
+
| | | | | | | | | | | +=======+=========+ |
|
|
61
|
+
| | | | | | | | | | | | 0 | In | |
|
|
62
|
+
| | | | | | | | | | | +-------+---------+ |
|
|
63
|
+
| | | | | | | | | | | | 1 | Out | |
|
|
64
|
+
| | | | | | | | | | | +-------+---------+ |
|
|
65
|
+
| | | | | | | | | | | |
|
|
66
|
+
+----------+---------+------------+------------+------------+------------+------------+------------+------------+------------+------------------------+
|
|
67
|
+
| DATA_OUT | 0x104 | GPIO_7_OUT | GPIO_6_OUT | GPIO_5_OUT | GPIO_4_OUT | GPIO_3_OUT | GPIO_2_OUT | GPIO_1_OUT | GPIO_0_OUT | Sets the state of a |
|
|
68
|
+
| | | | | | | | | | | GPIO configured as out |
|
|
69
|
+
+----------+---------+------------+------------+------------+------------+------------+------------+------------+------------+------------------------+
|
|
70
|
+
|
|
71
|
+
This example uses a simple simulation class to mimic the behaviour of the device offering ``read`` and ``write``
|
|
72
|
+
methods to offer register read and write access to the device. In the real work this would likely go
|
|
73
|
+
via a device driver or JTAG emulator, if the software is running off chip (i.e. a PC).
|
|
74
|
+
|
|
75
|
+
.. literalinclude :: ../example/why_ral/hardware_sim.py
|
|
76
|
+
:language: python
|
|
77
|
+
|
|
78
|
+
To configure pin 0 and set its state you would need to do the following steps:
|
|
79
|
+
|
|
80
|
+
1. Read the DIR register (to make sure you preserve the states of other pins)
|
|
81
|
+
2. Take the read value of the DIR register, force bit 0 to `1` then write it back
|
|
82
|
+
3. Read the DATA_OUT register (to make sure you preserve the states of other pins)
|
|
83
|
+
4. Take the read value of the DATA_OUT register, force bit 0 to `1` then write it back
|
|
84
|
+
|
|
85
|
+
If you had a simple environment that only had register read / write function, the code would be
|
|
86
|
+
as follows:
|
|
87
|
+
|
|
88
|
+
.. literalinclude :: ../example/why_ral/without_ral.py
|
|
89
|
+
:language: python
|
|
90
|
+
|
|
91
|
+
This code requires addresses to be hard coded, remembering to do read/modify/writes and bit
|
|
92
|
+
manipulations
|
|
93
|
+
|
|
94
|
+
.. warning:: A Register Access Layer (RAL) is not for everyone. Some engineers like to see the
|
|
95
|
+
address of each register and the content of a register as a hex word. You may be quite
|
|
96
|
+
happy with this, if that is you please stop, the overhead of an extra
|
|
97
|
+
layer, its opaque nature and inefficency will annoy you.
|
|
98
|
+
|
|
99
|
+
In order to move on the systemRDL code for the registers needs to exist
|
|
100
|
+
|
|
101
|
+
.. literalinclude :: ../example/why_ral/gpio.rdl
|
|
102
|
+
:language: systemrdl
|
|
103
|
+
|
|
104
|
+
In order to build the code (assuming you have everything installed), use the following
|
|
105
|
+
|
|
106
|
+
.. code-block:: bash
|
|
107
|
+
|
|
108
|
+
peakrdl python gpio.rdl -o .
|
|
109
|
+
|
|
110
|
+
Once built, a set of test cases can be run on the code to confirm its integrity, this is using the
|
|
111
|
+
``unittest`` framework that comes with python
|
|
112
|
+
|
|
113
|
+
.. code-block:: bash
|
|
114
|
+
|
|
115
|
+
python -m unittest discover -s gpio\tests -t .
|
|
116
|
+
|
|
117
|
+
Using the RAL allows for much simipler to understand code that does the function that was intended
|
|
118
|
+
|
|
119
|
+
.. literalinclude :: ../example/why_ral/with_ral.py
|
|
120
|
+
:language: python
|
|
121
|
+
|
|
122
|
+
The final part of this example shows a Hardware Abstraction Layer (HAL), in this case the GPIO pins
|
|
123
|
+
are abstracted to look like an array and the direction is automatically configured when the user
|
|
124
|
+
attempts to set the output state.
|
|
125
|
+
|
|
126
|
+
.. literalinclude :: ../example/why_ral/with_hal.py
|
|
127
|
+
:language: python
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
.. toctree::
|
|
131
|
+
:hidden:
|
|
132
|
+
:caption: Overview
|
|
133
|
+
|
|
134
|
+
self
|
|
135
|
+
|
|
136
|
+
.. toctree::
|
|
137
|
+
:hidden:
|
|
138
|
+
:maxdepth: 2
|
|
139
|
+
:caption: usage
|
|
140
|
+
|
|
141
|
+
installation
|
|
142
|
+
generated_package
|
|
143
|
+
api_components
|
|
144
|
+
api
|
|
145
|
+
command_line
|
|
146
|
+
customisation
|
|
147
|
+
|
|
148
|
+
.. toctree::
|
|
149
|
+
:hidden:
|
|
150
|
+
:maxdepth: 2
|
|
151
|
+
:caption: developer notes
|
|
152
|
+
|
|
153
|
+
design_decisions
|
|
154
|
+
design_tools
|
|
155
|
+
|
|
156
|
+
.. toctree::
|
|
157
|
+
:hidden:
|
|
158
|
+
:caption: other
|
|
159
|
+
|
|
160
|
+
genindex
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Installation
|
|
2
|
+
************
|
|
3
|
+
|
|
4
|
+
Dependencies
|
|
5
|
+
============
|
|
6
|
+
|
|
7
|
+
peakrdl-python runs in any modern version of python 3. This needs to be installed first
|
|
8
|
+
|
|
9
|
+
Installing the Package
|
|
10
|
+
======================
|
|
11
|
+
|
|
12
|
+
Install from `PyPi`_ using pip
|
|
13
|
+
|
|
14
|
+
.. code-block:: bash
|
|
15
|
+
|
|
16
|
+
python3 -m pip install peakrdl-python
|
|
17
|
+
|
|
18
|
+
.. _PyPi: https://pypi.org/project/peakrdl-python
|
|
19
|
+
|
|
20
|
+
.. note:: peakrdl-python uses the systemrdl-compiler. If your source files use
|
|
21
|
+
the embedded Perl preprocess refer to the installation instruction for
|
|
22
|
+
`systemrdl-compiler <https://pypi.org/project/systemrdl-compiler/>`_
|
|
23
|
+
|
|
24
|
+
.. _peakrdl_installation:
|
|
25
|
+
|
|
26
|
+
peakrdl
|
|
27
|
+
=======
|
|
28
|
+
|
|
29
|
+
`PeakRDL <https://pypi.org/project/peakrdl/>`_ is not a required dependency of PeakRDL Python,
|
|
30
|
+
therefore, it is not automatically installed. However, if you want to use the command line method
|
|
31
|
+
of invoking peakrdl-python
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""
|
|
2
|
+
A demonstration of using enumeration
|
|
3
|
+
"""
|
|
4
|
+
from enumerated_fields.lib import NormalCallbackSet
|
|
5
|
+
|
|
6
|
+
from enumerated_fields.reg_model.enumerated_fields import enumerated_fields_cls as GPIO
|
|
7
|
+
|
|
8
|
+
class HardwareSimulator:
|
|
9
|
+
def __init__(self):
|
|
10
|
+
# use a python dictionary to simulate the hardware
|
|
11
|
+
self._address_space = {0x00: 0, 0x04: 0}
|
|
12
|
+
|
|
13
|
+
def read(self, addr: int, width: int = 32, accesswidth: int = 32) -> int:
|
|
14
|
+
"""
|
|
15
|
+
function to simulate a device read
|
|
16
|
+
"""
|
|
17
|
+
return self._address_space[addr]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def write(self, addr: int, data: int, width: int=32, accesswidth: int=32) -> None:
|
|
21
|
+
"""
|
|
22
|
+
function to simulate a device read
|
|
23
|
+
"""
|
|
24
|
+
self._address_space[addr] = data
|
|
25
|
+
|
|
26
|
+
if __name__ == '__main__':
|
|
27
|
+
|
|
28
|
+
# create an instance of the hardware simulator
|
|
29
|
+
hw = HardwareSimulator()
|
|
30
|
+
# create an instance of the RAL with the callbacks directed at the hardware simulator
|
|
31
|
+
gpio = GPIO(callbacks=NormalCallbackSet(read_callback=hw.read, write_callback=hw.write))
|
|
32
|
+
|
|
33
|
+
# get the field values
|
|
34
|
+
for field in gpio.gpio_strength.readable_fields:
|
|
35
|
+
print(f'{field.inst_name} has strength {field.read().name} [0x{field.read().value}]')
|
|
36
|
+
|
|
37
|
+
# set the field values by retrieving the enum class from the class itself
|
|
38
|
+
CurrentEnum = gpio.gpio_strength.gpio_0.enum_cls
|
|
39
|
+
gpio.gpio_strength.gpio_0.write(CurrentEnum.STRENGTH_12MA)
|