aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorchrysn2012-03-04 22:43:52 +0100
committerchrysn2012-03-04 22:43:52 +0100
commit692817059cb53fe854e7c4d8f3c0e3a8a6836eab (patch)
tree137cafc9059e52997f9cdb3a068776a1a23ad07e /include
parentc2fdd6e75148911306cff8c32bf341f3533c178f (diff)
various enhancements for header generation
* don't reference sections that don't exist (typically happens for registers that don't contain any fields and are interpreted numerically. * allow templates to use override_backref for surpressing the list of registers that use it * print doc for fields even when it uses values or only exports a mask * allow fields to define their own mask; those fields have to define their values explicitly too, and don't have to provide a shift * don't print a "No values defined for the field" lines, as there's always a mask in that case by now.
Diffstat (limited to 'include')
-rw-r--r--include/libopencm3/efm32/tinygecko/cmu.h9
-rw-r--r--include/libopencm3/efm32/tinygecko/cmu.yaml2
-rw-r--r--include/libopencm3/efm32/tinygecko/generate.py46
3 files changed, 34 insertions, 23 deletions
diff --git a/include/libopencm3/efm32/tinygecko/cmu.h b/include/libopencm3/efm32/tinygecko/cmu.h
index db0cbde..80c959f 100644
--- a/include/libopencm3/efm32/tinygecko/cmu.h
+++ b/include/libopencm3/efm32/tinygecko/cmu.h
@@ -53,10 +53,10 @@
#define CMU_HFCORECLKDIV MMIO32(CMU_BASE + 0x004) /**< @see EFM32TG_CMU_HFCORECLKDIV_values */
#define CMU_HFPERCLKDIV MMIO32(CMU_BASE + 0x008) /**< @see EFM32TG_CMU_HFPERCLKDIV_bits */
#define CMU_HFRCOCTRL MMIO32(CMU_BASE + 0x00c) /**< @see EFM32TG_CMU_HFRCOCTRL_bits */
-#define CMU_LFRCOCTRL MMIO32(CMU_BASE + 0x010) /**< @see EFM32TG_CMU_LFRCOCTRL_bits */
+#define CMU_LFRCOCTRL MMIO32(CMU_BASE + 0x010)
#define CMU_AUXHFRCOCTRL MMIO32(CMU_BASE + 0x014) /**< @see EFM32TG_CMU_AUXHFRCOCTRL_bits */
#define CMU_CALCTRL MMIO32(CMU_BASE + 0x018) /**< @see EFM32TG_CMU_CALCTRL_bits */
-#define CMU_CALCNT MMIO32(CMU_BASE + 0x01c) /**< @see EFM32TG_CMU_CALCNT_bits */
+#define CMU_CALCNT MMIO32(CMU_BASE + 0x01c)
#define CMU_OSCENCMD MMIO32(CMU_BASE + 0x020) /**< @see EFM32TG_CMU_OSCENCMD_bits */
#define CMU_CMD MMIO32(CMU_BASE + 0x024) /**< @see EFM32TG_CMU_CMD_bits */
#define CMU_LFCLKSEL MMIO32(CMU_BASE + 0x028) /**< @see EFM32TG_CMU_LFCLKSEL_bits */
@@ -128,7 +128,6 @@
#define CMU_CTRL_HFXOTIMEOUT_16KCYCLES (3<<9)
#define CMU_CTRL_HFXOTIMEOUT_MASK (0x3<<9)
#define CMU_CTRL_HFXOGLITCHDETEN (1<<7)
-/* No values defined for the field HFXOBUFCUR */
#define CMU_CTRL_HFXOBUFCUR_MASK (0x3<<5)
#define CMU_CTRL_HFXOBOOST_50PCENT (0<<2)
#define CMU_CTRL_HFXOBOOST_70PCENT (1<<2)
@@ -194,7 +193,6 @@
* @{
*/
-/* No values defined for the field SUDELAY */
#define CMU_HFRCOCTRL_SUDELAY_MASK (0x1f<<12)
#define CMU_HFRCOCTRL_BAND_1MHZ (0<<8)
#define CMU_HFRCOCTRL_BAND_7MHZ (1<<8)
@@ -203,7 +201,6 @@
#define CMU_HFRCOCTRL_BAND_21MHZ (4<<8)
#define CMU_HFRCOCTRL_BAND_28MHZ (5<<8)
#define CMU_HFRCOCTRL_BAND_MASK (0x7<<8)
-/* No values defined for the field TUNING */
#define CMU_HFRCOCTRL_TUNING_MASK (0xff<<0)
/** @} */
@@ -223,7 +220,6 @@
#define CMU_AUXHFRCOCTRL_BAND_28MHZ (6<<8)
#define CMU_AUXHFRCOCTRL_BAND_21MHZ (7<<8)
#define CMU_AUXHFRCOCTRL_BAND_MASK (0x7<<8)
-/* No values defined for the field TUNING */
#define CMU_AUXHFRCOCTRL_TUNING_MASK (0xff<<0)
/** @} */
@@ -542,7 +538,6 @@
#define CMU_LCDCTRL_VBFDIV_DIV128 (7<<4)
#define CMU_LCDCTRL_VBFDIV_MASK (0x7<<4)
#define CMU_LCDCTRL_VBOOSTEN (1<<3)
-/* No values defined for the field FDIV */
#define CMU_LCDCTRL_FDIV_MASK (0x7<<0)
/** @} */
diff --git a/include/libopencm3/efm32/tinygecko/cmu.yaml b/include/libopencm3/efm32/tinygecko/cmu.yaml
index 6153c47..7b83b7f 100644
--- a/include/libopencm3/efm32/tinygecko/cmu.yaml
+++ b/include/libopencm3/efm32/tinygecko/cmu.yaml
@@ -153,6 +153,7 @@ registers:
offset: 0x010
definition_baserefext: ".5.5"
length: 7
+ type: uint
- name: AUXHFRCOCTRL
offset: 0x014
definition_baserefext: ".5.6"
@@ -200,6 +201,7 @@ registers:
offset: 0x01c
definition_baserefext: ".5.8"
length: 19
+ type: uint
- name: OSCENCMD
offset: 0x020
definition_baserefext: ".5.9"
diff --git a/include/libopencm3/efm32/tinygecko/generate.py b/include/libopencm3/efm32/tinygecko/generate.py
index 035b4d9..7f426a4 100644
--- a/include/libopencm3/efm32/tinygecko/generate.py
+++ b/include/libopencm3/efm32/tinygecko/generate.py
@@ -75,16 +75,19 @@ def yaml2h(filenamebase):
nl()
for regdata in regs:
- if 'is_template' in regdata:
+ has_bits = "fields" in regdata
+ has_values = "values" in regdata
+ is_template = "is_template" in regdata
+ if is_template:
# this isn't a real register, just a template
continue
secondcomponent_name = regdata['name']
- if ('fields' in regdata and isinstance(regdata['fields'], str)) or ('values' in regdata and isinstance(regdata['values'], str)):
+ if (has_bits and isinstance(regdata['fields'], str)) or (has_values and isinstance(regdata['values'], str)):
# uses a template
- secondcomponent_name = regdata['fields'] if 'fields' in regdata else regdata['values']
+ secondcomponent_name = regdata['fields'] if has_bits else regdata['values']
regs_dict[secondcomponent_name]['is_template'].append(regdata['name'])
- define("%s_%s"%(data['shortname'], regdata['name']), "MMIO32(%s_BASE + %#.003x)"%(data['shortname'], regdata['offset']), "@see %s_%s_%s"%(data['shortdocname'], secondcomponent_name, 'values' if 'values' in regdata else 'bits'))
+ define("%s_%s"%(data['shortname'], regdata['name']), "MMIO32(%s_BASE + %#.003x)"%(data['shortname'], regdata['offset']), "@see %s_%s_%s"%(data['shortdocname'], secondcomponent_name, 'values' if 'values' in regdata else 'bits') if has_bits or has_values else None)
nl()
wc_close() # close register definitions
nl()
@@ -104,15 +107,18 @@ def yaml2h(filenamebase):
if is_template:
commentlines.append("%s for the {shortname} \"{name}\" group of registers (%s)"%("Bit states" if has_bits else "Values", ", ".join(regdata['is_template'])))
assert len(regdata['is_template']) > 0, "What should I talk about when nobody uses this template?"
- commentlines.append("These registers use this:")
- commentlines.append("<ul>") # FIXME: once we're using markdown 1.8, this can be changed to markdown
- for user in regdata['is_template']:
- userdata = regs_dict[user]
- # FIXME: this is an ugly hack around this being in a single wc() line which doesn't take per-line contexts
- mergeddata = data.copy()
- mergeddata.update(userdata)
- commentlines.append(("<li>The {shortname}_{name} register; see {baseref}{definition_baserefext} for definitions"+regdata.get("details", "."+"</li>")).format(**mergeddata))
- commentlines.append("</ul>")
+ if 'override_backref' in regdata:
+ commentlines.append(regdata['override_backref'])
+ else:
+ commentlines.append("These registers use this:")
+ commentlines.append("<ul>") # FIXME: once we're using markdown 1.8, this can be changed to markdown
+ for user in regdata['is_template']:
+ userdata = regs_dict[user]
+ # FIXME: this is an ugly hack around this being in a single wc() line which doesn't take per-line contexts
+ mergeddata = data.copy()
+ mergeddata.update(userdata)
+ commentlines.append(("<li>The {shortname}_{name} register; see {baseref}{definition_baserefext} for definitions"+regdata.get("details", "."+"</li>")).format(**mergeddata))
+ commentlines.append("</ul>")
commentlines.append('@defgroup {shortdocname}_{name}_%s {shortname} {name} %s'%(('bits' if has_bits else 'values', 'bits group' if has_bits else 'values group')))
else:
commentlines.append("%s for the {shortname}_{name} register"%("Bit states" if has_bits else "Values"))
@@ -126,18 +132,26 @@ def yaml2h(filenamebase):
for field in regdata['fields']:
#shiftdefine = "_%s_%s_%s_shift"%(shortname, regdata['name'], field['name'])
#define(shiftdefine, field['shift'])
+
+ # there is one condition under which field's doc would get shown; show it immediately otherwise
+ if 'doc' in field and not ("values" not in field and field.get("length", 1) == 1):
+ wc(field['doc'])
+
if "values" in field:
for value in field.get("values"):
- define("%s_%s_%s_%s"%(data['shortname'], regdata['name'], field['name'], value['name']), "(%s<<%s)"%(value['value'], field['shift']), value.get('doc', None))
+ define("%s_%s_%s_%s"%(data['shortname'], regdata['name'], field['name'], value['name']), value['value'] if "mask" in field else "(%s<<%s)"%(value['value'], field['shift']), value.get('doc', None))
else:
if field.get('length', 1) == 1:
define("%s_%s_%s"%(data['shortname'], regdata['name'], field['name']), "(1<<%s)"%field['shift'], field.get('doc', None))
else:
# FIXME: this should require the 'type' parameter to be set on this field
- outfile.write("/* No values defined for the field %s */\n"%field['name'])
+ pass
if "values" in field or field.get("length", 1) != 1:
- mask = "(%#x<<%s)"%(~(~0<<field.get('length', 1)), field['shift'])
+ if "mask" in field:
+ mask = field['mask']
+ else:
+ mask = "(%#x<<%s)"%(~(~0<<field.get('length', 1)), field['shift'])
define("%s_%s_%s_MASK"%(data['shortname'], regdata['name'], field['name']), mask)
else:
for value in regdata['values']: