mirror of
https://github.com/apache/nuttx.git
synced 2026-05-20 12:33:27 +08:00
boards/arm/stm32/nucleo-f446re: added support for DAC driver
Signed-off-by: Michal Lenc <michallenc@seznam.cz>
This commit is contained in:
@@ -559,6 +559,14 @@ Configurations
|
||||
Functionality of CAN driver can be tested by calling application
|
||||
"can" in NuttShell. This application sends 100 messages over CAN 1.
|
||||
|
||||
dac:
|
||||
----
|
||||
This is an nsh configuration (see above) with added support
|
||||
for digital analog converter driver.
|
||||
|
||||
Functionality of DAC driver can be tested by calling application
|
||||
"dac" in NuttShell. GPIO_DAC1_OUT1 pin is set on PA_4.
|
||||
|
||||
gpio:
|
||||
-----
|
||||
This is an nsh configuration (see above) with added support for GPIO
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
#
|
||||
# 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_FPU is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
# CONFIG_NSH_CMDPARMS is not set
|
||||
# CONFIG_NSH_DISABLE_IFCONFIG is not set
|
||||
# CONFIG_NSH_DISABLE_PS is not set
|
||||
# CONFIG_STM32_FLASH_PREFETCH is not set
|
||||
CONFIG_ANALOG=y
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="nucleo-f446re"
|
||||
CONFIG_ARCH_BOARD_NUCLEO_F446RE=y
|
||||
CONFIG_ARCH_BUTTONS=y
|
||||
CONFIG_ARCH_CHIP="stm32"
|
||||
CONFIG_ARCH_CHIP_STM32=y
|
||||
CONFIG_ARCH_CHIP_STM32F446R=y
|
||||
CONFIG_ARCH_INTERRUPTSTACK=2048
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_BOARD_LATE_INITIALIZE=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=8499
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DAC=y
|
||||
CONFIG_EXAMPLES_DAC=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_RAM_SIZE=131072
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_SPI=y
|
||||
CONFIG_START_DAY=14
|
||||
CONFIG_START_MONTH=10
|
||||
CONFIG_START_YEAR=2014
|
||||
CONFIG_STM32_CRC=y
|
||||
CONFIG_STM32_DAC1=y
|
||||
CONFIG_STM32_DAC1CH1=y
|
||||
CONFIG_STM32_JTAG_SW_ENABLE=y
|
||||
CONFIG_STM32_OTGFS=y
|
||||
CONFIG_STM32_PWR=y
|
||||
CONFIG_STM32_USART2=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_TASK_NAME_SIZE=0
|
||||
CONFIG_TESTING_OSTEST=y
|
||||
CONFIG_USART2_SERIAL_CONSOLE=y
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
@@ -57,6 +57,10 @@ ifeq ($(CONFIG_DEV_GPIO),y)
|
||||
CSRCS += stm32_gpio.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_DAC),y)
|
||||
CSRCS += stm32_dac.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_LIB_BOARDCTL),y)
|
||||
CSRCS += stm32_appinit.c
|
||||
endif
|
||||
|
||||
@@ -373,4 +373,22 @@ int stm32_pwm_setup(void);
|
||||
int stm32_gpio_initialize(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_dac_setup
|
||||
*
|
||||
* Description:
|
||||
* Initialize and register the DAC0 of the microcontroller.
|
||||
*
|
||||
* Input parameters:
|
||||
* devpath - The full path to the driver to register. E.g., "/dev/dac0"
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_DAC)
|
||||
int stm32_dac_setup(void);
|
||||
#endif
|
||||
|
||||
#endif /* __BOARDS_ARM_STM32_NUCLEO_F401RE_SRC_NUCLEO_F446RE_H */
|
||||
|
||||
@@ -202,5 +202,15 @@ int stm32_bringup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DAC
|
||||
/* Initialize DAC and register the DAC driver. */
|
||||
|
||||
ret = stm32_dac_setup();
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to start ADC1: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/stm32/nucleo-f446re/src/stm32_dac.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/analog/dac.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "stm32_dac.h"
|
||||
#include "nucleo-f446re.h"
|
||||
|
||||
#ifdef CONFIG_DAC
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_STM32_DAC1CH1
|
||||
static struct dac_dev_s *g_dac1;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_DAC1CH2
|
||||
static struct dac_dev_s *g_dac2;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_dac_setup
|
||||
*
|
||||
* Description:
|
||||
* Initialize and register the DAC driver.
|
||||
*
|
||||
* Input parameters:
|
||||
* devpath - The full path to the driver to register. E.g., "/dev/dac0"
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32_dac_setup(void)
|
||||
{
|
||||
int ret;
|
||||
#ifdef CONFIG_STM32_DAC1CH1
|
||||
g_dac1 = stm32_dacinitialize(1);
|
||||
if (g_dac1 == NULL)
|
||||
{
|
||||
aerr("ERROR: Failed to get DAC interface\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Register the DAC driver at "/dev/dac0" */
|
||||
|
||||
ret = dac_register("/dev/dac0", g_dac1);
|
||||
if (ret < 0)
|
||||
{
|
||||
aerr("ERROR: dac_register() failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef CONFIG_STM32_DAC1CH2
|
||||
g_dac2 = stm32_dacinitialize(2);
|
||||
if (g_dac2 == NULL)
|
||||
{
|
||||
aerr("ERROR: Failed to get DAC interface\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Register the DAC driver at "/dev/dac1" */
|
||||
|
||||
ret = dac_register("/dev/dac1", g_dac2);
|
||||
if (ret < 0)
|
||||
{
|
||||
aerr("ERROR: dac_register() failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
UNUSED(ret);
|
||||
return OK;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_DAC */
|
||||
Reference in New Issue
Block a user