ox64: Add adc example config

This commit is contained in:
Henry Rovner 2024-07-04 14:26:35 -07:00 committed by Xiang Xiao
parent a16956e128
commit a83e7ced77
3 changed files with 143 additions and 5 deletions

View File

@ -43,6 +43,7 @@
#include "riscv_internal.h" #include "riscv_internal.h"
#include "chip.h" #include "chip.h"
#include "bl808_gpadc.h" #include "bl808_gpadc.h"
#include "bl808_gpio.h"
#ifdef CONFIG_BL808_GPADC #ifdef CONFIG_BL808_GPADC
@ -161,6 +162,22 @@ static struct adc_ops_s gpadc_ops =
.ao_ioctl = bl808_gpadc_ioctl .ao_ioctl = bl808_gpadc_ioctl
}; };
static uint8_t ch_to_gpio_map[12] =
{
[0] = 17,
[1] = 5,
[2] = 4,
[3] = 11,
[4] = 6,
[5] = 40,
[6] = 12,
[7] = 13,
[8] = 16,
[9] = 18,
[10] = 19,
[11] = 34
};
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
@ -339,17 +356,27 @@ static int bl808_gpadc_setup(struct adc_dev_s *dev)
channel_idx < priv->nchannels; channel_idx < priv->nchannels;
channel_idx++) channel_idx++)
{ {
uint8_t channel = priv->enabled_channels[channel_idx];
/* If enabling an external channel, configure GPIO */
if (channel < 12)
{
int pin = ch_to_gpio_map[channel];
bl808_configgpio(pin, GPIO_INPUT
| GPIO_FLOAT
| GPIO_FUNC_ANA);
}
if (channel_idx < 6) if (channel_idx < 6)
{ {
modifyreg32(BL808_GPADC_SCAN_POS1, 0, modifyreg32(BL808_GPADC_SCAN_POS1, 0,
(priv->enabled_channels[channel_idx] (channel << GPADC_SCAN_SHIFT(channel_idx)));
<< GPADC_SCAN_SHIFT(channel_idx)));
} }
else else
{ {
modifyreg32(BL808_GPADC_SCAN_POS2, 0, modifyreg32(BL808_GPADC_SCAN_POS2, 0,
(priv->enabled_channels[channel_idx] (channel << GPADC_SCAN_SHIFT(channel_idx)));
<< GPADC_SCAN_SHIFT(channel_idx)));
} }
} }

View File

@ -37,7 +37,6 @@
#include "bl808_mm_init.h" #include "bl808_mm_init.h"
#include "bl808_memorymap.h" #include "bl808_memorymap.h"
#include "bl808_serial.h" #include "bl808_serial.h"
#include "bl808_gpadc.h"
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions

View File

@ -0,0 +1,112 @@
#
# 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_DISABLE_OS_API is not set
# CONFIG_NSH_DISABLE_LOSMART is not set
# CONFIG_STANDARD_SERIAL is not set
CONFIG_ADC=y
CONFIG_ANALOG=y
CONFIG_ARCH="risc-v"
CONFIG_ARCH_ADDRENV=y
CONFIG_ARCH_BOARD="ox64"
CONFIG_ARCH_BOARD_BL808_OX64=y
CONFIG_ARCH_CHIP="bl808"
CONFIG_ARCH_CHIP_BL808=y
CONFIG_ARCH_DATA_NPAGES=128
CONFIG_ARCH_DATA_VBASE=0x80100000
CONFIG_ARCH_HEAP_NPAGES=128
CONFIG_ARCH_HEAP_VBASE=0x80200000
CONFIG_ARCH_INTERRUPTSTACK=2048
CONFIG_ARCH_KERNEL_STACKSIZE=3072
CONFIG_ARCH_PGPOOL_MAPPING=y
CONFIG_ARCH_PGPOOL_PBASE=0x50600000
CONFIG_ARCH_PGPOOL_SIZE=4194304
CONFIG_ARCH_PGPOOL_VBASE=0x50600000
CONFIG_ARCH_RISCV=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH_TEXT_NPAGES=128
CONFIG_ARCH_TEXT_VBASE=0x80000000
CONFIG_ARCH_USE_MMU=y
CONFIG_ARCH_USE_MPU=y
CONFIG_ARCH_USE_S_MODE=y
CONFIG_BL808_GPADC=y
CONFIG_BL808_GPADC_NCHANNELS=5
CONFIG_BL808_GPADC_RES_16=y
CONFIG_BL808_GPADC_SCAN_ORD0=3
CONFIG_BL808_GPADC_SCAN_ORD1=4
CONFIG_BL808_GPADC_SCAN_ORD2=6
CONFIG_BL808_GPADC_SCAN_ORD3=7
CONFIG_BL808_GPADC_SCAN_ORD4=9
CONFIG_BL808_UART0=y
CONFIG_BL808_UART1=y
CONFIG_BL808_UART2=y
CONFIG_BL808_UART3=y
CONFIG_BOARDCTL_ROMDISK=y
CONFIG_BOARD_LATE_INITIALIZE=y
CONFIG_BOARD_LOOPSPERMSEC=1120
CONFIG_BUILD_KERNEL=y
CONFIG_DEBUG_ASSERTIONS=y
CONFIG_DEBUG_ASSERTIONS_EXPRESSION=y
CONFIG_DEBUG_FEATURES=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEV_ZERO=y
CONFIG_ELF=y
CONFIG_EXAMPLES_ADC=y
CONFIG_EXAMPLES_ADC_DEVPATH="/dev/gpadc"
CONFIG_EXAMPLES_ADC_GROUPSIZE=5
CONFIG_EXAMPLES_ADC_NSAMPLES=1
CONFIG_EXAMPLES_HELLO=m
CONFIG_FS_PROCFS=y
CONFIG_FS_ROMFS=y
CONFIG_IDLETHREAD_STACKSIZE=3072
CONFIG_INIT_FILEPATH="/system/bin/init"
CONFIG_INIT_MOUNT=y
CONFIG_INIT_MOUNT_FLAGS=0x1
CONFIG_INIT_MOUNT_TARGET="/system/bin"
CONFIG_INIT_STACKSIZE=3072
CONFIG_INTELHEX_BINARY=y
CONFIG_LIBC_ENVPATH=y
CONFIG_LIBC_EXECFUNCS=y
CONFIG_LIBC_PERROR_STDOUT=y
CONFIG_LIBC_STRERROR=y
CONFIG_MEMSET_64BIT=y
CONFIG_MEMSET_OPTSPEED=y
CONFIG_MM_PGALLOC=y
CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_FILE_APPS=y
CONFIG_NSH_READLINE=y
CONFIG_PATH_INITIAL="/system/bin"
CONFIG_RAM_SIZE=1048576
CONFIG_RAM_START=0x50200000
CONFIG_READLINE_CMD_HISTORY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_HAVE_PARENT=y
CONFIG_SCHED_LPWORK=y
CONFIG_SCHED_WAITPID=y
CONFIG_STACK_COLORATION=y
CONFIG_START_MONTH=12
CONFIG_START_YEAR=2021
CONFIG_SYMTAB_ORDEREDBYNAME=y
CONFIG_SYSTEM_NSH=y
CONFIG_SYSTEM_NSH_PROGNAME="init"
CONFIG_TESTING_GETPRIME=y
CONFIG_TESTING_OSTEST=y
CONFIG_UART0_BAUD=2000000
CONFIG_UART0_BITS=7
CONFIG_UART1_BAUD=2000000
CONFIG_UART1_BITS=7
CONFIG_UART2_BAUD=2000000
CONFIG_UART2_BITS=7
CONFIG_UART3_BAUD=2000000
CONFIG_UART3_BITS=7
CONFIG_UART3_SERIAL_CONSOLE=y
CONFIG_USEC_PER_TICK=1000
CONFIG_USERLED=y
CONFIG_USERLED_LOWER=y