mirror of
https://github.com/apache/nuttx.git
synced 2026-10-01 11:26:29 +00:00
stm32: implement comp ioctl and update nucleo-g431kb defconfig
Implement ao_ioctl in stm32_comp_m3m4_v2.c to handle ANIOC_COMP_ENABLE and ANIOC_COMP_DISABLE commands. Also add CONFIG_STM32_COMP_INIT_DISABLED to allow keeping the comparator disabled after driver initialization until explicitly enabled. Update nucleo-g431kb:comp defconfig to enable CONFIG_EXAMPLES_COMP and set default DAC path for comparator ramp verification. Assisted-by: Gemini:gemini-2.5-pro Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
This commit is contained in:
parent
fc9fec46da
commit
e433409fcc
3 changed files with 72 additions and 33 deletions
|
|
@ -4,6 +4,12 @@
|
|||
|
||||
# COMP supported only for M3M4 for now
|
||||
|
||||
config STM32_COMP_INIT_DISABLED
|
||||
bool "Do not enable the comparator at initialization"
|
||||
default n
|
||||
---help---
|
||||
The comparator is kept disabled until ioctl() enable command.
|
||||
|
||||
if STM32_HAVE_IP_COMP_M3M4_V2
|
||||
|
||||
if STM32_COMP1
|
||||
|
|
|
|||
|
|
@ -764,6 +764,7 @@ static int comp_config(struct stm32_comp_s *priv)
|
|||
|
||||
comp_putreg_csr(priv, regval);
|
||||
|
||||
#ifndef CONFIG_STM32_COMP_INIT_DISABLED
|
||||
/* Enable Comparator */
|
||||
|
||||
comp_enable(priv, true);
|
||||
|
|
@ -774,6 +775,7 @@ static int comp_config(struct stm32_comp_s *priv)
|
|||
{
|
||||
comp_lock_set(priv, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
|
@ -918,8 +920,36 @@ static int comp_read(struct comp_dev_s *dev)
|
|||
#ifdef CONFIG_COMP
|
||||
static int comp_ioctl(struct comp_dev_s *dev, int cmd, unsigned long arg)
|
||||
{
|
||||
#warning "Missing logic"
|
||||
return -ENOTTY;
|
||||
FAR struct stm32_comp_s *priv = (FAR struct stm32_comp_s *)dev->ad_priv;
|
||||
int ret = OK;
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case ANIOC_COMP_ENABLE:
|
||||
{
|
||||
/* Enable comparator */
|
||||
|
||||
comp_enable(priv, true);
|
||||
break;
|
||||
}
|
||||
|
||||
case ANIOC_COMP_DISABLE:
|
||||
{
|
||||
/* Disable comparator */
|
||||
|
||||
comp_enable(priv, false);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
aerr("ERROR: Unknown cmd: %d\n", cmd);
|
||||
ret = -ENOTTY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -954,57 +984,57 @@ struct comp_dev_s *stm32_compinitialize(int intf)
|
|||
switch (intf)
|
||||
{
|
||||
#ifdef CONFIG_STM32_COMP1
|
||||
case 1:
|
||||
ainfo("COMP1 selected\n");
|
||||
dev = &g_comp1dev;
|
||||
break;
|
||||
case 1:
|
||||
ainfo("COMP1 selected\n");
|
||||
dev = &g_comp1dev;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_COMP2
|
||||
case 2:
|
||||
ainfo("COMP2 selected\n");
|
||||
dev = &g_comp2dev;
|
||||
break;
|
||||
case 2:
|
||||
ainfo("COMP2 selected\n");
|
||||
dev = &g_comp2dev;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_COMP3
|
||||
case 3:
|
||||
ainfo("COMP3 selected\n");
|
||||
dev = &g_comp3dev;
|
||||
break;
|
||||
case 3:
|
||||
ainfo("COMP3 selected\n");
|
||||
dev = &g_comp3dev;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_COMP4
|
||||
case 4:
|
||||
ainfo("COMP4 selected\n");
|
||||
dev = &g_comp4dev;
|
||||
break;
|
||||
case 4:
|
||||
ainfo("COMP4 selected\n");
|
||||
dev = &g_comp4dev;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_COMP5
|
||||
case 5:
|
||||
ainfo("COMP5 selected\n");
|
||||
dev = &g_comp5dev;
|
||||
break;
|
||||
case 5:
|
||||
ainfo("COMP5 selected\n");
|
||||
dev = &g_comp5dev;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_COMP6
|
||||
case 6:
|
||||
ainfo("COMP6 selected\n");
|
||||
dev = &g_comp6dev;
|
||||
break;
|
||||
case 6:
|
||||
ainfo("COMP6 selected\n");
|
||||
dev = &g_comp6dev;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_COMP7
|
||||
case 7:
|
||||
ainfo("COMP7 selected\n");
|
||||
dev = &g_comp7dev;
|
||||
break;
|
||||
case 7:
|
||||
ainfo("COMP7 selected\n");
|
||||
dev = &g_comp7dev;
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
aerr("ERROR: No COMP interface defined\n");
|
||||
return NULL;
|
||||
default:
|
||||
aerr("ERROR: No COMP interface defined\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Configure selected comparator */
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ CONFIG_BUILTIN=y
|
|||
CONFIG_COMP=y
|
||||
CONFIG_DAC=y
|
||||
CONFIG_DEFAULT_SMALL=y
|
||||
CONFIG_EXAMPLES_COMP=y
|
||||
CONFIG_EXAMPLES_COMP_DACPATH="/dev/dac5"
|
||||
CONFIG_EXAMPLES_DAC=y
|
||||
CONFIG_EXAMPLES_DAC_DEVPATH="/dev/dac5"
|
||||
CONFIG_FILE_STREAM=y
|
||||
|
|
@ -37,6 +39,7 @@ CONFIG_STM32_COMP2=y
|
|||
CONFIG_STM32_COMP2_HYST=3
|
||||
CONFIG_STM32_COMP2_INM=4
|
||||
CONFIG_STM32_COMP2_OUT=y
|
||||
CONFIG_STM32_COMP_INIT_DISABLED=y
|
||||
CONFIG_STM32_DAC3=y
|
||||
CONFIG_STM32_DAC3CH2=y
|
||||
CONFIG_STM32_DAC3CH2_MODE=3
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue