Fixup PICO_CONFIG entries (#208)
* remove default=undefined * fix a couple of typos / syntax "errors" * perform even better default-value-checking in extract_configs.py
This commit is contained in:
parent
6a8167b5bb
commit
967cbc5c3d
@ -56,15 +56,15 @@ extern "C" {
|
|||||||
#include "pico/stdio_semihosting.h"
|
#include "pico/stdio_semihosting.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// PICO_CONFIG: PICO_DEFAULT_LED_PIN, Optionally defined a pin that drives a regular LED on the board, default=undefined, group=pico_stdlib
|
// PICO_CONFIG: PICO_DEFAULT_LED_PIN, Optionally define a pin that drives a regular LED on the board, group=pico_stdlib
|
||||||
|
|
||||||
// PICO_CONFIG: PICO_DEFAULT_LED_PIN_INVERTED, 1 if LED is inverted, 0 otherwise, type=int, default=0, group=pico_stdlib
|
// PICO_CONFIG: PICO_DEFAULT_LED_PIN_INVERTED, 1 if LED is inverted or 0 if not, type=int, default=0, group=pico_stdlib
|
||||||
#ifndef PICO_DEFAULT_LED_PIN_INVERTED
|
#ifndef PICO_DEFAULT_LED_PIN_INVERTED
|
||||||
#define PICO_DEFAULT_LED_PIN_INVERTED 0
|
#define PICO_DEFAULT_LED_PIN_INVERTED 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// PICO_CONFIG: PICO_DEFAULT_WS2812_PIN, Optionally defined a pin that controls data to a WS2812 compatible LED on the board, default=undefined, group=pico_stdlib
|
// PICO_CONFIG: PICO_DEFAULT_WS2812_PIN, Optionally define a pin that controls data to a WS2812 compatible LED on the board, group=pico_stdlib
|
||||||
// PICO_CONFIG: PICO_DEFAULT_WS2812_POWER_PIN, Optionally defined a pin that controls power to a WS2812 compatible LED on the board, default=undefined, group=pico_stdlib
|
// PICO_CONFIG: PICO_DEFAULT_WS2812_POWER_PIN, Optionally define a pin that controls power to a WS2812 compatible LED on the board, group=pico_stdlib
|
||||||
|
|
||||||
/*! \brief Set up the default UART and assign it to the default GPIO's
|
/*! \brief Set up the default UART and assign it to the default GPIO's
|
||||||
* \ingroup pico_stdlib
|
* \ingroup pico_stdlib
|
||||||
|
@ -48,9 +48,9 @@ extern "C" {
|
|||||||
|
|
||||||
typedef struct i2c_inst i2c_inst_t;
|
typedef struct i2c_inst i2c_inst_t;
|
||||||
|
|
||||||
// PICO_CONFIG: PICO_DEFAULT_I2C, Define the default I2C for a board, default=undefined, group=hardware_i2c
|
// PICO_CONFIG: PICO_DEFAULT_I2C, Define the default I2C for a board, group=hardware_i2c
|
||||||
// PICO_CONFIG: PICO_DEFAULT_I2C_SDA_PIN, Define the default I2C SDA, min=0, max=29, default=undefined, group=hardware_i2c
|
// PICO_CONFIG: PICO_DEFAULT_I2C_SDA_PIN, Define the default I2C SDA pin, min=0, max=29, group=hardware_i2c
|
||||||
// PICO_CONFIG: PICO_DEFAULT_I2C_SCL_PIN, Define the default I2C SCL pin, min=0, max=29, default=undefined, group=hardware_i2c
|
// PICO_CONFIG: PICO_DEFAULT_I2C_SCL_PIN, Define the default I2C SCL pin, min=0, max=29, group=hardware_i2c
|
||||||
|
|
||||||
/** The I2C identifiers for use in I2C functions.
|
/** The I2C identifiers for use in I2C functions.
|
||||||
*
|
*
|
||||||
|
@ -35,11 +35,11 @@ extern "C" {
|
|||||||
* Each controller can be connected to a number of GPIO pins, see the datasheet GPIO function selection table for more information.
|
* Each controller can be connected to a number of GPIO pins, see the datasheet GPIO function selection table for more information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// PICO_CONFIG: PICO_DEFAULT_SPI, Define the default SPI for a board, default=undefined, group=hardware_spi
|
// PICO_CONFIG: PICO_DEFAULT_SPI, Define the default SPI for a board, group=hardware_spi
|
||||||
// PICO_CONFIG: PICO_DEFAULT_SPI_SCK_PIN, Define the default SPI SCK pin, min=0, max=29, default=undefined, group=hardware_spi
|
// PICO_CONFIG: PICO_DEFAULT_SPI_SCK_PIN, Define the default SPI SCK pin, min=0, max=29, group=hardware_spi
|
||||||
// PICO_CONFIG: PICO_DEFAULT_SPI_TX_PIN, Define the default SPI TX pin, min=0, max=29, default=undefined, group=hardware_spi
|
// PICO_CONFIG: PICO_DEFAULT_SPI_TX_PIN, Define the default SPI TX pin, min=0, max=29, group=hardware_spi
|
||||||
// PICO_CONFIG: PICO_DEFAULT_SPI_RX_PIN, Define the default SPI RX pin, min=0, max=29, default=undefined, group=hardware_spi
|
// PICO_CONFIG: PICO_DEFAULT_SPI_RX_PIN, Define the default SPI RX pin, min=0, max=29, group=hardware_spi
|
||||||
// PICO_CONFIG: PICO_DEFAULT_SPI_CSN_PIN, Define the default SPI CSN pin, min=0, max=29, default=undefined, group=hardware_spi
|
// PICO_CONFIG: PICO_DEFAULT_SPI_CSN_PIN, Define the default SPI CSN pin, min=0, max=29, group=hardware_spi
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opaque type representing an SPI instance.
|
* Opaque type representing an SPI instance.
|
||||||
|
@ -29,9 +29,9 @@ extern "C" {
|
|||||||
#define PICO_UART_DEFAULT_CRLF 0
|
#define PICO_UART_DEFAULT_CRLF 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// PICO_CONFIG: PICO_DEFAULT_UART, Define the default UART used for printf etc, default=undefined, group=hardware_uart
|
// PICO_CONFIG: PICO_DEFAULT_UART, Define the default UART used for printf etc, group=hardware_uart
|
||||||
// PICO_CONFIG: PICO_DEFAULT_UART_TX_PIN, Define the default UART TX pin, min=0, max=29, default=undefined, group=hardware_uart
|
// PICO_CONFIG: PICO_DEFAULT_UART_TX_PIN, Define the default UART TX pin, min=0, max=29, group=hardware_uart
|
||||||
// PICO_CONFIG: PICO_DEFAULT_UART_RX_PIN, Define the default UART RX pin, min=0, max=29, default=undefined, group=hardware_uart
|
// PICO_CONFIG: PICO_DEFAULT_UART_RX_PIN, Define the default UART RX pin, min=0, max=29, group=hardware_uart
|
||||||
|
|
||||||
// PICO_CONFIG: PICO_DEFAULT_UART_BAUD_RATE, Define the default UART baudrate, max=921600, default=115200, group=hardware_uart
|
// PICO_CONFIG: PICO_DEFAULT_UART_BAUD_RATE, Define the default UART baudrate, max=921600, default=115200, group=hardware_uart
|
||||||
#ifndef PICO_DEFAULT_UART_BAUD_RATE
|
#ifndef PICO_DEFAULT_UART_BAUD_RATE
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
#define PICO_STDIO_USB_ENABLE_RESET_VIA_BAUD_RATE 1
|
#define PICO_STDIO_USB_ENABLE_RESET_VIA_BAUD_RATE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// PICO_CONFIG: PICO_STDIO_USB_RESET_MAGIC_BAUD_RATE, baud rate that if selected causes a reset into BOOTSEL mode (if PICO_STDIO_USB_ENABLE_RESET_VIA_BAUD_RATE==1), default=1200, group=pico_stdio_usb
|
// PICO_CONFIG: PICO_STDIO_USB_RESET_MAGIC_BAUD_RATE, baud rate that if selected causes a reset into BOOTSEL mode (if PICO_STDIO_USB_ENABLE_RESET_VIA_BAUD_RATE is set), default=1200, group=pico_stdio_usb
|
||||||
#ifndef PICO_STDIO_USB_RESET_MAGIC_BAUD_RATE
|
#ifndef PICO_STDIO_USB_RESET_MAGIC_BAUD_RATE
|
||||||
#define PICO_STDIO_USB_RESET_MAGIC_BAUD_RATE 1200
|
#define PICO_STDIO_USB_RESET_MAGIC_BAUD_RATE 1200
|
||||||
#endif
|
#endif
|
||||||
|
@ -149,7 +149,7 @@ for dirpath, dirnames, filenames in os.walk(scandir):
|
|||||||
k, v = (i.strip() for i in item.split('='))
|
k, v = (i.strip() for i in item.split('='))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise Exception('{} at {}:{} has malformed value {}'.format(config_name, file_path, linenum, item))
|
raise Exception('{} at {}:{} has malformed value {}'.format(config_name, file_path, linenum, item))
|
||||||
config_attrs[k] = v.replace('\0', ',') if v != 'undefined' else None
|
config_attrs[k] = v.replace('\0', ',')
|
||||||
all_attrs.add(k)
|
all_attrs.add(k)
|
||||||
prev = item
|
prev = item
|
||||||
#print(file_path, config_name, config_attrs)
|
#print(file_path, config_name, config_attrs)
|
||||||
@ -178,9 +178,14 @@ for dirpath, dirnames, filenames in os.walk(scandir):
|
|||||||
all_defines[name][value] = (file_path, linenum)
|
all_defines[name][value] = (file_path, linenum)
|
||||||
|
|
||||||
# Check for defines with missing PICO_CONFIG entries
|
# Check for defines with missing PICO_CONFIG entries
|
||||||
|
resolved_defines = dict()
|
||||||
for d in all_defines:
|
for d in all_defines:
|
||||||
if d not in all_configs and d.startswith("PICO_"):
|
if d not in all_configs and d.startswith("PICO_"):
|
||||||
logger.warning("Potential unmarked PICO define {}".format(d))
|
logger.warning("Potential unmarked PICO define {}".format(d))
|
||||||
|
# resolve "nested defines" - this allows e.g. USB_DPRAM_MAX to resolve to USB_DPRAM_SIZE which is set to 4096 (which then matches the relevant PICO_CONFIG entry)
|
||||||
|
for val in all_defines[d]:
|
||||||
|
if val in all_defines:
|
||||||
|
resolved_defines[d] = all_defines[val]
|
||||||
|
|
||||||
for config_name in all_configs:
|
for config_name in all_configs:
|
||||||
|
|
||||||
@ -189,8 +194,8 @@ for config_name in all_configs:
|
|||||||
# Check that default values match up
|
# Check that default values match up
|
||||||
if 'default' in all_configs[config_name]['attrs']:
|
if 'default' in all_configs[config_name]['attrs']:
|
||||||
if config_name in all_defines:
|
if config_name in all_defines:
|
||||||
if all_configs[config_name]['attrs']['default'] not in all_defines[config_name] and (all_configs[config_name]['attrs'].get('type', 'int') != 'bool'):
|
if all_configs[config_name]['attrs']['default'] not in all_defines[config_name] and (config_name not in resolved_defines or all_configs[config_name]['attrs']['default'] not in resolved_defines[config_name]):
|
||||||
if config_name in ['USB_DPRAM_MAX'] or '/' in all_configs[config_name]['attrs']['default']:
|
if '/' in all_configs[config_name]['attrs']['default'] or ' ' in all_configs[config_name]['attrs']['default']:
|
||||||
continue
|
continue
|
||||||
# There _may_ be multiple matching defines, but arbitrarily display just one in the error message
|
# There _may_ be multiple matching defines, but arbitrarily display just one in the error message
|
||||||
first_define_value = list(all_defines[config_name].keys())[0]
|
first_define_value = list(all_defines[config_name].keys())[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user