boards/arm/samv7/same70-xplained: added PWM support
This commit adds board level support of PWM driver to SAME70-XPLAINED board. The functionality is tested with two new configurations pwm: An example configuration with configured PWM. pysim: This configuration contains support for pysimCoder application and includes ADC and PWM peripherals and Ethernet driver. Signed-off-by: Michal Lenc <michallenc@seznam.cz>
This commit is contained in:
parent
56b3fc0ef9
commit
4236fa926f
@ -1738,3 +1738,17 @@ Configuration sub-directories
|
||||
|
||||
CONFIG_SAMV7_FORMAT_MCUBOOT=y
|
||||
CONFIG_INIT_ENTRYPOINT="mcuboot_confirm_main"
|
||||
|
||||
pysim:
|
||||
This configuration includes support for pysimCoder appliaction (for further
|
||||
information regarding NuttX and pysimCoder please refer to NuttX documentation).
|
||||
|
||||
Following peripherals are included:
|
||||
|
||||
ADC - AFEC0 - channels 0, 6 and 8
|
||||
PWM - PWM0 - channels 0, 1, 2
|
||||
Ethernet - TCP and UPD support
|
||||
|
||||
pwm:
|
||||
This configuration is an example of PWM driver. The multichannel option is set on
|
||||
and PWM is generated on channels 0, 1 and 2 for driver PWM0.
|
||||
|
88
boards/arm/samv7/same70-xplained/configs/pwm/defconfig
Normal file
88
boards/arm/samv7/same70-xplained/configs/pwm/defconfig
Normal file
@ -0,0 +1,88 @@
|
||||
#
|
||||
# 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_RAMFUNCS is not set
|
||||
# CONFIG_MMCSD_MMCSUPPORT is not set
|
||||
# CONFIG_MMCSD_SPI is not set
|
||||
# CONFIG_SAMV7_SDRAMHEAP is not set
|
||||
# CONFIG_SAMV7_UART0 is not set
|
||||
# CONFIG_SAMV7_UART2 is not set
|
||||
# CONFIG_SAMV7_UART4 is not set
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="same70-xplained"
|
||||
CONFIG_ARCH_BOARD_SAME70_XPLAINED=y
|
||||
CONFIG_ARCH_BUTTONS=y
|
||||
CONFIG_ARCH_CHIP="samv7"
|
||||
CONFIG_ARCH_CHIP_SAME70=y
|
||||
CONFIG_ARCH_CHIP_SAME70Q21=y
|
||||
CONFIG_ARCH_CHIP_SAME70Q=y
|
||||
CONFIG_ARCH_CHIP_SAMV7=y
|
||||
CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH=0x200000
|
||||
CONFIG_ARCH_CHIP_SAMV7_MEM_RAM=0x60000
|
||||
CONFIG_ARCH_INTERRUPTSTACK=2048
|
||||
CONFIG_ARCH_IRQBUTTONS=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARMV7M_DCACHE=y
|
||||
CONFIG_ARMV7M_ICACHE=y
|
||||
CONFIG_ARMV7M_LAZYFPU=y
|
||||
CONFIG_AT24XX_ADDR=0x57
|
||||
CONFIG_AT24XX_EXTENDED=y
|
||||
CONFIG_AT24XX_EXTSIZE=160
|
||||
CONFIG_AT24XX_SIZE=2
|
||||
CONFIG_BOARD_LOOPSPERMSEC=51262
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_EXAMPLES_PWM=y
|
||||
CONFIG_EXAMPLES_PWM_DUTYPCT1=30
|
||||
CONFIG_EXAMPLES_PWM_DUTYPCT3=70
|
||||
CONFIG_FAT_LCNAMES=y
|
||||
CONFIG_FAT_LFN=y
|
||||
CONFIG_FS_FAT=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_I2CTOOL_MAXBUS=0
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_MMCSD_MULTIBLOCK_LIMIT=1
|
||||
CONFIG_MMCSD_SDIO=y
|
||||
CONFIG_MTD=y
|
||||
CONFIG_MTD_AT24XX=y
|
||||
CONFIG_MTD_AT25=y
|
||||
CONFIG_MTD_CONFIG=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_PWM=y
|
||||
CONFIG_PWM_MULTICHAN=y
|
||||
CONFIG_PWM_NCHANNELS=3
|
||||
CONFIG_RAM_SIZE=393216
|
||||
CONFIG_RAM_START=0x20400000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SAMV7_GPIOA_IRQ=y
|
||||
CONFIG_SAMV7_GPIOC_IRQ=y
|
||||
CONFIG_SAMV7_GPIO_IRQ=y
|
||||
CONFIG_SAMV7_HSMCI0=y
|
||||
CONFIG_SAMV7_PWM0=y
|
||||
CONFIG_SAMV7_PWM0_CH0=y
|
||||
CONFIG_SAMV7_PWM0_CH1=y
|
||||
CONFIG_SAMV7_PWM0_CH2=y
|
||||
CONFIG_SAMV7_SDRAMC=y
|
||||
CONFIG_SAMV7_SDRAMSIZE=2097152
|
||||
CONFIG_SAMV7_TWIHS0=y
|
||||
CONFIG_SAMV7_USART1=y
|
||||
CONFIG_SAMV7_XDMAC=y
|
||||
CONFIG_SCHED_HPWORK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SDIO_BLOCKSETUP=y
|
||||
CONFIG_START_DAY=10
|
||||
CONFIG_START_MONTH=3
|
||||
CONFIG_START_YEAR=2014
|
||||
CONFIG_SYSTEM_I2CTOOL=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_RAMTEST=y
|
||||
CONFIG_USART1_SERIAL_CONSOLE=y
|
159
boards/arm/samv7/same70-xplained/configs/pysim/defconfig
Normal file
159
boards/arm/samv7/same70-xplained/configs/pysim/defconfig
Normal file
@ -0,0 +1,159 @@
|
||||
#
|
||||
# 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_RAMFUNCS is not set
|
||||
# CONFIG_MMCSD_MMCSUPPORT is not set
|
||||
# CONFIG_MMCSD_SPI is not set
|
||||
# CONFIG_SAMV7_UART0 is not set
|
||||
# CONFIG_SAMV7_UART2 is not set
|
||||
# CONFIG_SAMV7_UART4 is not set
|
||||
CONFIG_ADC=y
|
||||
CONFIG_ANALOG=y
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="same70-xplained"
|
||||
CONFIG_ARCH_BOARD_SAME70_XPLAINED=y
|
||||
CONFIG_ARCH_BUTTONS=y
|
||||
CONFIG_ARCH_CHIP="samv7"
|
||||
CONFIG_ARCH_CHIP_SAME70=y
|
||||
CONFIG_ARCH_CHIP_SAME70Q21=y
|
||||
CONFIG_ARCH_CHIP_SAME70Q=y
|
||||
CONFIG_ARCH_CHIP_SAMV7=y
|
||||
CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH=0x200000
|
||||
CONFIG_ARCH_CHIP_SAMV7_MEM_RAM=0x60000
|
||||
CONFIG_ARCH_INTERRUPTSTACK=2048
|
||||
CONFIG_ARCH_IRQBUTTONS=y
|
||||
CONFIG_ARCH_RAMVECTORS=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARMV7M_DCACHE=y
|
||||
CONFIG_ARMV7M_ICACHE=y
|
||||
CONFIG_ARMV7M_LAZYFPU=y
|
||||
CONFIG_AT24XX_ADDR=0x57
|
||||
CONFIG_AT24XX_EXTENDED=y
|
||||
CONFIG_AT24XX_EXTSIZE=160
|
||||
CONFIG_AT24XX_SIZE=2
|
||||
CONFIG_BOARDCTL_APP_SYMTAB=y
|
||||
CONFIG_BOARDCTL_OS_SYMTAB=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=51262
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_CLOCK_MONOTONIC=y
|
||||
CONFIG_DEFAULT_TASK_STACKSIZE=4096
|
||||
CONFIG_ELF=y
|
||||
CONFIG_ELF_STACKSIZE=2048
|
||||
CONFIG_ETH0_PHY_KSZ8081=y
|
||||
CONFIG_EXAMPLES_ADC=y
|
||||
CONFIG_EXAMPLES_ADC_GROUPSIZE=3
|
||||
CONFIG_EXAMPLES_ADC_NSAMPLES=1000
|
||||
CONFIG_EXAMPLES_PWM=y
|
||||
CONFIG_FAT_LCNAMES=y
|
||||
CONFIG_FAT_LFN=y
|
||||
CONFIG_FS_BINFS=y
|
||||
CONFIG_FS_FAT=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_FS_PROCFS_REGISTER=y
|
||||
CONFIG_FS_ROMFS=y
|
||||
CONFIG_FS_TMPFS=y
|
||||
CONFIG_I2CTOOL_MAXBUS=0
|
||||
CONFIG_IDLETHREAD_STACKSIZE=4096
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INIT_STACKSIZE=2048
|
||||
CONFIG_IOB_NBUFFERS=24
|
||||
CONFIG_LIBC_EXECFUNCS=y
|
||||
CONFIG_LIBC_HOSTNAME="SAME70-Xplained"
|
||||
CONFIG_LIBC_STRERROR=y
|
||||
CONFIG_MMCSD_MULTIBLOCK_LIMIT=1
|
||||
CONFIG_MMCSD_SDIO=y
|
||||
CONFIG_MODULE=y
|
||||
CONFIG_MTD=y
|
||||
CONFIG_MTD_AT24XX=y
|
||||
CONFIG_MTD_AT25=y
|
||||
CONFIG_MTD_CONFIG=y
|
||||
CONFIG_NET=y
|
||||
CONFIG_NETDB_DNSCLIENT=y
|
||||
CONFIG_NETDB_DNSSERVER_NOADDR=y
|
||||
CONFIG_NETDEV_PHY_IOCTL=y
|
||||
CONFIG_NETDEV_STATISTICS=y
|
||||
CONFIG_NETINIT_DHCPC=y
|
||||
CONFIG_NETINIT_MONITOR=y
|
||||
CONFIG_NETINIT_THREAD=y
|
||||
CONFIG_NETINIT_THREAD_STACKSIZE=2048
|
||||
CONFIG_NETUTILS_DHCPC=y
|
||||
CONFIG_NETUTILS_TELNETD=y
|
||||
CONFIG_NETUTILS_TFTPC=y
|
||||
CONFIG_NETUTILS_WEBCLIENT=y
|
||||
CONFIG_NET_ARP_SEND=y
|
||||
CONFIG_NET_BROADCAST=y
|
||||
CONFIG_NET_ICMP=y
|
||||
CONFIG_NET_ICMP_SOCKET=y
|
||||
CONFIG_NET_STATISTICS=y
|
||||
CONFIG_NET_TCP=y
|
||||
CONFIG_NET_TCPBACKLOG=y
|
||||
CONFIG_NET_TCP_WRITE_BUFFERS=y
|
||||
CONFIG_NET_UDP=y
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_FILE_APPS=y
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_NSH_ROMFSETC=y
|
||||
CONFIG_NSH_TELNETD_CLIENTSTACKSIZE=2048
|
||||
CONFIG_NSH_TELNETD_DAEMONSTACKSIZE=2048
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_PSEUDOTERM=y
|
||||
CONFIG_PTHREAD_CLEANUP=y
|
||||
CONFIG_PTHREAD_MUTEX_TYPES=y
|
||||
CONFIG_PTHREAD_STACK_DEFAULT=2048
|
||||
CONFIG_PTHREAD_STACK_MIN=1024
|
||||
CONFIG_PWM=y
|
||||
CONFIG_PWM_MULTICHAN=y
|
||||
CONFIG_PWM_NCHANNELS=3
|
||||
CONFIG_RAM_SIZE=393216
|
||||
CONFIG_RAM_START=0x20400000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_READLINE_CMD_HISTORY=y
|
||||
CONFIG_RR_INTERVAL=10
|
||||
CONFIG_SAMV7_AFEC0=y
|
||||
CONFIG_SAMV7_AFEC_DMA=y
|
||||
CONFIG_SAMV7_AFEC_DMASAMPLES=10
|
||||
CONFIG_SAMV7_EMAC0=y
|
||||
CONFIG_SAMV7_EMAC0_PHYSR=30
|
||||
CONFIG_SAMV7_EMAC0_PHYSR_100FD=0x6
|
||||
CONFIG_SAMV7_EMAC0_PHYSR_100HD=0x2
|
||||
CONFIG_SAMV7_EMAC0_PHYSR_10FD=0x5
|
||||
CONFIG_SAMV7_EMAC0_PHYSR_10HD=0x1
|
||||
CONFIG_SAMV7_EMAC0_PHYSR_ALTCONFIG=y
|
||||
CONFIG_SAMV7_EMAC0_PHYSR_ALTMODE=0x7
|
||||
CONFIG_SAMV7_EMAC0_RMII=y
|
||||
CONFIG_SAMV7_GPIOA_IRQ=y
|
||||
CONFIG_SAMV7_GPIOC_IRQ=y
|
||||
CONFIG_SAMV7_GPIO_IRQ=y
|
||||
CONFIG_SAMV7_HSMCI0=y
|
||||
CONFIG_SAMV7_PWM0=y
|
||||
CONFIG_SAMV7_PWM0_CH0=y
|
||||
CONFIG_SAMV7_PWM0_CH1=y
|
||||
CONFIG_SAMV7_PWM0_CH2=y
|
||||
CONFIG_SAMV7_TC0=y
|
||||
CONFIG_SAMV7_TC0_TIOA0=y
|
||||
CONFIG_SAMV7_TWIHS0=y
|
||||
CONFIG_SAMV7_USART1=y
|
||||
CONFIG_SAMV7_XDMAC=y
|
||||
CONFIG_SCHED_HPWORK=y
|
||||
CONFIG_SCHED_HPWORKSTACKSIZE=2048
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SDIO_BLOCKSETUP=y
|
||||
CONFIG_START_DAY=10
|
||||
CONFIG_START_MONTH=3
|
||||
CONFIG_START_YEAR=2014
|
||||
CONFIG_SYMTAB_ORDEREDBYNAME=y
|
||||
CONFIG_SYSTEM_I2CTOOL=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_NSH_STACKSIZE=2048
|
||||
CONFIG_SYSTEM_PING=y
|
||||
CONFIG_SYSTEM_PING_STACKSIZE=2048
|
||||
CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=2048
|
||||
CONFIG_USART1_SERIAL_CONSOLE=y
|
||||
CONFIG_USEC_PER_TICK=1000
|
@ -340,6 +340,12 @@
|
||||
#define GPIO_MCAN1_TX GPIO_MCAN1_TX_2
|
||||
#define GPIO_MCAN1_RX GPIO_MCAN1_RX_2
|
||||
|
||||
/* PWM */
|
||||
|
||||
#define GPIO_PWMC0_H0 GPIO_PWMC0_H0_1 /* PA_0 */
|
||||
#define GPIO_PWMC0_H1 GPIO_PWMC0_H1_1 /* PA_2 */
|
||||
#define GPIO_PWMC0_H2 GPIO_PWMC0_H2_5 /* PC_19 */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
@ -50,6 +50,10 @@ ifeq ($(CONFIG_SAMV7_USBDEVHS),y)
|
||||
CSRCS += sam_usbdev.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SAMV7_PWM),y)
|
||||
CSRCS += sam_pwm.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SAMV7_SPI),y)
|
||||
CSRCS += sam_spi.c
|
||||
endif
|
||||
|
@ -316,6 +316,16 @@ int sam_bringup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SAMV7_PWM
|
||||
/* Initialize PWM and register the driver. */
|
||||
|
||||
ret = sam_pwm_setup();
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: sam_afec_initialize failed: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SAMV7_AFEC
|
||||
/* Initialize AFEC and register the ADC driver. */
|
||||
|
||||
|
111
boards/arm/samv7/same70-xplained/src/sam_pwm.c
Normal file
111
boards/arm/samv7/same70-xplained/src/sam_pwm.c
Normal file
@ -0,0 +1,111 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/samv7/same70-xplained/src/sam_pwm.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 <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/timers/pwm.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "sam_pwm.h"
|
||||
#include "same70-xplained.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
#ifdef CONFIG_PWM
|
||||
|
||||
extern struct pwm_lowerhalf_s *sam_pwminitialize(int pwm);
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sam_pwm_setup
|
||||
*
|
||||
* Description:
|
||||
* Initialize PWM and register the PWM device.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int sam_pwm_setup(void)
|
||||
{
|
||||
struct pwm_lowerhalf_s *pwm;
|
||||
int ret;
|
||||
|
||||
#ifdef CONFIG_SAMV7_PWM0
|
||||
/* Call sam_pwminitialize() to get an instance of the PWM interface */
|
||||
|
||||
pwm = sam_pwminitialize(0);
|
||||
if (!pwm)
|
||||
{
|
||||
aerr("ERROR: Failed to get the SAM PWM lower half\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Register the PWM driver at "/dev/pwm0" */
|
||||
|
||||
ret = pwm_register("/dev/pwm0", pwm);
|
||||
if (ret < 0)
|
||||
{
|
||||
aerr("ERROR: pwm_register failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef CONFIG_SAMV7_PWM1
|
||||
/* Call sam_pwminitialize() to get an instance of the PWM interface */
|
||||
|
||||
pwm = sam_pwminitialize(1);
|
||||
if (!pwm)
|
||||
{
|
||||
aerr("ERROR: Failed to get the SAM PWM lower half\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Register the PWM driver at "/dev/pwm1" */
|
||||
|
||||
ret = pwm_register("/dev/pwm1", pwm);
|
||||
if (ret < 0)
|
||||
{
|
||||
aerr("ERROR: pwm_register failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
UNUSED(ret);
|
||||
return OK;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_PWM */
|
@ -436,6 +436,18 @@ int sam_bringup(void);
|
||||
int sam_afec_setup(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sam_pwm_setup
|
||||
*
|
||||
* Description:
|
||||
* Initialize PWM and register the PWM device.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SAMV7_PWM
|
||||
int sam_pwm_setup(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sam_dacdev_initialize
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user