Rename adc_devinit() to board_adc_setup(). Add support to the boardctl() interface so that it can call board_adc_setup() on behalf of an application. Change apps/examples/adc to that is now calls boardctl() instead of adc_devinit() in order to initalize the ADC device.

This commit is contained in:
Gregory Nutt
2015-03-31 15:00:23 -06:00
parent ba169b69f9
commit 4212b9b385
23 changed files with 140 additions and 47 deletions
+12 -1
View File
@@ -1586,7 +1586,18 @@ config LIB_BOARDCTL
bool "Enabled boardctl() interface" bool "Enabled boardctl() interface"
default n default n
if LIB_BOARDCTL
config BOARDCTL_TSCTEST config BOARDCTL_TSCTEST
bool "Enable touchscreen test interfaces" bool "Enable touchscreen test interfaces"
default n 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
+28 -1
View File
@@ -126,8 +126,35 @@ int boardctl(unsigned int cmd, uintptr_t arg)
break; break;
#endif #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: 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; break;
} }
+3 -2
View File
@@ -43,6 +43,7 @@
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
#include <nuttx/board.h>
#include <nuttx/analog/adc.h> #include <nuttx/analog/adc.h>
#include <arch/board/board.h> #include <arch/board/board.h>
@@ -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: * Description:
* All STM32 architectures must provide the following interface to work with * 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 #ifdef CONFIG_STM32_ADC1
static bool initialized = false; static bool initialized = false;
+3 -2
View File
@@ -47,6 +47,7 @@
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
#include <nuttx/board.h>
#include <nuttx/analog/adc.h> #include <nuttx/analog/adc.h>
#include <arch/board/board.h> #include <arch/board/board.h>
@@ -75,7 +76,7 @@
************************************************************************************/ ************************************************************************************/
/************************************************************************************ /************************************************************************************
* Name: adc_devinit * Name: board_adc_setup
* *
* Description: * Description:
* All LPC17 architectures must provide the following interface to work with * 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; static bool initialized = false;
struct adc_dev_s *adc; struct adc_dev_s *adc;
+3 -2
View File
@@ -49,6 +49,7 @@
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
#include <nuttx/board.h>
#include <nuttx/analog/adc.h> #include <nuttx/analog/adc.h>
#include <arch/board/board.h> #include <arch/board/board.h>
@@ -77,7 +78,7 @@
************************************************************************************/ ************************************************************************************/
/************************************************************************************ /************************************************************************************
* Name: adc_devinit * Name: board_adc_setup
* *
* Description: * Description:
* All LPC17 architectures must provide the following interface to work with * 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; static bool initialized = false;
struct adc_dev_s *adc; struct adc_dev_s *adc;
@@ -43,6 +43,7 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <nuttx/compiler.h> #include <nuttx/compiler.h>
#include <stdint.h> #include <stdint.h>
/************************************************************************************ /************************************************************************************
+3 -2
View File
@@ -42,6 +42,7 @@
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
#include <nuttx/board.h>
#include <nuttx/analog/adc.h> #include <nuttx/analog/adc.h>
#include <arch/board/board.h> #include <arch/board/board.h>
@@ -158,7 +159,7 @@ int board_adc_initialize(void)
} }
/************************************************************************************ /************************************************************************************
* Name: adc_devinit * Name: board_adc_setup
* *
* Description: * Description:
* All STM32 architectures must provide the following interface to work with * All STM32 architectures must provide the following interface to work with
@@ -167,7 +168,7 @@ int board_adc_initialize(void)
************************************************************************************/ ************************************************************************************/
#ifdef CONFIG_EXAMPLES_ADC #ifdef CONFIG_EXAMPLES_ADC
int adc_devinit(void) int board_adc_setup(void)
{ {
#ifdef CONFIG_SAMA5_ADC #ifdef CONFIG_SAMA5_ADC
return board_adc_initialize(); return board_adc_initialize();
@@ -378,6 +378,8 @@ CONFIG_ARCH_BUTTONS=y
CONFIG_ARCH_HAVE_IRQBUTTONS=y CONFIG_ARCH_HAVE_IRQBUTTONS=y
CONFIG_ARCH_IRQBUTTONS=y CONFIG_ARCH_IRQBUTTONS=y
CONFIG_NSH_MMCSDMINOR=0 CONFIG_NSH_MMCSDMINOR=0
CONFIG_LIB_BOARDCTL=y
CONFIG_BOARDCTL_ADCTEST=y
# #
# Board-Specific Options # Board-Specific Options
+5 -2
View File
@@ -41,8 +41,11 @@
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
#include <nuttx/board.h>
#include <nuttx/analog/adc.h> #include <nuttx/analog/adc.h>
#include <arch/board/board.h> #include <arch/board/board.h>
#include "chip.h" #include "chip.h"
#include "stm32_adc.h" #include "stm32_adc.h"
#include "olimex-stm32-h405.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: * Description:
* All STM32 architectures must provide the following interface to work with * 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(); return stm32_adc_initialize();
} }
+2
View File
@@ -370,6 +370,8 @@ CONFIG_ARCH_BUTTONS=y
CONFIG_ARCH_HAVE_IRQBUTTONS=y CONFIG_ARCH_HAVE_IRQBUTTONS=y
CONFIG_ARCH_IRQBUTTONS=y CONFIG_ARCH_IRQBUTTONS=y
CONFIG_NSH_MMCSDMINOR=0 CONFIG_NSH_MMCSDMINOR=0
CONFIG_LIB_BOARDCTL=y
CONFIG_BOARDCTL_ADCTEST=y
# #
# Board-Specific Options # Board-Specific Options
+5 -2
View File
@@ -41,8 +41,11 @@
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
#include <nuttx/board.h>
#include <nuttx/analog/adc.h> #include <nuttx/analog/adc.h>
#include <arch/board/board.h> #include <arch/board/board.h>
#include "chip.h" #include "chip.h"
#include "stm32_adc.h" #include "stm32_adc.h"
#include "olimex-stm32-p207.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: * Description:
* All STM32 architectures must provide the following interface to work with * 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(); return stm32_adc_initialize();
} }
+3 -2
View File
@@ -42,6 +42,7 @@
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
#include <nuttx/board.h>
#include <nuttx/analog/adc.h> #include <nuttx/analog/adc.h>
#include "sam_adc.h" #include "sam_adc.h"
@@ -110,7 +111,7 @@ int board_adc_initialize(void)
#endif /* CONFIG_ADC */ #endif /* CONFIG_ADC */
/************************************************************************************ /************************************************************************************
* Name: adc_devinit * Name: board_adc_setup
* *
* Description: * Description:
* All SAMA5 architectures must provide the following interface to work with * All SAMA5 architectures must provide the following interface to work with
@@ -119,7 +120,7 @@ int board_adc_initialize(void)
************************************************************************************/ ************************************************************************************/
#ifdef CONFIG_EXAMPLES_ADC #ifdef CONFIG_EXAMPLES_ADC
int adc_devinit(void) int board_adc_setup(void)
{ {
#ifdef CONFIG_SAMA5_ADC #ifdef CONFIG_SAMA5_ADC
return board_adc_initialize(); return board_adc_initialize();
+3 -2
View File
@@ -42,6 +42,7 @@
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
#include <nuttx/board.h>
#include <nuttx/analog/adc.h> #include <nuttx/analog/adc.h>
#include "sam_adc.h" #include "sam_adc.h"
@@ -67,7 +68,7 @@
************************************************************************************/ ************************************************************************************/
/************************************************************************************ /************************************************************************************
* Name: adc_devinit * Name: board_adc_setup
* *
* Description: * Description:
* All STM32 architectures must provide the following interface to work with * 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 #ifdef CONFIG_SAMA5_ADC
static bool initialized = false; static bool initialized = false;
+3 -2
View File
@@ -42,6 +42,7 @@
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
#include <nuttx/board.h>
#include <nuttx/analog/adc.h> #include <nuttx/analog/adc.h>
#include "sam_adc.h" #include "sam_adc.h"
@@ -66,7 +67,7 @@
************************************************************************************/ ************************************************************************************/
/************************************************************************************ /************************************************************************************
* Name: adc_devinit * Name: board_adc_setup
* *
* Description: * Description:
* All STM32 architectures must provide the following interface to work with * 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 #ifdef CONFIG_SAMA5_ADC
static bool initialized = false; static bool initialized = false;
+3 -2
View File
@@ -42,6 +42,7 @@
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
#include <nuttx/board.h>
#include <nuttx/analog/adc.h> #include <nuttx/analog/adc.h>
#include <arch/board/board.h> #include <arch/board/board.h>
@@ -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: * Description:
* All STM32 architectures must provide the following interface to work with * 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 #ifdef CONFIG_STM32_ADC1
static bool initialized = false; static bool initialized = false;
+3 -2
View File
@@ -42,6 +42,7 @@
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
#include <nuttx/board.h>
#include <nuttx/analog/adc.h> #include <nuttx/analog/adc.h>
#include <arch/board/board.h> #include <arch/board/board.h>
@@ -103,7 +104,7 @@ static const uint32_t g_pinlist[ADC1_NCHANNELS] = {GPIO_ADC1_IN14};
************************************************************************************/ ************************************************************************************/
/************************************************************************************ /************************************************************************************
* Name: adc_devinit * Name: board_adc_setup
* *
* Description: * Description:
* All STM32 architectures must provide the following interface to work with * 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 #ifdef CONFIG_STM32_ADC1
static bool initialized = false; static bool initialized = false;
+3 -2
View File
@@ -42,6 +42,7 @@
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
#include <nuttx/board.h>
#include <nuttx/analog/adc.h> #include <nuttx/analog/adc.h>
#include <arch/board/board.h> #include <arch/board/board.h>
@@ -107,7 +108,7 @@ static const uint32_t g_pinlist[ADC3_NCHANNELS] = {GPIO_ADC3_IN7};
************************************************************************************/ ************************************************************************************/
/************************************************************************************ /************************************************************************************
* Name: adc_devinit * Name: board_adc_setup
* *
* Description: * Description:
* All STM32 architectures must provide the following interface to work with * 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 #ifdef CONFIG_STM32_ADC3
static bool initialized = false; static bool initialized = false;
+3 -2
View File
@@ -42,6 +42,7 @@
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
#include <nuttx/board.h>
#include <nuttx/analog/adc.h> #include <nuttx/analog/adc.h>
#include <arch/board/board.h> #include <arch/board/board.h>
@@ -107,7 +108,7 @@ static const uint32_t g_pinlist[ADC3_NCHANNELS] = {GPIO_ADC3_IN7};
************************************************************************************/ ************************************************************************************/
/************************************************************************************ /************************************************************************************
* Name: adc_devinit * Name: board_adc_setup
* *
* Description: * Description:
* All STM32 architectures must provide the following interface to work with * 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 #ifdef CONFIG_STM32_ADC3
static bool initialized = false; static bool initialized = false;
@@ -249,18 +249,5 @@ int tiva_timer_initialize(void);
int board_adc_initialize(void); int board_adc_initialize(void);
#endif #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 /* __ASSEMBLY__ */
#endif /* __CONFIGS_TM4C123G_LAUNCHPAD_TM4C123G_LAUNCHPAD_H */ #endif /* __CONFIGS_TM4C123G_LAUNCHPAD_TM4C123G_LAUNCHPAD_H */
+6 -4
View File
@@ -42,6 +42,7 @@
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
#include <nuttx/board.h>
#include <nuttx/analog/adc.h> #include <nuttx/analog/adc.h>
#include "tiva_adc.h" #include "tiva_adc.h"
@@ -136,7 +137,7 @@ int board_adc_initialize(void)
#endif /* CONFIG_ADC */ #endif /* CONFIG_ADC */
/************************************************************************************ /************************************************************************************
* Name: adc_devinit * Name: board_adc_setup
* *
* Description: * Description:
* All Tiva architectures must provide the following interface to work with * All Tiva architectures must provide the following interface to work with
@@ -145,7 +146,7 @@ int board_adc_initialize(void)
************************************************************************************/ ************************************************************************************/
#ifdef CONFIG_EXAMPLES_ADC #ifdef CONFIG_EXAMPLES_ADC
int adc_devinit(void) int board_adc_setup(void)
{ {
#ifdef CONFIG_TIVA_ADC #ifdef CONFIG_TIVA_ADC
return board_adc_initialize(); return board_adc_initialize();
@@ -159,7 +160,7 @@ int adc_devinit(void)
/* Tiva timer interface does not currently support user configuration */ /* Tiva timer interface does not currently support user configuration */
# if 0 #if 0
/************************************************************************************ /************************************************************************************
* Name: adc_timer_init * Name: adc_timer_init
* *
@@ -188,5 +189,6 @@ TIMER_HANDLE adc_timer_init(void)
return tiva_gptm_configure((const struct tiva_gptmconfig_s *)&adctimer); return tiva_gptm_configure((const struct tiva_gptmconfig_s *)&adctimer);
} }
# endif
#endif
#endif /* defined (CONFIG_TIVA_ADC) && defined (CONFIG_TIVA_TIMER) */ #endif /* defined (CONFIG_TIVA_ADC) && defined (CONFIG_TIVA_TIMER) */
+3 -2
View File
@@ -47,6 +47,7 @@
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
#include <nuttx/board.h>
#include <nuttx/analog/adc.h> #include <nuttx/analog/adc.h>
#include <arch/board/board.h> #include <arch/board/board.h>
@@ -75,7 +76,7 @@
************************************************************************************/ ************************************************************************************/
/************************************************************************************ /************************************************************************************
* Name: adc_devinit * Name: board_adc_setup
* *
* Description: * Description:
* All LPC17 architectures must provide the following interface to work with * 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; static bool initialized = false;
struct adc_dev_s *adc; struct adc_dev_s *adc;
+26
View File
@@ -196,6 +196,32 @@ int board_tsc_setup(int minor);
void board_tsc_teardown(void); 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 * Name: board_led_initialize
* *
+17
View File
@@ -69,11 +69,28 @@
* ARG: None * ARG: None
* CONFIGURATION: CONFIG_LIB_BOARDCTL && CONFIG_BOARDCTL_TSCTEST * CONFIGURATION: CONFIG_LIB_BOARDCTL && CONFIG_BOARDCTL_TSCTEST
* DEPENDENCIES: Board logic must provide board_tsc_teardown() * 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_INIT _BOARDIOC(0x0001)
#define BOARDIOC_TSCTEST_SETUP _BOARDIOC(0x0002) #define BOARDIOC_TSCTEST_SETUP _BOARDIOC(0x0002)
#define BOARDIOC_TSCTEST_TEARDOWN _BOARDIOC(0x0003) #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 * Public Type Definitions