mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 17:48:54 +08:00
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:
+12
-1
@@ -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
|
||||
|
||||
+28
-1
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/analog/adc.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:
|
||||
* 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;
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/analog/adc.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/analog/adc.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/compiler.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/************************************************************************************
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/analog/adc.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -41,8 +41,11 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/analog/adc.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#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();
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -41,8 +41,11 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/analog/adc.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#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();
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/analog/adc.h>
|
||||
|
||||
#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();
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/analog/adc.h>
|
||||
|
||||
#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;
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/analog/adc.h>
|
||||
|
||||
#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;
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/analog/adc.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:
|
||||
* 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;
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/analog/adc.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:
|
||||
* 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;
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/analog/adc.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:
|
||||
* 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;
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/analog/adc.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:
|
||||
* 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;
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/analog/adc.h>
|
||||
|
||||
#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) */
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/analog/adc.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
*
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user