boards/arm/samv7/same70-xplained: add support for AFEC (ADC) driver
This commit adds board level support for Analog Front End driver to SAME70 Xplained boaed. Example application can be run via adc configuration. Signed-off-by: Michal Lenc <michallenc@seznam.cz>
This commit is contained in:
parent
e0cef411e1
commit
3db9549fce
@ -1311,6 +1311,12 @@ NOTES:
|
||||
Configuration sub-directories
|
||||
-----------------------------
|
||||
|
||||
adc
|
||||
|
||||
This is a basic nsh configuration (se below) with added example for
|
||||
ADC (AFEC) driver. Data can be read through channel AFE0_AD0 by
|
||||
running application "adc" in NuttShell.
|
||||
|
||||
mrf24j40-starhub
|
||||
|
||||
This configuration implements a hub node in a 6LoWPAN start network.
|
||||
|
84
boards/arm/samv7/same70-xplained/configs/adc/defconfig
Normal file
84
boards/arm/samv7/same70-xplained/configs/adc/defconfig
Normal file
@ -0,0 +1,84 @@
|
||||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
# CONFIG_ARCH_RAMFUNCS is not set
|
||||
# CONFIG_MMCSD_MMCSUPPORT is not set
|
||||
# CONFIG_MMCSD_SPI is not set
|
||||
# CONFIG_SAMV7_SDRAMHEAP is not set
|
||||
# CONFIG_SAMV7_UART0 is not set
|
||||
# CONFIG_SAMV7_UART2 is not set
|
||||
# CONFIG_SAMV7_UART4 is not set
|
||||
CONFIG_ADC=y
|
||||
CONFIG_ANALOG=y
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="same70-xplained"
|
||||
CONFIG_ARCH_BOARD_SAME70_XPLAINED=y
|
||||
CONFIG_ARCH_BUTTONS=y
|
||||
CONFIG_ARCH_CHIP="samv7"
|
||||
CONFIG_ARCH_CHIP_SAME70=y
|
||||
CONFIG_ARCH_CHIP_SAME70Q21=y
|
||||
CONFIG_ARCH_CHIP_SAME70Q=y
|
||||
CONFIG_ARCH_CHIP_SAMV7=y
|
||||
CONFIG_ARCH_INTERRUPTSTACK=2048
|
||||
CONFIG_ARCH_IRQBUTTONS=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARMV7M_DCACHE=y
|
||||
CONFIG_ARMV7M_ICACHE=y
|
||||
CONFIG_ARMV7M_LAZYFPU=y
|
||||
CONFIG_AT24XX_ADDR=0x57
|
||||
CONFIG_AT24XX_EXTENDED=y
|
||||
CONFIG_AT24XX_EXTSIZE=160
|
||||
CONFIG_AT24XX_SIZE=2
|
||||
CONFIG_BOARD_LOOPSPERMSEC=51262
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_EXAMPLES_ADC=y
|
||||
CONFIG_EXAMPLES_ADC_GROUPSIZE=1
|
||||
CONFIG_EXAMPLES_ADC_NSAMPLES=1000
|
||||
CONFIG_EXAMPLES_ADC_SWTRIG=y
|
||||
CONFIG_FAT_LCNAMES=y
|
||||
CONFIG_FAT_LFN=y
|
||||
CONFIG_FS_FAT=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_I2CTOOL_MAXBUS=0
|
||||
CONFIG_MMCSD_MULTIBLOCK_DISABLE=y
|
||||
CONFIG_MMCSD_SDIO=y
|
||||
CONFIG_MTD=y
|
||||
CONFIG_MTD_AT24XX=y
|
||||
CONFIG_MTD_AT25=y
|
||||
CONFIG_MTD_CONFIG=y
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_RAM_SIZE=393216
|
||||
CONFIG_RAM_START=0x20400000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SAMV7_AFEC0=y
|
||||
CONFIG_SAMV7_GPIOA_IRQ=y
|
||||
CONFIG_SAMV7_GPIOC_IRQ=y
|
||||
CONFIG_SAMV7_GPIO_IRQ=y
|
||||
CONFIG_SAMV7_HSMCI0=y
|
||||
CONFIG_SAMV7_SDRAMC=y
|
||||
CONFIG_SAMV7_SDRAMSIZE=2097152
|
||||
CONFIG_SAMV7_TWIHS0=y
|
||||
CONFIG_SAMV7_USART1=y
|
||||
CONFIG_SAMV7_XDMAC=y
|
||||
CONFIG_SCHED_HPWORK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_SDIO_BLOCKSETUP=y
|
||||
CONFIG_START_DAY=10
|
||||
CONFIG_START_MONTH=3
|
||||
CONFIG_START_YEAR=2014
|
||||
CONFIG_SYSTEM_I2CTOOL=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_RAMTEST=y
|
||||
CONFIG_USART1_SERIAL_CONSOLE=y
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
@ -81,6 +81,10 @@ endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SAMV7_AFEC),y)
|
||||
CSRCS += sam_afec.c
|
||||
endif
|
||||
|
||||
ifneq (,$(findstring y,$(CONFIG_SAMV7_DAC0) $(CONFIG_SAMV7_DAC1)))
|
||||
CSRCS += sam_dac.c
|
||||
endif
|
||||
|
121
boards/arm/samv7/same70-xplained/src/sam_afec.c
Normal file
121
boards/arm/samv7/same70-xplained/src/sam_afec.c
Normal file
@ -0,0 +1,121 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/samv7/same70-xplained/src/sam_afec.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/analog/adc.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "chip.h"
|
||||
#include "arm_arch.h"
|
||||
|
||||
#include "sam_afec.h"
|
||||
#include "same70-xplained.h"
|
||||
|
||||
#ifdef CONFIG_SAMV7_AFEC
|
||||
|
||||
#define ADC0_NCHANNELS 3
|
||||
#define ADC1_NCHANNELS 4
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SAMV7_AFEC0
|
||||
static const uint8_t g_chanlist0[ADC0_NCHANNELS] =
|
||||
{
|
||||
0, 6, 8
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SAMV7_AFEC1
|
||||
static const uint8_t g_chanlist1[ADC1_NCHANNELS] =
|
||||
{
|
||||
1, 3, 5, 6
|
||||
};
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sam_afecinitialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize and register the ADC driver.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int sam_afec_setup(void)
|
||||
{
|
||||
struct adc_dev_s *adc;
|
||||
int ret;
|
||||
|
||||
/* Call sam_adc_initialize() to get an instance of the ADC interface */
|
||||
|
||||
#ifdef CONFIG_SAMV7_AFEC0
|
||||
adc = sam_afec_initialize(0, g_chanlist0, ADC0_NCHANNELS);
|
||||
if (adc == NULL)
|
||||
{
|
||||
aerr("ERROR: Failed to get ADC1 interface\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Register the ADC driver at "/dev/adc0" */
|
||||
|
||||
ret = adc_register("/dev/adc0", adc);
|
||||
if (ret < 0)
|
||||
{
|
||||
aerr("ERROR: adc_register adc0 failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef CONFIG_SAMV7_AFEC1
|
||||
adc = sam_afec_initialize(1, g_chanlist1, ADC1_NCHANNELS);
|
||||
if (adc == NULL)
|
||||
{
|
||||
aerr("ERROR: Failed to get ADC2 interface\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Register the ADC driver at "/dev/adc1" */
|
||||
|
||||
ret = adc_register("/dev/adc1", adc);
|
||||
if (ret < 0)
|
||||
{
|
||||
aerr("ERROR: adc_register adc1 failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_SAMV7_AFEC */
|
@ -342,6 +342,16 @@ int sam_bringup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SAMV7_AFEC
|
||||
/* Initialize AFEC and register the ADC driver. */
|
||||
|
||||
ret = sam_afec_setup();
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: sam_afec_initialize failed: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SAMV7_DAC0) || defined(CONFIG_SAMV7_DAC1)
|
||||
ret = sam_dacdev_initialize();
|
||||
if (ret < 0)
|
||||
|
@ -450,6 +450,18 @@ void sam_sdram_config(void);
|
||||
int sam_bringup(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sam_afec_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize and register the ADC driver.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SAMV7_AFEC
|
||||
int sam_afec_setup(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sam_dacdev_initialize
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user