diff --git a/configs/Kconfig b/configs/Kconfig index c1dc72ca95c..4fe6e0928b2 100644 --- a/configs/Kconfig +++ b/configs/Kconfig @@ -1586,7 +1586,18 @@ config LIB_BOARDCTL bool "Enabled boardctl() interface" default n +if LIB_BOARDCTL + config BOARDCTL_TSCTEST bool "Enable touchscreen test interfaces" default n - depends on LIB_BOARDCTL + +config BOARDCTL_ADCTEST + bool "Enable ADC test interfaces" + default n + +config BOARDCTL_IOCTL + bool "Board-specific boardctl() commands" + default n + +endif # LIB_BOARDCTL diff --git a/configs/boardctl.c b/configs/boardctl.c index d865fff6852..953b3e2d0e5 100755 --- a/configs/boardctl.c +++ b/configs/boardctl.c @@ -126,8 +126,35 @@ int boardctl(unsigned int cmd, uintptr_t arg) break; #endif +#ifdef CONFIG_BOARDCTL_ADCTEST + /* CMD: BOARDIOC_ADCTEST_SETUP + * DESCRIPTION: ADC controller test configuration + * ARG: None + * CONFIGURATION: CONFIG_LIB_BOARDCTL && CONFIG_BOARDCTL_ADCTEST + * DEPENDENCIES: Board logic must provide board_adc_setup() + */ + + case BOARDIOC_ADCTEST_SETUP: + { + ret = board_adc_setup((); + } + break; +#endif + default: - ret = -ENOTTY; + { +#ifdef CONFIG_BOARDCTL_IOCTL + /* Boards may also select CONFIG_BOARDCTL_IOCTL=y to enable board- + * specific commands. In this case, all commands not recognized + * by boardctl() will be forwarded to the board-provided board_ioctl() + * function. + */ + + ret = board_ioctl(cmd, arg); +#else + ret = -ENOTTY; +#endif + } break; } diff --git a/configs/cloudctrl/src/stm32_adc.c b/configs/cloudctrl/src/stm32_adc.c index d78497fecde..70e3578dd3f 100644 --- a/configs/cloudctrl/src/stm32_adc.c +++ b/configs/cloudctrl/src/stm32_adc.c @@ -43,6 +43,7 @@ #include #include +#include #include #include @@ -113,7 +114,7 @@ static const uint32_t g_pinlist[ADC1_NCHANNELS] = {GPIO_ADC12_IN10}; //{GPIO_AD ************************************************************************************/ /************************************************************************************ - * Name: adc_devinit + * Name: board_adc_setup * * Description: * All STM32 architectures must provide the following interface to work with @@ -121,7 +122,7 @@ static const uint32_t g_pinlist[ADC1_NCHANNELS] = {GPIO_ADC12_IN10}; //{GPIO_AD * ************************************************************************************/ -int adc_devinit(void) +int board_adc_setup(void) { #ifdef CONFIG_STM32_ADC1 static bool initialized = false; diff --git a/configs/lpcxpresso-lpc1768/src/lpc17_adc.c b/configs/lpcxpresso-lpc1768/src/lpc17_adc.c index 3b361d644bd..898f746b0d4 100644 --- a/configs/lpcxpresso-lpc1768/src/lpc17_adc.c +++ b/configs/lpcxpresso-lpc1768/src/lpc17_adc.c @@ -47,6 +47,7 @@ #include #include +#include #include #include @@ -75,7 +76,7 @@ ************************************************************************************/ /************************************************************************************ - * Name: adc_devinit + * Name: board_adc_setup * * Description: * All LPC17 architectures must provide the following interface to work with @@ -83,7 +84,7 @@ * ************************************************************************************/ -int adc_devinit(void) +int board_adc_setup(void) { static bool initialized = false; struct adc_dev_s *adc; diff --git a/configs/mbed/src/lpc17_adc.c b/configs/mbed/src/lpc17_adc.c index 0ae4423b467..7b0fe482605 100644 --- a/configs/mbed/src/lpc17_adc.c +++ b/configs/mbed/src/lpc17_adc.c @@ -49,6 +49,7 @@ #include #include +#include #include #include @@ -77,7 +78,7 @@ ************************************************************************************/ /************************************************************************************ - * Name: adc_devinit + * Name: board_adc_setup * * Description: * All LPC17 architectures must provide the following interface to work with @@ -85,7 +86,7 @@ * ************************************************************************************/ -int adc_devinit(void) +int board_adc_setup(void) { static bool initialized = false; struct adc_dev_s *adc; diff --git a/configs/nucleo-f4x1re/src/nucleo-f4x1re.h b/configs/nucleo-f4x1re/src/nucleo-f4x1re.h index 8c4b561f6f2..9f231e8f481 100644 --- a/configs/nucleo-f4x1re/src/nucleo-f4x1re.h +++ b/configs/nucleo-f4x1re/src/nucleo-f4x1re.h @@ -43,6 +43,7 @@ #include #include + #include /************************************************************************************ diff --git a/configs/nucleo-f4x1re/src/stm32_adc.c b/configs/nucleo-f4x1re/src/stm32_adc.c index f1b1ffa7a65..e6aaf7cc4ce 100644 --- a/configs/nucleo-f4x1re/src/stm32_adc.c +++ b/configs/nucleo-f4x1re/src/stm32_adc.c @@ -42,6 +42,7 @@ #include #include +#include #include #include @@ -158,7 +159,7 @@ int board_adc_initialize(void) } /************************************************************************************ - * Name: adc_devinit + * Name: board_adc_setup * * Description: * All STM32 architectures must provide the following interface to work with @@ -167,7 +168,7 @@ int board_adc_initialize(void) ************************************************************************************/ #ifdef CONFIG_EXAMPLES_ADC -int adc_devinit(void) +int board_adc_setup(void) { #ifdef CONFIG_SAMA5_ADC return board_adc_initialize(); diff --git a/configs/olimex-stm32-h405/nshusb/defconfig b/configs/olimex-stm32-h405/nshusb/defconfig index dd18ba95aab..37715abaa65 100644 --- a/configs/olimex-stm32-h405/nshusb/defconfig +++ b/configs/olimex-stm32-h405/nshusb/defconfig @@ -378,6 +378,8 @@ CONFIG_ARCH_BUTTONS=y CONFIG_ARCH_HAVE_IRQBUTTONS=y CONFIG_ARCH_IRQBUTTONS=y CONFIG_NSH_MMCSDMINOR=0 +CONFIG_LIB_BOARDCTL=y +CONFIG_BOARDCTL_ADCTEST=y # # Board-Specific Options diff --git a/configs/olimex-stm32-h405/src/stm32_adc.c b/configs/olimex-stm32-h405/src/stm32_adc.c index bff9debacaa..3ba3b6549f9 100644 --- a/configs/olimex-stm32-h405/src/stm32_adc.c +++ b/configs/olimex-stm32-h405/src/stm32_adc.c @@ -41,8 +41,11 @@ #include #include + +#include #include #include + #include "chip.h" #include "stm32_adc.h" #include "olimex-stm32-h405.h" @@ -111,7 +114,7 @@ static const uint32_t g_pinlist[ADC1_NCHANNELS] = {GPIO_ADC1_IN1};/*, GPIO_ADC ************************************************************************************/ /************************************************************************************ - * Name: adc_devinit + * Name: board_adc_setup * * Description: * All STM32 architectures must provide the following interface to work with @@ -119,7 +122,7 @@ static const uint32_t g_pinlist[ADC1_NCHANNELS] = {GPIO_ADC1_IN1};/*, GPIO_ADC * ************************************************************************************/ -int adc_devinit(void) +int board_adc_setup(void) { return stm32_adc_initialize(); } diff --git a/configs/olimex-stm32-p207/nsh/defconfig b/configs/olimex-stm32-p207/nsh/defconfig index f91cbe0ad01..b70e024f782 100644 --- a/configs/olimex-stm32-p207/nsh/defconfig +++ b/configs/olimex-stm32-p207/nsh/defconfig @@ -370,6 +370,8 @@ CONFIG_ARCH_BUTTONS=y CONFIG_ARCH_HAVE_IRQBUTTONS=y CONFIG_ARCH_IRQBUTTONS=y CONFIG_NSH_MMCSDMINOR=0 +CONFIG_LIB_BOARDCTL=y +CONFIG_BOARDCTL_ADCTEST=y # # Board-Specific Options diff --git a/configs/olimex-stm32-p207/src/stm32_adc.c b/configs/olimex-stm32-p207/src/stm32_adc.c index 0665c44c65a..96fc837b971 100644 --- a/configs/olimex-stm32-p207/src/stm32_adc.c +++ b/configs/olimex-stm32-p207/src/stm32_adc.c @@ -41,8 +41,11 @@ #include #include + +#include #include #include + #include "chip.h" #include "stm32_adc.h" #include "olimex-stm32-p207.h" @@ -103,7 +106,7 @@ static const uint32_t g_pinlist[ADC1_NCHANNELS] = {GPIO_ADC1_IN10}; ************************************************************************************/ /************************************************************************************ - * Name: adc_devinit + * Name: board_adc_setup * * Description: * All STM32 architectures must provide the following interface to work with @@ -111,7 +114,7 @@ static const uint32_t g_pinlist[ADC1_NCHANNELS] = {GPIO_ADC1_IN10}; * ************************************************************************************/ -int adc_devinit(void) +int board_adc_setup(void) { return stm32_adc_initialize(); } diff --git a/configs/sama5d3-xplained/src/sam_adc.c b/configs/sama5d3-xplained/src/sam_adc.c index 2d091745b42..f770ba5d22b 100644 --- a/configs/sama5d3-xplained/src/sam_adc.c +++ b/configs/sama5d3-xplained/src/sam_adc.c @@ -42,6 +42,7 @@ #include #include +#include #include #include "sam_adc.h" @@ -110,7 +111,7 @@ int board_adc_initialize(void) #endif /* CONFIG_ADC */ /************************************************************************************ - * Name: adc_devinit + * Name: board_adc_setup * * Description: * All SAMA5 architectures must provide the following interface to work with @@ -119,7 +120,7 @@ int board_adc_initialize(void) ************************************************************************************/ #ifdef CONFIG_EXAMPLES_ADC -int adc_devinit(void) +int board_adc_setup(void) { #ifdef CONFIG_SAMA5_ADC return board_adc_initialize(); diff --git a/configs/sama5d3x-ek/src/sam_adc.c b/configs/sama5d3x-ek/src/sam_adc.c index cc5614bd4a4..bb082fd0853 100644 --- a/configs/sama5d3x-ek/src/sam_adc.c +++ b/configs/sama5d3x-ek/src/sam_adc.c @@ -42,6 +42,7 @@ #include #include +#include #include #include "sam_adc.h" @@ -67,7 +68,7 @@ ************************************************************************************/ /************************************************************************************ - * Name: adc_devinit + * Name: board_adc_setup * * Description: * All STM32 architectures must provide the following interface to work with @@ -75,7 +76,7 @@ * ************************************************************************************/ -int adc_devinit(void) +int board_adc_setup(void) { #ifdef CONFIG_SAMA5_ADC static bool initialized = false; diff --git a/configs/sama5d4-ek/src/sam_adc.c b/configs/sama5d4-ek/src/sam_adc.c index f45cc479957..13346a91b90 100644 --- a/configs/sama5d4-ek/src/sam_adc.c +++ b/configs/sama5d4-ek/src/sam_adc.c @@ -42,6 +42,7 @@ #include #include +#include #include #include "sam_adc.h" @@ -66,7 +67,7 @@ ************************************************************************************/ /************************************************************************************ - * Name: adc_devinit + * Name: board_adc_setup * * Description: * All STM32 architectures must provide the following interface to work with @@ -74,7 +75,7 @@ * ************************************************************************************/ -int adc_devinit(void) +int board_adc_setup(void) { #ifdef CONFIG_SAMA5_ADC static bool initialized = false; diff --git a/configs/shenzhou/src/stm32_adc.c b/configs/shenzhou/src/stm32_adc.c index ee806a993ed..12190404238 100644 --- a/configs/shenzhou/src/stm32_adc.c +++ b/configs/shenzhou/src/stm32_adc.c @@ -42,6 +42,7 @@ #include #include +#include #include #include @@ -112,7 +113,7 @@ static const uint32_t g_pinlist[ADC1_NCHANNELS] = {GPIO_ADC12_IN10}; //{GPIO_AD ************************************************************************************/ /************************************************************************************ - * Name: adc_devinit + * Name: board_adc_setup * * Description: * All STM32 architectures must provide the following interface to work with @@ -120,7 +121,7 @@ static const uint32_t g_pinlist[ADC1_NCHANNELS] = {GPIO_ADC12_IN10}; //{GPIO_AD * ************************************************************************************/ -int adc_devinit(void) +int board_adc_setup(void) { #ifdef CONFIG_STM32_ADC1 static bool initialized = false; diff --git a/configs/stm3210e-eval/src/stm32_adc.c b/configs/stm3210e-eval/src/stm32_adc.c index 5bd4090237e..7a563c00c77 100644 --- a/configs/stm3210e-eval/src/stm32_adc.c +++ b/configs/stm3210e-eval/src/stm32_adc.c @@ -42,6 +42,7 @@ #include #include +#include #include #include @@ -103,7 +104,7 @@ static const uint32_t g_pinlist[ADC1_NCHANNELS] = {GPIO_ADC1_IN14}; ************************************************************************************/ /************************************************************************************ - * Name: adc_devinit + * Name: board_adc_setup * * Description: * All STM32 architectures must provide the following interface to work with @@ -111,7 +112,7 @@ static const uint32_t g_pinlist[ADC1_NCHANNELS] = {GPIO_ADC1_IN14}; * ************************************************************************************/ -int adc_devinit(void) +int board_adc_setup(void) { #ifdef CONFIG_STM32_ADC1 static bool initialized = false; diff --git a/configs/stm3220g-eval/src/stm32_adc.c b/configs/stm3220g-eval/src/stm32_adc.c index 6347f1cfe43..94f3c2d4283 100644 --- a/configs/stm3220g-eval/src/stm32_adc.c +++ b/configs/stm3220g-eval/src/stm32_adc.c @@ -42,6 +42,7 @@ #include #include +#include #include #include @@ -107,7 +108,7 @@ static const uint32_t g_pinlist[ADC3_NCHANNELS] = {GPIO_ADC3_IN7}; ************************************************************************************/ /************************************************************************************ - * Name: adc_devinit + * Name: board_adc_setup * * Description: * All STM32 architectures must provide the following interface to work with @@ -115,7 +116,7 @@ static const uint32_t g_pinlist[ADC3_NCHANNELS] = {GPIO_ADC3_IN7}; * ************************************************************************************/ -int adc_devinit(void) +int board_adc_setup(void) { #ifdef CONFIG_STM32_ADC3 static bool initialized = false; diff --git a/configs/stm3240g-eval/src/stm32_adc.c b/configs/stm3240g-eval/src/stm32_adc.c index 9fba540237d..9c613e098b0 100644 --- a/configs/stm3240g-eval/src/stm32_adc.c +++ b/configs/stm3240g-eval/src/stm32_adc.c @@ -42,6 +42,7 @@ #include #include +#include #include #include @@ -107,7 +108,7 @@ static const uint32_t g_pinlist[ADC3_NCHANNELS] = {GPIO_ADC3_IN7}; ************************************************************************************/ /************************************************************************************ - * Name: adc_devinit + * Name: board_adc_setup * * Description: * All STM32 architectures must provide the following interface to work with @@ -115,7 +116,7 @@ static const uint32_t g_pinlist[ADC3_NCHANNELS] = {GPIO_ADC3_IN7}; * ************************************************************************************/ -int adc_devinit(void) +int board_adc_setup(void) { #ifdef CONFIG_STM32_ADC3 static bool initialized = false; diff --git a/configs/tm4c123g-launchpad/src/tm4c123g-launchpad.h b/configs/tm4c123g-launchpad/src/tm4c123g-launchpad.h index 145127e6030..2d1bab2fe25 100644 --- a/configs/tm4c123g-launchpad/src/tm4c123g-launchpad.h +++ b/configs/tm4c123g-launchpad/src/tm4c123g-launchpad.h @@ -249,18 +249,5 @@ int tiva_timer_initialize(void); int board_adc_initialize(void); #endif -/************************************************************************************ - * Name: adc_devinit - * - * Description: - * All Tiva architectures must provide the following interface to work with - * examples/adc. - * - ************************************************************************************/ - -#if defined(CONFIG_TIVA_ADC) && defined(CONFIG_EXAMPLES_ADC) -int adc_devinit(void); -#endif - #endif /* __ASSEMBLY__ */ #endif /* __CONFIGS_TM4C123G_LAUNCHPAD_TM4C123G_LAUNCHPAD_H */ diff --git a/configs/tm4c123g-launchpad/src/tm4c_adc.c b/configs/tm4c123g-launchpad/src/tm4c_adc.c index 2c727c3b6ae..f452a433e9a 100644 --- a/configs/tm4c123g-launchpad/src/tm4c_adc.c +++ b/configs/tm4c123g-launchpad/src/tm4c_adc.c @@ -42,6 +42,7 @@ #include #include +#include #include #include "tiva_adc.h" @@ -136,7 +137,7 @@ int board_adc_initialize(void) #endif /* CONFIG_ADC */ /************************************************************************************ - * Name: adc_devinit + * Name: board_adc_setup * * Description: * All Tiva architectures must provide the following interface to work with @@ -145,7 +146,7 @@ int board_adc_initialize(void) ************************************************************************************/ #ifdef CONFIG_EXAMPLES_ADC -int adc_devinit(void) +int board_adc_setup(void) { #ifdef CONFIG_TIVA_ADC return board_adc_initialize(); @@ -159,7 +160,7 @@ int adc_devinit(void) /* Tiva timer interface does not currently support user configuration */ -# if 0 +#if 0 /************************************************************************************ * Name: adc_timer_init * @@ -188,5 +189,6 @@ TIMER_HANDLE adc_timer_init(void) return tiva_gptm_configure((const struct tiva_gptmconfig_s *)&adctimer); } -# endif + +#endif #endif /* defined (CONFIG_TIVA_ADC) && defined (CONFIG_TIVA_TIMER) */ diff --git a/configs/zkit-arm-1769/src/lpc17_adc.c b/configs/zkit-arm-1769/src/lpc17_adc.c index 932f8214cc4..2ba54b4b729 100644 --- a/configs/zkit-arm-1769/src/lpc17_adc.c +++ b/configs/zkit-arm-1769/src/lpc17_adc.c @@ -47,6 +47,7 @@ #include #include +#include #include #include @@ -75,7 +76,7 @@ ************************************************************************************/ /************************************************************************************ - * Name: adc_devinit + * Name: board_adc_setup * * Description: * All LPC17 architectures must provide the following interface to work with @@ -83,7 +84,7 @@ * ************************************************************************************/ -int adc_devinit(void) +int board_adc_setup(void) { static bool initialized = false; struct adc_dev_s *adc; diff --git a/include/nuttx/board.h b/include/nuttx/board.h index 2942b02173a..80ec312c6fa 100644 --- a/include/nuttx/board.h +++ b/include/nuttx/board.h @@ -196,6 +196,32 @@ int board_tsc_setup(int minor); void board_tsc_teardown(void); +/**************************************************************************** + * Name: board_adc_setup + * + * Description: + * All architectures must provide the following interface in order to + * work with examples/adc. + * + ****************************************************************************/ + +int board_adc_setup(void); + +/**************************************************************************** + * Name: board_ioctl + * + * Description: + * If CONFIG_LIB_BOARDCTL=y, boards may also select CONFIG_BOARDCTL_IOCTL=y + * enable board specific commands. In this case, all commands not + * recognized by boardctl() will be forwarded to the board-provided + * board_ioctl() function. + * + ****************************************************************************/ + +#ifdef CONFIG_BOARDCTL_IOCTL +int board_ioctl(unsigned int cmd, uintptr_t arg); +#endif + /**************************************************************************** * Name: board_led_initialize * diff --git a/include/sys/boardctl.h b/include/sys/boardctl.h index 675daa80259..8da574ec344 100644 --- a/include/sys/boardctl.h +++ b/include/sys/boardctl.h @@ -69,11 +69,28 @@ * ARG: None * CONFIGURATION: CONFIG_LIB_BOARDCTL && CONFIG_BOARDCTL_TSCTEST * DEPENDENCIES: Board logic must provide board_tsc_teardown() + * + * CMD: BOARDIOC_ADCTEST_SETUP + * DESCRIPTION: ADC controller test configuration + * ARG: None + * CONFIGURATION: CONFIG_LIB_BOARDCTL && CONFIG_BOARDCTL_ADCTEST + * DEPENDENCIES: Board logic must provide board_adc_setup() + * */ #define BOARDIOC_INIT _BOARDIOC(0x0001) #define BOARDIOC_TSCTEST_SETUP _BOARDIOC(0x0002) #define BOARDIOC_TSCTEST_TEARDOWN _BOARDIOC(0x0003) +#define BOARDIOC_ADCTEST_SETUP _BOARDIOC(0x0004) + +/* If CONFIG_BOARDCTL_IOCTL=y, then boad-specific commands will be support. + * In this case, all commands not recognized by boardctl() will be forwarded + * to the board-provided board_ioctl() function. + * + * User defined board commands may begin with this value: + */ + +#define BOARDIOC_USER _BOARDIOC(0x0005) /**************************************************************************** * Public Type Definitions