Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option that will add a table to the documentation with an overview of all of the parameters that have a lock indicator #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions corsair/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,16 +501,19 @@ class Markdown(Generator, Jinja2, Wavedrom):
:type image_dir: str
:param print_conventions: Enable generating table with register access modes explained
:type print_conventions: bool
:param print_lock_parameters: Enable generating table with overview of the parameters with lock marking
:type print_lock_parameters: bool
"""

def __init__(self, rmap=None, path='regs.md', title='Register map',
print_images=True, image_dir="regs_img", print_conventions=True, **args):
def __init__(self, rmap=None, path='regs.md', title='Register map', print_images=True,
image_dir="regs_img", print_conventions=True, print_lock_parameters=False, **args):
super().__init__(rmap, **args)
self.path = path
self.title = title
self.print_images = print_images
self.image_dir = image_dir
self.print_conventions = print_conventions
self.print_lock_parameters = print_lock_parameters

def generate(self):
filename = utils.get_file_name(self.path)
Expand All @@ -523,6 +526,7 @@ def generate(self):
j2_vars['rmap'] = self.rmap
j2_vars['print_images'] = utils.str2bool(self.print_images)
j2_vars['print_conventions'] = utils.str2bool(self.print_conventions)
j2_vars['print_lock_parameters'] = utils.str2bool(self.print_lock_parameters)
j2_vars['image_dir'] = self.image_dir
j2_vars['filename'] = filename
j2_vars['title'] = self.title
Expand All @@ -549,16 +553,19 @@ class Asciidoc(Generator, Jinja2, Wavedrom):
:type image_dir: str
:param print_conventions: Enable generating table with register access modes explained
:type print_conventions: bool
:param print_lock_parameters: Enable generating table with overview of the parameters with lock marking
:type print_lock_parameters: bool
"""

def __init__(self, rmap=None, path='regs.adoc', title='Register map',
print_images=True, image_dir="regs_img", print_conventions=True, **args):
def __init__(self, rmap=None, path='regs.adoc', title='Register map', print_images=True,
image_dir="regs_img", print_conventions=True, print_lock_parameters=False, **args):
super().__init__(rmap, **args)
self.path = path
self.title = title
self.print_images = print_images
self.image_dir = image_dir
self.print_conventions = print_conventions
self.print_lock_parameters = print_lock_parameters

def generate(self):
filename = utils.get_file_name(self.path)
Expand All @@ -571,6 +578,7 @@ def generate(self):
j2_vars['rmap'] = self.rmap
j2_vars['print_images'] = utils.str2bool(self.print_images)
j2_vars['print_conventions'] = utils.str2bool(self.print_conventions)
j2_vars['print_lock_parameters'] = utils.str2bool(self.print_lock_parameters)
j2_vars['image_dir'] = self.image_dir
j2_vars['filename'] = filename
j2_vars['title'] = self.title
Expand Down
18 changes: 18 additions & 0 deletions corsair/templates/regmap_asciidoc.j2
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ Base address: {{ "0x%08x" % config['base_address'] }}
{% endfor %}
|==========================

{% if print_lock_parameters %}
=== Overview lock parameters

The following table gives an overview of all the parameters that are connected to the lock signal.
When the lock signal is active these parameters are write protected.

[#table-Overview_lock_parameters,cols="1,1", options="header"]
|==========================
| Register Name | Parameter Name
{% for reg in rmap %}
{% for bitfield in reg.bitfields %}
{% if 'l' in bitfield.hardware %}
{{ "| %-10s | %s" % ("<<%s>>" % (reg.name), bitfield.name) }} |
{% endif %}
{% endfor %}
{% endfor %}
|==========================
{% endif %}

{% for reg in rmap %}

Expand Down
19 changes: 18 additions & 1 deletion corsair/templates/regmap_md.j2
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,25 @@ Base address: {{ "0x%08x" % config['base_address'] }}
{% for reg in rmap %}
{{ "| %-24s | %-10s | %s" % ("[%s](#%s)" % (reg.name, reg.name.lower()), literal(reg.address, config['address_width']), reg.description) }} |
{% endfor %}
{% for reg in rmap %}

{% if print_lock_parameters %}
## Overview lock parameters

The following table gives an overview of all the parameters that are connected to the lock signal.
When the lock signal is active these parameters are write protected.

| Register Name | Parameter Name |
| :------------ | :------------- |
{% for reg in rmap %}
{% for bitfield in reg.bitfields %}
{% if 'l' in bitfield.hardware %}
{{ "| %-10s | %s" % ("[%s](#%s)" % (reg.name, reg.name.lower()), bitfield.name) }} |
{% endif %}
{% endfor %}
{% endfor %}
{% endif %}

{% for reg in rmap %}
## {{ reg.name }}

{{ reg.description }}
Expand Down