mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
arch/arm64/src/imx9: Flex-IO based PWM driver for imx9
This is a high resolution PWM driver, utilizing one 16-bit Flex-IO timer for generating PWM period and the rest of the timers to generate PWM duty cycles. This means that the period has to be the same for every PWM generated from one FLEXIO block, but this way we can get 16-bit resolution for the PWM signals. For a typical IMX9 HW there are 8 timers for each Flex-IO block, which means that by using this driver one can get 7 PWM outputs from one block. This driver can be later extended to have configuration options to use all 8 channels per flex-io by either using 8+8 -bit timer (less resolution) or by using an external trigger from an LPIT. Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
This commit is contained in:
committed by
Xiang Xiao
parent
87dc54d755
commit
47f37e84ba
@@ -16,16 +16,57 @@ config ARCH_CHIP_IMX93
|
||||
select ARCH_HAVE_MULTICPU
|
||||
select ARMV8A_HAVE_GICv3
|
||||
select ARCH_CORTEX_A55
|
||||
select ARCH_HAVE_PWM_MULTICHAN
|
||||
|
||||
endchoice # i.MX9 Chip Selection
|
||||
|
||||
endmenu # "i.MX9 Chip Selection"
|
||||
|
||||
config IMX9_FLEXIO_PWM
|
||||
bool
|
||||
select PWM_MULTICHAN
|
||||
default n
|
||||
|
||||
menu "i.MX9 Peripheral Selection"
|
||||
config IMX9_UART1
|
||||
bool "UART1"
|
||||
default n
|
||||
select UART1_SERIALDRIVER
|
||||
|
||||
config IMX9_FLEXIO1_PWM
|
||||
depends on PWM
|
||||
bool "Enable FLEXIO1 based PWM generation"
|
||||
select IMX9_FLEXIO_PWM
|
||||
default n
|
||||
|
||||
config IMX9_FLEXIO2_PWM
|
||||
depends on PWM
|
||||
bool "Enable FLEXIO2 based PWM generation"
|
||||
select IMX9_FLEXIO_PWM
|
||||
default n
|
||||
|
||||
config IMX9_FLEXIO1_PWM_NCHANNELS
|
||||
depends on IMX9_FLEXIO1_PWM
|
||||
int "Number of channels for FLEXIO1"
|
||||
default 4
|
||||
range 1 7
|
||||
|
||||
config IMX9_FLEXIO1_PWM_CHANNEL_PINS
|
||||
depends on IMX9_FLEXIO1_PWM
|
||||
hex "FlexIO outputs used for FLEXIO1 timers"
|
||||
default 0x0000000007060504
|
||||
|
||||
config IMX9_FLEXIO2_PWM_NCHANNELS
|
||||
depends on IMX9_FLEXIO2_PWM
|
||||
int "Number of channels for FLEXIO2"
|
||||
default 1
|
||||
range 1 7
|
||||
|
||||
config IMX9_FLEXIO2_PWM_CHANNEL_PINS
|
||||
depends on IMX9_FLEXIO2_PWM
|
||||
hex "FlexIO outputs used for FLEXIO2 timers"
|
||||
default 0x0000000000000000
|
||||
|
||||
endmenu # iMX Peripheral Selection
|
||||
|
||||
config IMX9_GPIO_IRQ
|
||||
|
||||
@@ -34,3 +34,7 @@ endif
|
||||
ifeq ($(CONFIG_IMX9_GPIO_IRQ),y)
|
||||
CHIP_CSRCS += imx9_gpioirq.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_IMX9_FLEXIO_PWM),y)
|
||||
CHIP_CSRCS += imx9_flexio_pwm.c
|
||||
endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,104 @@
|
||||
/****************************************************************************
|
||||
* arch/arm64/src/imx9/imx9_flexio_pwm.h
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_ARM64_SRC_IMX9_IMX9_FLEXIO_PWM_H
|
||||
#define __ARCH_ARM64_SRC_IMX9_IMX9_FLEXIO_PWM_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
/* Check if PWM support for any channel is enabled. */
|
||||
|
||||
#ifdef CONFIG_IMX9_FLEXIO_PWM
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <arch/board/board.h>
|
||||
#include "hardware/imx9_flexio.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PWM_FLEXIO1 = 0,
|
||||
PWM_FLEXIO2 = 1,
|
||||
} flexio_pwm_id_t;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: imx9_flexio_pwm_init
|
||||
*
|
||||
* Description:
|
||||
* Initialize a FLEXIO block for EPWM usage.
|
||||
*
|
||||
* Input Parameters:
|
||||
* pwmid - A number identifying the pwm block.
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, a pointer to the lower half of the PWM driver is
|
||||
* returned. NULL is returned on any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
struct pwm_lowerhalf_s *imx9_flexio_pwm_init(flexio_pwm_id_t pwmid);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* CONFIG_IMX9_FLEXIO_PWM */
|
||||
#endif /* __ARCH_ARM64_SRC_IMX9_IMX9_FLEXIO_PWM_H */
|
||||
Reference in New Issue
Block a user