mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-22 01:12:31 +00:00
module docs: add PRINT_MODULE_USAGE_PARAMS_I2C_{SPI_DRIVER,ADDRESS}
For SPI/I2C driver default options
This commit is contained in:
@@ -33,9 +33,12 @@ class ModuleDocumentation(object):
|
||||
self._scope = scope
|
||||
|
||||
self._options = '' # all option chars
|
||||
self._explicit_options = '' # all option chars (explicit in the module)
|
||||
self._all_values = [] # list of all values
|
||||
self._all_commands = []
|
||||
|
||||
self._paring_implicit_options = False
|
||||
|
||||
for func_name, args in function_calls:
|
||||
attribute_name = '_handle_'+func_name.lower()
|
||||
try:
|
||||
@@ -99,7 +102,7 @@ class ModuleDocumentation(object):
|
||||
def _handle_usage_param_int(self, args):
|
||||
assert(len(args) == 6) # option_char, default_val, min_val, max_val, description, is_optional
|
||||
option_char = self._get_option_char(args[0])
|
||||
default_val = int(args[1])
|
||||
default_val = int(args[1], 0)
|
||||
description = self._get_string(args[4])
|
||||
if self._is_bool_true(args[5]):
|
||||
self._usage_string += " [-%s <val>] %s\n" % (option_char, description)
|
||||
@@ -120,6 +123,33 @@ class ModuleDocumentation(object):
|
||||
else:
|
||||
self._usage_string += " -%s <val> %s\n" % (option_char, description)
|
||||
|
||||
def _handle_usage_params_i2c_spi_driver(self, args):
|
||||
assert(len(args) == 2) # i2c_support, spi_support
|
||||
self._paring_implicit_options = True
|
||||
if self._is_bool_true(args[0]):
|
||||
self._handle_usage_param_flag(['\'I\'', "\"Internal I2C bus(es)\"", 'true'])
|
||||
self._handle_usage_param_flag(['\'X\'', "\"External I2C bus(es\")", 'true'])
|
||||
if self._is_bool_true(args[1]):
|
||||
self._handle_usage_param_flag(['\'s\'', "\"Internal SPI bus(es)\"", 'true'])
|
||||
self._handle_usage_param_flag(['\'S\'', "\"External SPI bus(es)\"", 'true'])
|
||||
|
||||
self._handle_usage_param_int(['\'b\'', '-1', '0', '16',
|
||||
"\"bus (board-specific internal (default=all) or n-th external (default=1))\"", 'true'])
|
||||
|
||||
if self._is_bool_true(args[1]):
|
||||
self._handle_usage_param_int(['\'c\'', '1', '1', '10',
|
||||
"\"chip-select index (for external SPI)\"", 'true'])
|
||||
self._handle_usage_param_int(['\'m\'', '-1', '0', '3', "\"SPI mode\"", 'true'])
|
||||
|
||||
self._handle_usage_param_int(['\'f\'', '-1', '0', '1000000', "\"bus frequency in kHz\"", 'true'])
|
||||
self._paring_implicit_options = False
|
||||
|
||||
def _handle_usage_params_i2c_address(self, args):
|
||||
assert(len(args) == 1) # i2c_address
|
||||
self._paring_implicit_options = True
|
||||
self._handle_usage_param_int(['\'a\'', args[0], '0', '0xff', "\"I2C address\"", 'true'])
|
||||
self._paring_implicit_options = False
|
||||
|
||||
def _handle_usage_param_flag(self, args):
|
||||
assert(len(args) == 3) # option_char, description, is_optional
|
||||
option_char = self._get_option_char(args[0])
|
||||
@@ -187,6 +217,8 @@ class ModuleDocumentation(object):
|
||||
assert(len(argument) == 3) # must have the form: 'p' (assume there's no escaping)
|
||||
option_char = argument[1]
|
||||
self._options += option_char
|
||||
if not self._paring_implicit_options:
|
||||
self._explicit_options += option_char
|
||||
return option_char
|
||||
|
||||
|
||||
@@ -234,9 +266,10 @@ class ModuleDocumentation(object):
|
||||
|
||||
def options(self):
|
||||
"""
|
||||
get all the -p options as string of chars
|
||||
get all the -p options as string of chars, that are explicitly set in
|
||||
the module
|
||||
"""
|
||||
return self._options
|
||||
return self._explicit_options
|
||||
|
||||
def all_values(self):
|
||||
"""
|
||||
@@ -257,7 +290,7 @@ class SourceParser(object):
|
||||
"""
|
||||
|
||||
# Regex to extract module doc function calls, starting with PRINT_MODULE_
|
||||
re_doc_definition = re.compile(r'PRINT_MODULE_([A-Z_]*)\s*\(')
|
||||
re_doc_definition = re.compile(r'PRINT_MODULE_([A-Z0-9_]*)\s*\(')
|
||||
|
||||
def __init__(self):
|
||||
self._modules = {} # all found modules: key is the module name
|
||||
|
||||
Reference in New Issue
Block a user