From c6d89df2d2e6efd260e0d415e01f8107a8901d4b Mon Sep 17 00:00:00 2001 From: MacRsh Date: Thu, 7 Dec 2023 13:02:56 +0800 Subject: [PATCH] =?UTF-8?q?1.Kconfig=E9=85=8D=E7=BD=AE=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Kconfig | 93 ++++++++++++++++++++++++++++++++++-------------- source/service.c | 8 +++-- 2 files changed, 72 insertions(+), 29 deletions(-) diff --git a/Kconfig b/Kconfig index dd7c02b..81b71e8 100644 --- a/Kconfig +++ b/Kconfig @@ -3,110 +3,147 @@ mainmenu "mr-library" menu "Device configure" config MR_CFG_HEAP_SIZE - int "The heap size (Bytes)" - default 1024 - range 8 2147483647 + int "Heap size (Bytes)" + default 4096 + range 32 2147483647 help - Size of dynamic memory for system. + "Size of dynamic memory for system." config MR_USING_ASSERT - bool "Enable assert" - default y + bool "Enable assert" + default y + help + "Enabling this option allows the use of assert statements in the code." config MR_CFG_NAME_MAX - int "The maximum length of device name" + int "Max length of device name" default 8 range 4 1024 help - Maximum length of name + "Maximum length of name" config MR_CFG_DESC_MAX - int "The maximum number of descriptors" + int "Max number of descriptors" default 32 range 16 1024 help - Maximum number of descriptors + "Maximum number of descriptors" config MR_USING_RDWR_CTL bool "Enable read/write control" default y + help + "Enabling this option allows for read and write control of devices." + + config MR_USING_CONSOLE + bool "Enable console" + default y + help + "Enabling this option allows for the use of the console device." + menu "Console configure" + depends on MR_USING_CONSOLE + + config MR_CFG_CONSOLE_NAME + string "Console device name" + default "serial1" + help + "This option sets the name of the console device." + + config MR_USING_CONSOLE_NONBLOCK + bool "Console device non-blocking read/write" + default n + help + "Enable or disable non-blocking read/write for the console device." + endmenu config MR_USING_PRINTF_BUFSZ - bool "The size of printf buffer" - default 128 - range 16 2147483647 + int "Size of printf buffer" + default 128 + range 16 2147483647 + help + "This option sets the size of the buffer used for printf operations." config MR_USING_ADC bool "Enable ADC device" default n + help + "Enabling this option allows for the use of ADC (Analog-to-Digital Converter) devices." config MR_USING_CAN bool "Enable CAN device" default n + help + "Enabling this option allows for the use of CAN (Controller Area Network) devices." menu "CAN configure" depends on MR_USING_CAN config MR_CFG_CAN_RD_BUFSZ - int "The RX buffer size" + int "RX buffer size" default 32 range 0 MR_CFG_HEAP_SIZE help - Size of SPI Rx buffer + "This option sets the size of the RX (receive) buffer used by the CAN device." endmenu config MR_USING_DAC bool "Enable DAC device" default n + help + "Enabling this option allows for the use of DAC (Digital-to-Analog Converter) devices." config MR_USING_I2C bool "Enable I2C device" default n + help + "Enabling this option allows for the use of I2C (Inter-Integrated Circuit) devices." menu "I2C configure" depends on MR_USING_I2C config MR_CFG_I2C_RD_BUFSZ - int "The RX buffer size" + int "RX buffer size" default 32 range 0 MR_CFG_HEAP_SIZE help - Size of SPI RX buffer + "This option sets the size of the RX (receive) buffer used by the I2C device." endmenu config MR_USING_PIN bool "Enable Pin device" default n + help + "Enabling this option allows for the use of Pin devices." config MR_USING_SERIAL bool "Enable Serial device" default n + help + "Enabling this option allows for the use of Serial devices." menu "Serial configure" depends on MR_USING_SERIAL config MR_CFG_SERIAL_RD_BUFSZ - int "The RX buffer size" + int "RX buffer size" default 32 range 0 MR_CFG_HEAP_SIZE help - Size of Serial RX buffer + "This option sets the size of the RX (receive) buffer used by the Serial device." config MR_CFG_SERIAL_WR_BUFSZ - int "The TX buffer size for Serial" + int "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" + "This option sets the size of the TX (transmit) buffer used by the Serial device." endmenu config MR_USING_SPI bool "Enable SPI device" default n + help + "Enabling this option allows for the use of SPI (Serial Peripheral Interface) devices." menu "SPI configure" depends on MR_USING_SPI @@ -116,13 +153,15 @@ menu "Device configure" default 32 range 0 MR_CFG_HEAP_SIZE help - Size of SPI RX buffer + "This option sets the size of the RX (receive) buffer used by the SPI device." endmenu config MR_USING_TIMER bool "Enable Timer device" default n + help + "Enabling this option allows for the use of Timer devices." endmenu -source "driver/Kconfig" +source "driver/Kconfig" \ No newline at end of file diff --git a/source/service.c b/source/service.c index 9af98f6..fbc9d3a 100644 --- a/source/service.c +++ b/source/service.c @@ -344,12 +344,16 @@ MR_WEAK void mr_delay_ms(uint32_t ms) */ MR_WEAK int mr_printf_output(const char *buf, size_t size) { -#ifdef MR_CFG_CONSOLE_NAME +#ifdef MR_USING_CONSOLE static int console = -1; if (console < 0) { +#ifndef MR_USING_CONSOLE_NONBLOCK console = mr_dev_open(MR_CFG_CONSOLE_NAME, MR_OFLAG_RDWR); +#else + console = mr_dev_open(MR_CFG_CONSOLE_NAME, MR_OFLAG_RDWR | MR_OFLAG_NONBLOCK); +#endif /* MR_USING_CONSOLE_NONBLOCK */ if (console < 0) { return console; @@ -358,7 +362,7 @@ MR_WEAK int mr_printf_output(const char *buf, size_t size) return (int)mr_dev_write(console, buf, size); #else return 0; -#endif /* MR_CFG_CONSOLE_NAME */ +#endif /* MR_USING_CONSOLE */ } /**