Skip to content

Commit b122c42

Browse files
authored
More CYW43 config tweaks (#2033)
- Re-synchronise the PICO_CMAKE_CONFIG: entries with the corresponding PICO_CONFIG: entries - Fix a silly typo I made in #2002 - Enhance config-extraction scripts to catch similar typos in future
1 parent 363302f commit b122c42

File tree

5 files changed

+37
-15
lines changed

5 files changed

+37
-15
lines changed

src/rp2_common/pico_cyw43_driver/CMakeLists.txt

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,28 +56,32 @@ if (EXISTS ${PICO_CYW43_DRIVER_PATH}/${CYW43_DRIVER_TEST_FILE})
5656
hardware_exception
5757
)
5858

59+
if (CYW43_PIN_WL_DYNAMIC)
60+
# PICO_CMAKE_CONFIG: CYW43_PIN_WL_DYNAMIC, flag to indicate if cyw43 SPI pins can be changed at runtime, type=bool, group=pico_cyw43_driver
61+
target_compile_definitions(cyw43_driver_picow INTERFACE CYW43_PIN_WL_DYNAMIC=${CYW43_PIN_WL_DYNAMIC})
62+
endif()
5963
if (CYW43_DEFAULT_PIN_WL_REG_ON)
60-
# PICO_CMAKE_CONFIG: CYW43_DEFAULT_PIN_WL_REG_ON, gpio pin to power up the cyw43 chip, type=int, default=23, group=pico_cyw43_driver
64+
# PICO_CMAKE_CONFIG: CYW43_DEFAULT_PIN_WL_REG_ON, gpio pin to power up the cyw43 chip, type=int, group=pico_cyw43_driver
6165
target_compile_definitions(cyw43_driver_picow INTERFACE CYW43_DEFAULT_PIN_WL_REG_ON=${CYW43_DEFAULT_PIN_WL_REG_ON})
6266
endif()
6367
if (CYW43_DEFAULT_PIN_WL_DATA_OUT)
64-
# PICO_CMAKE_CONFIG: CYW43_DEFAULT_PIN_WL_DATA_OUT, gpio pin for spi data out to the cyw43 chip, type=int, default=24, group=pico_cyw43_driver
68+
# PICO_CMAKE_CONFIG: CYW43_DEFAULT_PIN_WL_DATA_OUT, gpio pin for spi data out to the cyw43 chip, type=int, group=pico_cyw43_driver
6569
target_compile_definitions(cyw43_driver_picow INTERFACE CYW43_DEFAULT_PIN_WL_DATA_OUT=${CYW43_DEFAULT_PIN_WL_DATA_OUT})
6670
endif()
6771
if (CYW43_DEFAULT_PIN_WL_DATA_IN)
68-
# PICO_CMAKE_CONFIG: CYW43_DEFAULT_PIN_WL_DATA_IN, gpio pin for spi data in from the cyw43 chip, type=int, default=24, group=pico_cyw43_driver
72+
# PICO_CMAKE_CONFIG: CYW43_DEFAULT_PIN_WL_DATA_IN, gpio pin for spi data in from the cyw43 chip, type=int, group=pico_cyw43_driver
6973
target_compile_definitions(cyw43_driver_picow INTERFACE CYW43_DEFAULT_PIN_WL_DATA_IN=${CYW43_DEFAULT_PIN_WL_DATA_IN})
7074
endif()
7175
if (CYW43_DEFAULT_PIN_WL_HOST_WAKE)
72-
# PICO_CMAKE_CONFIG: CYW43_DEFAULT_PIN_WL_HOST_WAKE, gpio (irq) pin for the irq line from the cyw43 chip, type=int, default=24, group=pico_cyw43_driver
76+
# PICO_CMAKE_CONFIG: CYW43_DEFAULT_PIN_WL_HOST_WAKE, gpio (irq) pin for the irq line from the cyw43 chip, type=int, group=pico_cyw43_driver
7377
target_compile_definitions(cyw43_driver_picow INTERFACE CYW43_DEFAULT_PIN_WL_HOST_WAKE=${CYW43_DEFAULT_PIN_WL_HOST_WAKE})
7478
endif()
7579
if (CYW43_DEFAULT_PIN_WL_CLOCK)
76-
# PICO_CMAKE_CONFIG: CYW43_DEFAULT_PIN_WL_HOST_WAKE, gpio pin for the spi clock line to the cyw43 chip, type=int, default=29, group=pico_cyw43_driver
80+
# PICO_CMAKE_CONFIG: CYW43_DEFAULT_PIN_WL_CLOCK, gpio pin for the spi clock line to the cyw43 chip, type=int, group=pico_cyw43_driver
7781
target_compile_definitions(cyw43_driver_picow INTERFACE CYW43_DEFAULT_PIN_WL_CLOCK=${CYW43_DEFAULT_PIN_WL_CLOCK})
7882
endif()
7983
if (CYW43_DEFAULT_PIN_WL_CS)
80-
# PICO_CMAKE_CONFIG: CYW43_DEFAULT_PIN_WL_CS, gpio pin for the spi chip select to the cyw43 chip, type=int, default=25, group=pico_cyw43_driver
84+
# PICO_CMAKE_CONFIG: CYW43_DEFAULT_PIN_WL_CS, gpio pin for the spi chip select to the cyw43 chip, type=int, group=pico_cyw43_driver
8185
target_compile_definitions(cyw43_driver_picow INTERFACE CYW43_DEFAULT_PIN_WL_CS=${CYW43_DEFAULT_PIN_WL_CS})
8286
endif()
8387
if (CYW43_PIO_CLOCK_DIV_INT)
@@ -89,7 +93,7 @@ if (EXISTS ${PICO_CYW43_DRIVER_PATH}/${CYW43_DRIVER_TEST_FILE})
8993
target_compile_definitions(cyw43_driver_picow INTERFACE CYW43_PIO_CLOCK_DIV_FRAC8=${CYW43_PIO_CLOCK_DIV_FRAC8})
9094
endif()
9195
if (CYW43_PIO_CLOCK_DIV_DYNAMIC)
92-
# PICO_CMAKE_CONFIG: CYW43_PIO_CLOCK_DIV_DYNAMIC, flag used to enable dynamic pio clock divider API, type=bool, default=false, group=pico_cyw43_driver
96+
# PICO_CMAKE_CONFIG: CYW43_PIO_CLOCK_DIV_DYNAMIC, flag used to enable dynamic pio clock divider API, type=bool, default=0, group=pico_cyw43_driver
9397
target_compile_definitions(cyw43_driver_picow INTERFACE CYW43_PIO_CLOCK_DIV_DYNAMIC=${CYW43_PIO_CLOCK_DIV_DYNAMIC})
9498
endif()
9599

src/rp2_common/pico_cyw43_driver/include/pico/cyw43_driver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void cyw43_driver_deinit(struct async_context *context);
7979

8080
// PICO_CONFIG: CYW43_DEFAULT_PIN_WL_CLOCK, gpio pin for the spi clock line to the cyw43 chip, type=int, advanced=true, group=pico_cyw43_driver
8181

82-
// PICO_CONFIG: CYW43_DEFAULT_PIN_WL_CS, gpio pin for the spi chip select to the cyw43 chip, type=int, dvanced=true, group=pico_cyw43_driver
82+
// PICO_CONFIG: CYW43_DEFAULT_PIN_WL_CS, gpio pin for the spi chip select to the cyw43 chip, type=int, advanced=true, group=pico_cyw43_driver
8383

8484
#if CYW43_PIO_CLOCK_DIV_DYNAMIC
8585
/*! \brief Set the clock divisor for the cyw43 pio clock

tools/extract_build_defines.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939

4040
BUILD_DEFINE_RE = re.compile(r'#\s+{}:\s+(\w+),\s+([^,]+)(?:,\s+(.*))?$'.format(BASE_BUILD_DEFINE_NAME))
4141

42+
ALLOWED_CONFIG_PROPERTIES = set(['type', 'default', 'min', 'max', 'group'])
43+
4244
CHIP_NAMES = ["rp2040", "rp2350"]
4345

4446
chips_all_configs = defaultdict(dict)
@@ -47,10 +49,14 @@
4749

4850

4951

50-
def ValidateAttrs(config_attrs, file_path, linenum):
52+
def ValidateAttrs(config_name, config_attrs, file_path, linenum):
5153
_type = config_attrs.get('type')
5254

5355
# Validate attrs
56+
for key in config_attrs.keys():
57+
if key not in ALLOWED_CONFIG_PROPERTIES:
58+
raise Exception('{} at {}:{} has unexpected property "{}"'.format(config_name, file_path, linenum, key))
59+
5460
if _type == 'int':
5561
_min = _max = _default = None
5662
if config_attrs.get('min', None) is not None:
@@ -184,7 +190,7 @@ def ValidateAttrs(config_attrs, file_path, linenum):
184190
file_path = os.path.join(scandir, config_obj['filename'])
185191
linenum = config_obj['line_number']
186192

187-
ValidateAttrs(config_obj['attrs'], file_path, linenum)
193+
ValidateAttrs(config_name, config_obj['attrs'], file_path, linenum)
188194

189195
# All settings in "host" should also be in "all"
190196
for config_name, config_obj in chips_all_configs["host"].items():

tools/extract_cmake_configs.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939

4040
CMAKE_CONFIG_RE = re.compile(r'#\s+{}:\s+(\w+),\s+([^,]+)(?:,\s+(.*))?$'.format(BASE_CMAKE_CONFIG_NAME))
4141

42+
ALLOWED_CONFIG_PROPERTIES = set(['type', 'default', 'min', 'max', 'group', 'advanced', 'docref'])
43+
4244
CHIP_NAMES = ["rp2040", "rp2350"]
4345

4446
chips_all_configs = defaultdict(dict)
@@ -47,10 +49,14 @@
4749

4850

4951

50-
def ValidateAttrs(config_attrs, file_path, linenum):
52+
def ValidateAttrs(config_name, config_attrs, file_path, linenum):
5153
_type = config_attrs.get('type')
5254

5355
# Validate attrs
56+
for key in config_attrs.keys():
57+
if key not in ALLOWED_CONFIG_PROPERTIES:
58+
raise Exception('{} at {}:{} has unexpected property "{}"'.format(config_name, file_path, linenum, key))
59+
5460
if _type == 'int':
5561
_min = _max = _default = None
5662
if config_attrs.get('min', None) is not None:
@@ -93,7 +99,7 @@ def ValidateAttrs(config_attrs, file_path, linenum):
9399
_default = config_attrs.get('default', None)
94100
if _default is not None:
95101
if '/' not in _default:
96-
if (_default.lower() != '0') and (config_attrs['default'].lower() != '1') and ( _default not in all_configs):
102+
if (_default.lower() != '0') and (config_attrs['default'].lower() != '1') and (_default not in all_configs):
97103
logger.info('{} at {}:{} has non-integer default value "{}"'.format(config_name, file_path, linenum, config_attrs['default']))
98104

99105
elif _type == 'string':
@@ -184,7 +190,7 @@ def ValidateAttrs(config_attrs, file_path, linenum):
184190
file_path = os.path.join(scandir, config_obj['filename'])
185191
linenum = config_obj['line_number']
186192

187-
ValidateAttrs(config_obj['attrs'], file_path, linenum)
193+
ValidateAttrs(config_name, config_obj['attrs'], file_path, linenum)
188194

189195
# All settings in "host" should also be in "all"
190196
for config_name, config_obj in chips_all_configs["host"].items():

tools/extract_configs.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
CONFIG_RE = re.compile(r'//\s+{}:\s+(\w+),\s+([^,]+)(?:,\s+(.*))?$'.format(BASE_CONFIG_NAME))
4141
DEFINE_RE = re.compile(r'#define\s+(\w+)\s+(.+?)(\s*///.*)?$')
4242

43+
ALLOWED_CONFIG_PROPERTIES = set(['type', 'default', 'min', 'max', 'enumvalues', 'group', 'advanced', 'depends'])
44+
4345
CHIP_NAMES = ["rp2040", "rp2350"]
4446

4547
chips_all_configs = defaultdict(dict)
@@ -49,10 +51,14 @@
4951

5052

5153

52-
def ValidateAttrs(config_attrs, file_path, linenum):
54+
def ValidateAttrs(config_name, config_attrs, file_path, linenum):
5355
_type = config_attrs.get('type', 'int')
5456

5557
# Validate attrs
58+
for key in config_attrs.keys():
59+
if key not in ALLOWED_CONFIG_PROPERTIES:
60+
raise Exception('{} at {}:{} has unexpected property "{}"'.format(config_name, file_path, linenum, key))
61+
5662
if _type == 'int':
5763
assert 'enumvalues' not in config_attrs
5864
_min = _max = _default = None
@@ -229,7 +235,7 @@ def ValidateAttrs(config_attrs, file_path, linenum):
229235
file_path = os.path.join(scandir, config_obj['filename'])
230236
linenum = config_obj['line_number']
231237

232-
ValidateAttrs(config_obj['attrs'], file_path, linenum)
238+
ValidateAttrs(config_name, config_obj['attrs'], file_path, linenum)
233239

234240
# Check that default values match up
235241
if 'default' in config_obj['attrs']:

0 commit comments

Comments
 (0)