diff --git a/drivers/Kconfig b/drivers/Kconfig index ec390b98a3b..2641064b9a8 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -108,37 +108,7 @@ menuconfig PWM See include/nuttx/drivers/pwm.h for further PWM driver information. if PWM - -config PWM_PULSECOUNT - bool "PWM Pulse Count Support" - default n - depends on ARCH_HAVE_PWM_PULSECOUNT - ---help--- - Some hardware will support generation of a fixed number of pulses. - This might be used, for example to support a stepper motor. If the - hardware will support a fixed pulse count, then this configuration - should be set to enable the capability. - -config PWM_MULTICHAN - bool "PWM Multiple Output Channel Support" - default n - depends on ARCH_HAVE_PWM_MULTICHAN - depends on !PWM_PULSECOUNT - ---help--- - Enables support for multiple output channels per timer. - -if PWM_MULTICHAN - -config PWM_NCHANNELS - int "Number of Output Channels Per Timer" - default 1 - range 1 6 - ---help--- - Specifies the number of output channels per timer. Each timer - may support fewer output channels than this value. - -endif # PWM_MULTICHAN - +source drivers/pwm/Kconfig endif # PWM config ARCH_HAVE_I2CRESET diff --git a/drivers/Makefile b/drivers/Makefile index fcccabbd0c0..b38157c11fc 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -67,6 +67,7 @@ include eeprom$(DELIM)Make.defs include net$(DELIM)Make.defs include pipes$(DELIM)Make.defs include power$(DELIM)Make.defs +include pwm$(DELIM)Make.defs include sensors$(DELIM)Make.defs include serial$(DELIM)Make.defs include spi$(DELIM)Make.defs @@ -94,11 +95,6 @@ ifeq ($(CONFIG_DRVR_READAHEAD),y) endif endif endif - -ifeq ($(CONFIG_PWM),y) - CSRCS += pwm.c -endif - endif # CONFIG_NFILE_DESCRIPTORS != 0 AOBJS = $(ASRCS:.S=$(OBJEXT)) diff --git a/drivers/README.txt b/drivers/README.txt index efbc10a7d4a..e8fc3efadca 100644 --- a/drivers/README.txt +++ b/drivers/README.txt @@ -18,11 +18,6 @@ dev_null.c, dev_urandom, and dev_zero.c that should be called if you want to register these devices (devnull_register(), devurandom_register(), and devzero_register()). -pwm.c - Provides the "upper half" of a pulse width modulation (PWM) driver. - The "lower half" of the PWM driver is provided by device-specific - logic. See include/nuttx/drivers/pwm.h for usage information. - ramdisk.c Can be used to set up a block of memory or (read-only) FLASH as a block driver that can be mounted as a files system. See @@ -130,6 +125,11 @@ power/ and by placing drivers into reduce power usage modes when the drivers are not active. +pwm/ + Provides the "upper half" of a pulse width modulation (PWM) driver. + The "lower half" of the PWM driver is provided by device-specific + logic. See include/nuttx/drivers/pwm.h for usage information. + sensors/ Drivers for various sensors. A sensor driver differs little from other types of drivers other than they are use to provide measuresments diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig new file mode 100644 index 00000000000..9334bb1b4ad --- /dev/null +++ b/drivers/pwm/Kconfig @@ -0,0 +1,38 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +if PWM + +config PWM_PULSECOUNT + bool "PWM Pulse Count Support" + default n + depends on ARCH_HAVE_PWM_PULSECOUNT + ---help--- + Some hardware will support generation of a fixed number of pulses. + This might be used, for example to support a stepper motor. If the + hardware will support a fixed pulse count, then this configuration + should be set to enable the capability. + +config PWM_MULTICHAN + bool "PWM Multiple Output Channel Support" + default n + depends on ARCH_HAVE_PWM_MULTICHAN + depends on !PWM_PULSECOUNT + ---help--- + Enables support for multiple output channels per timer. + +if PWM_MULTICHAN + +config PWM_NCHANNELS + int "Number of Output Channels Per Timer" + default 1 + range 1 6 + ---help--- + Specifies the number of output channels per timer. Each timer + may support fewer output channels than this value. + +endif # PWM_MULTICHAN + +endif # PWM diff --git a/drivers/pwm/Make.defs b/drivers/pwm/Make.defs new file mode 100644 index 00000000000..94bb77dd6c9 --- /dev/null +++ b/drivers/pwm/Make.defs @@ -0,0 +1,47 @@ +############################################################################ +# drivers/pwm/Make.defs +# +# Copyright (C) 2017 Pinecone Inc. All rights reserved. +# Author: Xiang Xiao +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +# Don't build anything if there is no PWM support + +ifeq ($(CONFIG_PWM),y) + +CSRCS += pwm.c + +# Include PWM device driver build support + +DEPPATH += --dep-path pwm +VPATH += :pwm +CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)drivers$(DELIM)pwm} +endif diff --git a/drivers/pwm.c b/drivers/pwm/pwm.c similarity index 99% rename from drivers/pwm.c rename to drivers/pwm/pwm.c index d91b148bb5e..bb0c15da9e9 100644 --- a/drivers/pwm.c +++ b/drivers/pwm/pwm.c @@ -1,5 +1,5 @@ /**************************************************************************** - * drivers/pwm.c + * drivers/pwm/pwm.c * * Copyright (C) 2011-2013, 2016-2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt