1.新增Kconfig。
This commit is contained in:
119
Kconfig
Normal file
119
Kconfig
Normal file
@@ -0,0 +1,119 @@
|
||||
mainmenu "mr-library"
|
||||
|
||||
menu "Device configure"
|
||||
|
||||
config MR_CFG_HEAP_SIZE
|
||||
int "The heap size (Bytes)"
|
||||
default 1024
|
||||
range 8 2147483647
|
||||
help
|
||||
Size of dynamic memory for system.
|
||||
|
||||
config MR_USING_ASSERT
|
||||
bool "Enable assert"
|
||||
default y
|
||||
|
||||
config MR_CFG_NAME_MAX
|
||||
int "The maximum length of device name"
|
||||
default 8
|
||||
range 4 1024
|
||||
help
|
||||
Maximum length of name
|
||||
|
||||
config MR_CFG_DESC_MAX
|
||||
int "The maximum number of descriptors"
|
||||
default 32
|
||||
range 16 1024
|
||||
help
|
||||
Maximum number of descriptors
|
||||
|
||||
config MR_USING_RDWR_CTL
|
||||
bool "Enable read/write control"
|
||||
default y
|
||||
|
||||
config MR_USING_ADC
|
||||
bool "Enable ADC device"
|
||||
default n
|
||||
|
||||
config MR_USING_CAN
|
||||
bool "Enable CAN device"
|
||||
default n
|
||||
|
||||
menu "CAN configure"
|
||||
depends on MR_USING_CAN
|
||||
|
||||
config MR_CFG_CAN_RD_BUFSZ
|
||||
int "The RX buffer size"
|
||||
default 32
|
||||
range 0 MR_CFG_HEAP_SIZE
|
||||
help
|
||||
Size of SPI Rx buffer
|
||||
endmenu
|
||||
|
||||
config MR_USING_DAC
|
||||
bool "Enable DAC device"
|
||||
default n
|
||||
|
||||
config MR_USING_I2C
|
||||
bool "Enable I2C device"
|
||||
default n
|
||||
|
||||
menu "I2C configure"
|
||||
depends on MR_USING_I2C
|
||||
|
||||
config MR_CFG_I2C_RD_BUFSZ
|
||||
int "The RX buffer size"
|
||||
default 32
|
||||
range 0 MR_CFG_HEAP_SIZE
|
||||
help
|
||||
Size of SPI RX buffer
|
||||
endmenu
|
||||
|
||||
config MR_USING_PIN
|
||||
bool "Enable Pin device"
|
||||
default n
|
||||
|
||||
config MR_USING_SERIAL
|
||||
bool "Enable Serial device"
|
||||
default n
|
||||
|
||||
menu "Serial configure"
|
||||
depends on MR_USING_SERIAL
|
||||
|
||||
config MR_CFG_SERIAL_RD_BUFSZ
|
||||
int "The RX buffer size"
|
||||
default 32
|
||||
range 0 MR_CFG_HEAP_SIZE
|
||||
help
|
||||
Size of Serial RX buffer
|
||||
|
||||
config MR_CFG_SERIAL_WR_BUFSZ
|
||||
int "The TX buffer size for Serial"
|
||||
default 0
|
||||
range 0 MR_CFG_HEAP_SIZE
|
||||
help
|
||||
Size of Serial TX buffer
|
||||
|
||||
config MR_CFG_CONSOLE_NAME
|
||||
string "The console device name"
|
||||
default "serial1"
|
||||
endmenu
|
||||
|
||||
config MR_USING_SPI
|
||||
bool "Enable SPI Device"
|
||||
default n
|
||||
|
||||
menu "SPI configure"
|
||||
depends on MR_USING_SPI
|
||||
|
||||
config MR_CFG_SPI_RD_BUFSZ
|
||||
int "RX buffer size"
|
||||
default 32
|
||||
range 0 MR_CFG_HEAP_SIZE
|
||||
help
|
||||
Size of SPI RX buffer
|
||||
endmenu
|
||||
|
||||
endmenu
|
||||
|
||||
source "driver/Kconfig"
|
||||
203
bsp/wch/ch32v20x/driver/Kconfig
Normal file
203
bsp/wch/ch32v20x/driver/Kconfig
Normal file
@@ -0,0 +1,203 @@
|
||||
menu "Board configure"
|
||||
|
||||
menu "ADC"
|
||||
|
||||
config MR_USING_ADC1
|
||||
bool "Enable ADC1 driver"
|
||||
default n
|
||||
|
||||
config MR_USING_ADC2
|
||||
bool "Enable ADC2 driver"
|
||||
default n
|
||||
|
||||
endmenu
|
||||
|
||||
menu "I2C"
|
||||
|
||||
config MR_USING_I2C1
|
||||
bool "Enable I2C1 driver"
|
||||
default n
|
||||
|
||||
menu "I2C1 driver configure"
|
||||
depends on MR_USING_I2C1
|
||||
|
||||
config MR_CFG_I2C1_GROUP
|
||||
int "I2C1 Group"
|
||||
default 1
|
||||
range 1 2
|
||||
endmenu
|
||||
|
||||
config MR_USING_I2C2
|
||||
bool "Enable I2C2 driver"
|
||||
default n
|
||||
|
||||
menu "I2C2 driver configure"
|
||||
depends on MR_USING_I2C2
|
||||
|
||||
config MR_CFG_I2C2_GROUP
|
||||
int "I2C2 Group"
|
||||
default 1
|
||||
range 1 1
|
||||
endmenu
|
||||
|
||||
endmenu
|
||||
|
||||
menu "GPIO"
|
||||
|
||||
config MR_USING_GPIOA
|
||||
bool "Enable GPIOA driver"
|
||||
default n
|
||||
|
||||
config MR_USING_GPIOB
|
||||
bool "Enable GPIOB driver"
|
||||
default n
|
||||
|
||||
config MR_USING_GPIOC
|
||||
bool "Enable GPIOC driver"
|
||||
default n
|
||||
|
||||
config MR_USING_GPIOD
|
||||
bool "Enable GPIOD driver"
|
||||
default n
|
||||
|
||||
endmenu
|
||||
|
||||
menu "UART"
|
||||
|
||||
config MR_USING_UART1
|
||||
bool "Enable UART1 driver"
|
||||
default n
|
||||
|
||||
menu "UART1 driver configure"
|
||||
depends on MR_USING_UART1
|
||||
|
||||
config MR_CFG_UART1_GROUP
|
||||
int "UART1 Group"
|
||||
default 1
|
||||
range 1 4
|
||||
endmenu
|
||||
|
||||
config MR_USING_UART2
|
||||
bool "Enable UART2 driver"
|
||||
default n
|
||||
|
||||
menu "UART2 driver configure"
|
||||
depends on MR_USING_UART2
|
||||
|
||||
config MR_CFG_UART2_GROUP
|
||||
int "UART2 Group"
|
||||
default 1
|
||||
range 1 2
|
||||
endmenu
|
||||
|
||||
config MR_USING_UART3
|
||||
bool "Enable UART3 driver"
|
||||
default n
|
||||
|
||||
menu "UART3 driver configure"
|
||||
depends on MR_USING_UART3
|
||||
|
||||
config MR_CFG_UART3_GROUP
|
||||
int "UART3 Group"
|
||||
default 1
|
||||
range 1 4
|
||||
endmenu
|
||||
|
||||
config MR_USING_UART4
|
||||
bool "Enable UART4 driver"
|
||||
default n
|
||||
|
||||
menu "UART4 driver configure"
|
||||
depends on MR_USING_UART4
|
||||
|
||||
config MR_CFG_UART4_GROUP
|
||||
int "UART4 Group"
|
||||
default 1
|
||||
range 1 3
|
||||
endmenu
|
||||
|
||||
config MR_USING_UART5
|
||||
bool "Enable UART5 driver"
|
||||
default n
|
||||
|
||||
menu "UART5 driver configure"
|
||||
depends on MR_USING_UART5
|
||||
|
||||
config MR_CFG_UART5_GROUP
|
||||
int "UART5 Group"
|
||||
default 1
|
||||
range 1 3
|
||||
endmenu
|
||||
|
||||
config MR_USING_UART6
|
||||
bool "Enable UART6 driver"
|
||||
default n
|
||||
|
||||
menu "UART6 driver configure"
|
||||
depends on MR_USING_UART6
|
||||
|
||||
config MR_CFG_UART6_GROUP
|
||||
int "UART6 Group"
|
||||
default 1
|
||||
range 1 3
|
||||
endmenu
|
||||
|
||||
config MR_USING_UART7
|
||||
bool "Enable UART7 driver"
|
||||
default n
|
||||
|
||||
menu "UART7 driver configure"
|
||||
depends on MR_USING_UART7
|
||||
|
||||
config MR_CFG_UART7_GROUP
|
||||
int "UART7 Group"
|
||||
default 1
|
||||
range 1 3
|
||||
endmenu
|
||||
|
||||
config MR_USING_UART8
|
||||
bool "Enable UART8 driver"
|
||||
default n
|
||||
|
||||
menu "UART8 driver configure"
|
||||
depends on MR_USING_UART8
|
||||
|
||||
config MR_CFG_UART8_GROUP
|
||||
int "UART8 Group"
|
||||
default 1
|
||||
range 1 3
|
||||
endmenu
|
||||
|
||||
endmenu
|
||||
|
||||
menu "SPI"
|
||||
|
||||
config MR_USING_SPI1
|
||||
bool "Enable SPI1 driver"
|
||||
default n
|
||||
|
||||
menu "SPI1 driver configure"
|
||||
depends on MR_USING_SPI1
|
||||
|
||||
config MR_CFG_SPI1_GROUP
|
||||
int "SPI1 Group"
|
||||
default 1
|
||||
range 1 2
|
||||
endmenu
|
||||
|
||||
config MR_USING_SPI2
|
||||
bool "Enable SPI2 driver"
|
||||
default n
|
||||
|
||||
menu "SPI2 driver configure"
|
||||
depends on MR_USING_SPI2
|
||||
|
||||
config MR_CFG_SPI2_GROUP
|
||||
int "SPI2 Group"
|
||||
default 1
|
||||
range 1 1
|
||||
endmenu
|
||||
|
||||
endmenu
|
||||
|
||||
endmenu
|
||||
228
bsp/wch/ch32v30x/driver/Kconfig
Normal file
228
bsp/wch/ch32v30x/driver/Kconfig
Normal file
@@ -0,0 +1,228 @@
|
||||
menu "Board configure"
|
||||
|
||||
menu "ADC"
|
||||
|
||||
config MR_USING_ADC1
|
||||
bool "Enable ADC1 driver"
|
||||
default n
|
||||
|
||||
config MR_USING_ADC2
|
||||
bool "Enable ADC2 driver"
|
||||
default n
|
||||
|
||||
endmenu
|
||||
|
||||
menu "DAC"
|
||||
|
||||
config MR_USING_DAC1
|
||||
bool "Enable DAC1 driver"
|
||||
default n
|
||||
|
||||
endmenu
|
||||
|
||||
menu "I2C"
|
||||
|
||||
config MR_USING_I2C1
|
||||
bool "Enable I2C1 driver"
|
||||
default n
|
||||
|
||||
menu "I2C1 driver configure"
|
||||
depends on MR_USING_I2C1
|
||||
|
||||
config MR_CFG_I2C1_GROUP
|
||||
int "I2C1 Group"
|
||||
default 1
|
||||
range 1 2
|
||||
endmenu
|
||||
|
||||
config MR_USING_I2C2
|
||||
bool "Enable I2C2 driver"
|
||||
default n
|
||||
|
||||
menu "I2C2 driver configure"
|
||||
depends on MR_USING_I2C2
|
||||
|
||||
config MR_CFG_I2C2_GROUP
|
||||
int "I2C2 Group"
|
||||
default 1
|
||||
range 1 1
|
||||
endmenu
|
||||
|
||||
endmenu
|
||||
|
||||
menu "GPIO"
|
||||
|
||||
config MR_USING_GPIOA
|
||||
bool "Enable GPIOA driver"
|
||||
default n
|
||||
|
||||
config MR_USING_GPIOB
|
||||
bool "Enable GPIOB driver"
|
||||
default n
|
||||
|
||||
config MR_USING_GPIOC
|
||||
bool "Enable GPIOC driver"
|
||||
default n
|
||||
|
||||
config MR_USING_GPIOD
|
||||
bool "Enable GPIOD driver"
|
||||
default n
|
||||
|
||||
config MR_USING_GPIOE
|
||||
bool "Enable GPIOE driver"
|
||||
default n
|
||||
|
||||
endmenu
|
||||
|
||||
menu "UART"
|
||||
|
||||
config MR_USING_UART1
|
||||
bool "Enable UART1 driver"
|
||||
default n
|
||||
|
||||
menu "UART1 driver configure"
|
||||
depends on MR_USING_UART1
|
||||
|
||||
config MR_CFG_UART1_GROUP
|
||||
int "UART1 Group"
|
||||
default 1
|
||||
range 1 4
|
||||
endmenu
|
||||
|
||||
config MR_USING_UART2
|
||||
bool "Enable UART2 driver"
|
||||
default n
|
||||
|
||||
menu "UART2 driver configure"
|
||||
depends on MR_USING_UART2
|
||||
|
||||
config MR_CFG_UART2_GROUP
|
||||
int "UART2 Group"
|
||||
default 1
|
||||
range 1 2
|
||||
endmenu
|
||||
|
||||
config MR_USING_UART3
|
||||
bool "Enable UART3 driver"
|
||||
default n
|
||||
|
||||
menu "UART3 driver configure"
|
||||
depends on MR_USING_UART3
|
||||
|
||||
config MR_CFG_UART3_GROUP
|
||||
int "UART3 Group"
|
||||
default 1
|
||||
range 1 4
|
||||
endmenu
|
||||
|
||||
config MR_USING_UART4
|
||||
bool "Enable UART4 driver"
|
||||
default n
|
||||
|
||||
menu "UART4 driver configure"
|
||||
depends on MR_USING_UART4
|
||||
|
||||
config MR_CFG_UART4_GROUP
|
||||
int "UART4 Group"
|
||||
default 1
|
||||
range 1 3
|
||||
endmenu
|
||||
|
||||
config MR_USING_UART5
|
||||
bool "Enable UART5 driver"
|
||||
default n
|
||||
|
||||
menu "UART5 driver configure"
|
||||
depends on MR_USING_UART5
|
||||
|
||||
config MR_CFG_UART5_GROUP
|
||||
int "UART5 Group"
|
||||
default 1
|
||||
range 1 3
|
||||
endmenu
|
||||
|
||||
config MR_USING_UART6
|
||||
bool "Enable UART6 driver"
|
||||
default n
|
||||
|
||||
menu "UART6 driver configure"
|
||||
depends on MR_USING_UART6
|
||||
|
||||
config MR_CFG_UART6_GROUP
|
||||
int "UART6 Group"
|
||||
default 1
|
||||
range 1 3
|
||||
endmenu
|
||||
|
||||
config MR_USING_UART7
|
||||
bool "Enable UART7 driver"
|
||||
default n
|
||||
|
||||
menu "UART7 driver configure"
|
||||
depends on MR_USING_UART7
|
||||
|
||||
config MR_CFG_UART7_GROUP
|
||||
int "UART7 Group"
|
||||
default 1
|
||||
range 1 3
|
||||
endmenu
|
||||
|
||||
config MR_USING_UART8
|
||||
bool "Enable UART8 driver"
|
||||
default n
|
||||
|
||||
menu "UART8 driver configure"
|
||||
depends on MR_USING_UART8
|
||||
|
||||
config MR_CFG_UART8_GROUP
|
||||
int "UART8 Group"
|
||||
default 1
|
||||
range 1 3
|
||||
endmenu
|
||||
|
||||
endmenu
|
||||
|
||||
menu "SPI"
|
||||
|
||||
config MR_USING_SPI1
|
||||
bool "Enable SPI1 driver"
|
||||
default n
|
||||
|
||||
menu "SPI1 driver configure"
|
||||
depends on MR_USING_SPI1
|
||||
|
||||
config MR_CFG_SPI1_GROUP
|
||||
int "SPI1 Group"
|
||||
default 1
|
||||
range 1 2
|
||||
endmenu
|
||||
|
||||
config MR_USING_SPI2
|
||||
bool "Enable SPI2 driver"
|
||||
default n
|
||||
|
||||
menu "SPI2 driver configure"
|
||||
depends on MR_USING_SPI2
|
||||
|
||||
config MR_CFG_SPI2_GROUP
|
||||
int "SPI2 Group"
|
||||
default 1
|
||||
range 1 1
|
||||
endmenu
|
||||
|
||||
config MR_USING_SPI3
|
||||
bool "Enable SPI3 driver"
|
||||
default n
|
||||
|
||||
menu "SPI3 driver configure"
|
||||
depends on MR_USING_SPI3
|
||||
|
||||
config MR_CFG_SPI3_GROUP
|
||||
int "SPI3 Group"
|
||||
default 1
|
||||
range 1 2
|
||||
endmenu
|
||||
|
||||
endmenu
|
||||
|
||||
endmenu
|
||||
3
driver/Kconfig
Normal file
3
driver/Kconfig
Normal file
@@ -0,0 +1,3 @@
|
||||
menu "No Driver Configuration"
|
||||
|
||||
endmenu
|
||||
60
kconfig.py
Normal file
60
kconfig.py
Normal file
@@ -0,0 +1,60 @@
|
||||
import argparse
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import textwrap
|
||||
|
||||
from kconfiglib import Kconfig, split_expr, expr_value, expr_str, BOOL, \
|
||||
TRISTATE, TRI_TO_STR, AND, OR
|
||||
|
||||
def generate_config(kconfig_file,config_in, config_out, header_out):
|
||||
|
||||
print("Parsing " + kconfig_file)
|
||||
kconf = Kconfig(kconfig_file, warn_to_stderr=False,
|
||||
suppress_traceback=True)
|
||||
|
||||
# Load config files
|
||||
print(kconf.load_config(config_in))
|
||||
|
||||
# Write merged config
|
||||
print(kconf.write_config(config_out))
|
||||
|
||||
# Write headers
|
||||
print(kconf.write_autoconf(header_out))
|
||||
|
||||
with open(header_out, 'r+') as header_file:
|
||||
|
||||
content = header_file.read()
|
||||
header_file.truncate(0)
|
||||
header_file.seek(0)
|
||||
|
||||
# Remove CONFIG_ and MR_USING_XXX following number
|
||||
content = content.replace("#define CONFIG_", "#define ")
|
||||
content = re.sub(r'#define MR_USING_(\w+) (\d+)', r'#define MR_USING_\1', content)
|
||||
|
||||
# Add the micro
|
||||
header_file.write("#ifndef _MR_CONFIG_H_\n")
|
||||
header_file.write("#define _MR_CONFIG_H_\n\n")
|
||||
|
||||
header_file.write("#ifdef __cplusplus\n")
|
||||
header_file.write("extern \"C\" {\n")
|
||||
header_file.write("#endif /* __cplusplus */\n\n")
|
||||
|
||||
# Write back the original data
|
||||
header_file.write(content)
|
||||
|
||||
# Add the micro
|
||||
header_file.write("\n#ifdef __cplusplus\n")
|
||||
header_file.write("}\n")
|
||||
header_file.write("#endif /* __cplusplus */\n\n")
|
||||
header_file.write("#endif /* _MR_CONFIG_H_ */\n")
|
||||
|
||||
def main():
|
||||
kconfig_file = 'Kconfig'
|
||||
config_in = '.config'
|
||||
config_out = '.config'
|
||||
header_out = 'include/mr_config.h'
|
||||
generate_config(kconfig_file, config_in, config_out, header_out)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user