nucleo-g431rb: add CORDIC example
This commit is contained in:
parent
f9937b28cc
commit
68a345e248
5 changed files with 167 additions and 0 deletions
54
boards/arm/stm32/nucleo-g431rb/configs/cordic/defconfig
Normal file
54
boards/arm/stm32/nucleo-g431rb/configs/cordic/defconfig
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
#
|
||||
# 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_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="nucleo-g431rb"
|
||||
CONFIG_ARCH_BOARD_NUCLEO_G431RB=y
|
||||
CONFIG_ARCH_BUTTONS=y
|
||||
CONFIG_ARCH_CHIP="stm32"
|
||||
CONFIG_ARCH_CHIP_STM32=y
|
||||
CONFIG_ARCH_CHIP_STM32G431R=y
|
||||
CONFIG_ARCH_INTERRUPTSTACK=2048
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=8499
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEBUG_FULLOPT=y
|
||||
CONFIG_DEBUG_SYMBOLS=y
|
||||
CONFIG_EXAMPLES_CORDIC=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBC_FLOATINGPOINT=y
|
||||
CONFIG_MATH_CORDIC=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=22528
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_START_DAY=14
|
||||
CONFIG_START_MONTH=10
|
||||
CONFIG_START_YEAR=2014
|
||||
CONFIG_STM32_CORDIC=y
|
||||
CONFIG_STM32_JTAG_SW_ENABLE=y
|
||||
CONFIG_STM32_USART2=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_TASK_NAME_SIZE=0
|
||||
CONFIG_USART2_SERIAL_CONSOLE=y
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
|
|
@ -51,6 +51,10 @@ ifeq ($(CONFIG_BOARD_STM32_IHM16M1),y)
|
|||
CSRCS += stm32_foc_ihm16m1.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_MATH_CORDIC),y)
|
||||
CSRCS += stm32_cordic.c
|
||||
endif
|
||||
|
||||
DEPPATH += --dep-path board
|
||||
VPATH += :board
|
||||
CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board)
|
||||
|
|
|
|||
|
|
@ -143,4 +143,16 @@ int stm32_adc_setup(void);
|
|||
int stm32_foc_setup(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_cordic_setup
|
||||
*
|
||||
* Description:
|
||||
* Initialize CORDIC peripheral for the board.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_MATH_CORDIC
|
||||
int stm32_cordic_setup(void);
|
||||
#endif
|
||||
|
||||
#endif /* __BOARDS_ARM_STM32_NUCLEO_G431RB_SRC_NUCLEO_G431RB_H */
|
||||
|
|
|
|||
|
|
@ -122,6 +122,16 @@ int stm32_bringup(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MATH_CORDIC
|
||||
/* Initialize CORDIC and register the CORDIC driver. */
|
||||
|
||||
ret = stm32_cordic_setup();
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: stm32_cordic_setup failed: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
UNUSED(ret);
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
87
boards/arm/stm32/nucleo-g431rb/src/stm32_cordic.c
Normal file
87
boards/arm/stm32/nucleo-g431rb/src/stm32_cordic.c
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
/****************************************************************************
|
||||
* boards/arm/stm32/nucleo-g431rb/src/stm32_cordic.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/math/cordic.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "stm32_cordic.h"
|
||||
|
||||
#include "nucleo-g431rb.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_cordic_setup
|
||||
*
|
||||
* Description:
|
||||
* Initialize CORDIC and register the CORDIC device.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32_cordic_setup(void)
|
||||
{
|
||||
FAR struct cordic_lowerhalf_s *cordic = NULL;
|
||||
static bool initialized = false;
|
||||
int ret = OK;
|
||||
|
||||
/* Have we already initialized? */
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
/* Call stm32_cordicinitialize() to get an instance of the CORDIC
|
||||
* interface
|
||||
*/
|
||||
|
||||
cordic = stm32_cordicinitialize();
|
||||
if (!cordic)
|
||||
{
|
||||
tmrerr("Failed to get the STM32 CORDIC lower half\n");
|
||||
ret = -ENODEV;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Register the CORDIC driver at "/dev/cordic0" */
|
||||
|
||||
ret = cordic_register("/dev/cordic0", cordic);
|
||||
if (ret < 0)
|
||||
{
|
||||
tmrerr("cordic_register failed: %d\n", ret);
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Now we are initialized */
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
errout:
|
||||
return ret;
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue