bsp:cvitek: add pinmux for adc
Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
This commit is contained in:
parent
2c85bcb463
commit
d8294de640
|
@ -154,11 +154,45 @@ menu "General Drivers Configuration"
|
||||||
default 32
|
default 32
|
||||||
endif
|
endif
|
||||||
|
|
||||||
config BSP_USING_ADC
|
menuconfig BSP_USING_ADC
|
||||||
bool "Using ADC"
|
bool "Using ADC"
|
||||||
select RT_USING_ADC
|
select RT_USING_ADC
|
||||||
default n
|
default n
|
||||||
|
|
||||||
|
if BSP_USING_ADC
|
||||||
|
config BSP_USING_ADC_ACTIVE
|
||||||
|
bool "Enable ADC Controller in Active Domain"
|
||||||
|
default n
|
||||||
|
|
||||||
|
if BSP_USING_ADC_ACTIVE
|
||||||
|
config BSP_ACTIVE_ADC1_PINNAME
|
||||||
|
string "Pin name for VIN1 in Active Domain"
|
||||||
|
default ""
|
||||||
|
config BSP_ACTIVE_ADC2_PINNAME
|
||||||
|
string "Pin name for VIN2 in Active Domain"
|
||||||
|
default ""
|
||||||
|
config BSP_ACTIVE_ADC3_PINNAME
|
||||||
|
string "Pin name for VIN3 in Active Domain"
|
||||||
|
default ""
|
||||||
|
endif
|
||||||
|
|
||||||
|
config BSP_USING_ADC_NODIE
|
||||||
|
bool "Enable ADC Controller in No-die Domain"
|
||||||
|
default n
|
||||||
|
|
||||||
|
if BSP_USING_ADC_NODIE
|
||||||
|
config BSP_NODIE_ADC1_PINNAME
|
||||||
|
string "Pin name for VIN1 in No-die Domain"
|
||||||
|
default ""
|
||||||
|
config BSP_NODIE_ADC2_PINNAME
|
||||||
|
string "Pin name for VIN2 in No-die Domain"
|
||||||
|
default ""
|
||||||
|
config BSP_NODIE_ADC3_PINNAME
|
||||||
|
string "Pin name for VIN3 in No-die Domain"
|
||||||
|
default ""
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
config BSP_USING_SPI
|
config BSP_USING_SPI
|
||||||
bool "Using SPI"
|
bool "Using SPI"
|
||||||
select RT_USING_SPI
|
select RT_USING_SPI
|
||||||
|
|
|
@ -154,11 +154,45 @@ menu "General Drivers Configuration"
|
||||||
default 49
|
default 49
|
||||||
endif
|
endif
|
||||||
|
|
||||||
config BSP_USING_ADC
|
menuconfig BSP_USING_ADC
|
||||||
bool "Using ADC"
|
bool "Using ADC"
|
||||||
select RT_USING_ADC
|
select RT_USING_ADC
|
||||||
default n
|
default n
|
||||||
|
|
||||||
|
if BSP_USING_ADC
|
||||||
|
config BSP_USING_ADC_ACTIVE
|
||||||
|
bool "Enable ADC Controller in Active Domain"
|
||||||
|
default n
|
||||||
|
|
||||||
|
if BSP_USING_ADC_ACTIVE
|
||||||
|
config BSP_ACTIVE_ADC1_PINNAME
|
||||||
|
string "Pin name for VIN1 in Active Domain"
|
||||||
|
default ""
|
||||||
|
config BSP_ACTIVE_ADC2_PINNAME
|
||||||
|
string "Pin name for VIN2 in Active Domain"
|
||||||
|
default ""
|
||||||
|
config BSP_ACTIVE_ADC3_PINNAME
|
||||||
|
string "Pin name for VIN3 in Active Domain"
|
||||||
|
default ""
|
||||||
|
endif
|
||||||
|
|
||||||
|
config BSP_USING_ADC_NODIE
|
||||||
|
bool "Enable ADC Controller in No-die Domain"
|
||||||
|
default n
|
||||||
|
|
||||||
|
if BSP_USING_ADC_NODIE
|
||||||
|
config BSP_NODIE_ADC1_PINNAME
|
||||||
|
string "Pin name for VIN1 in No-die Domain"
|
||||||
|
default ""
|
||||||
|
config BSP_NODIE_ADC2_PINNAME
|
||||||
|
string "Pin name for VIN2 in No-die Domain"
|
||||||
|
default ""
|
||||||
|
config BSP_NODIE_ADC3_PINNAME
|
||||||
|
string "Pin name for VIN3 in No-die Domain"
|
||||||
|
default ""
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
config BSP_USING_SPI
|
config BSP_USING_SPI
|
||||||
bool "Using SPI"
|
bool "Using SPI"
|
||||||
select RT_USING_SPI
|
select RT_USING_SPI
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <rtthread.h>
|
#include <rtthread.h>
|
||||||
#include <rtdevice.h>
|
#include <rtdevice.h>
|
||||||
#include "drv_adc.h"
|
#include "drv_adc.h"
|
||||||
|
#include "drv_pinmux.h"
|
||||||
|
|
||||||
#define DBG_LEVEL DBG_LOG
|
#define DBG_LEVEL DBG_LOG
|
||||||
#include <rtdbg.h>
|
#include <rtdbg.h>
|
||||||
|
@ -100,10 +101,101 @@ static const struct rt_adc_ops _adc_ops =
|
||||||
.convert = _adc_convert,
|
.convert = _adc_convert,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(BOARD_TYPE_MILKV_DUO) || defined(BOARD_TYPE_MILKV_DUO_SPINOR)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* cv180xb supports
|
||||||
|
* - adc1 & adc2 for active domain
|
||||||
|
* - adc3 for no-die domain
|
||||||
|
*
|
||||||
|
* FIXME: currnet adc driver only support adc1 in active domain
|
||||||
|
*/
|
||||||
|
#ifdef BSP_USING_ADC_ACTIVE
|
||||||
|
static const char *pinname_whitelist_adc1_active[] = {
|
||||||
|
"ADC1",
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
static const char *pinname_whitelist_adc2_active[] = {
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
static const char *pinname_whitelist_adc3_active[] = {
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef BSP_USING_ADC_NODIE
|
||||||
|
static const char *pinname_whitelist_adc1_nodie[] = {
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
static const char *pinname_whitelist_adc2_nodie[] = {
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
static const char *pinname_whitelist_adc3_nodie[] = {
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined(BOARD_TYPE_MILKV_DUO256M) || defined(BOARD_TYPE_MILKV_DUO256M_SPINOR)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* sg2002 supports
|
||||||
|
* - adc1 for active domain
|
||||||
|
* - adc1/adc2/adc3 for no-die domain
|
||||||
|
*
|
||||||
|
* FIXME: currnet adc driver only support adc1 in active domain
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef BSP_USING_ADC_ACTIVE
|
||||||
|
static const char *pinname_whitelist_adc1_active[] = {
|
||||||
|
"ADC1",
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
static const char *pinname_whitelist_adc2_active[] = {
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
static const char *pinname_whitelist_adc3_active[] = {
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef BSP_USING_ADC_NODIE
|
||||||
|
static const char *pinname_whitelist_adc1_nodie[] = {
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
static const char *pinname_whitelist_adc2_nodie[] = {
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
static const char *pinname_whitelist_adc3_nodie[] = {
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
#error "Unsupported board type!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void rt_hw_adc_pinmux_config()
|
||||||
|
{
|
||||||
|
#ifdef BSP_USING_ADC_ACTIVE
|
||||||
|
pinmux_config(BSP_ACTIVE_ADC1_PINNAME, XGPIOB_3, pinname_whitelist_adc1_active);
|
||||||
|
pinmux_config(BSP_ACTIVE_ADC2_PINNAME, XGPIOB_6, pinname_whitelist_adc2_active);
|
||||||
|
/* cv1800b & sg2002 don't support ADC3 either in active domain */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef BSP_USING_ADC_NODIE
|
||||||
|
pinmux_config(BSP_NODIE_ADC1_PINNAME, PWR_GPIO_2, pinname_whitelist_adc1_nodie);
|
||||||
|
pinmux_config(BSP_NODIE_ADC2_PINNAME, PWR_GPIO_1, pinname_whitelist_adc2_nodie);
|
||||||
|
pinmux_config(BSP_NODIE_ADC3_PINNAME, PWR_VBAT_DET, pinname_whitelist_adc3_nodie);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
int rt_hw_adc_init(void)
|
int rt_hw_adc_init(void)
|
||||||
{
|
{
|
||||||
rt_uint8_t i;
|
rt_uint8_t i;
|
||||||
|
|
||||||
|
rt_hw_adc_pinmux_config();
|
||||||
|
|
||||||
for (i = 0; i < sizeof(adc_dev_config) / sizeof(adc_dev_config[0]); i++)
|
for (i = 0; i < sizeof(adc_dev_config) / sizeof(adc_dev_config[0]); i++)
|
||||||
{
|
{
|
||||||
cvi_do_calibration(adc_dev_config[i].base);
|
cvi_do_calibration(adc_dev_config[i].base);
|
||||||
|
|
Loading…
Reference in New Issue