mirror of
https://github.com/apache/nuttx.git
synced 2026-05-25 09:45:55 +08:00
mcx-nxxx: Add LPI2C driver for mcx-nxxx architecture
This adds a LPI2C driver for the mcx-nxxx chip, and the necessary board definitions for the frdm-mcxn236 evaluation kit. Signed-off-by: Ville Juven <ville.juven@unikie.com>
This commit is contained in:
@@ -26,6 +26,10 @@ config NXXX_GPIO_IRQ
|
||||
bool "GPIO Interrupt Support"
|
||||
default y
|
||||
|
||||
config NXXX_LPI2C
|
||||
bool "LPI2C support"
|
||||
default n
|
||||
|
||||
menu "LPUART"
|
||||
|
||||
config NXXX_LPUART
|
||||
@@ -117,6 +121,252 @@ endmenu # LPUART Configuration
|
||||
|
||||
endmenu # LPUART
|
||||
|
||||
menu "LPI2C Peripherals"
|
||||
|
||||
menuconfig NXXX_LPI2C0
|
||||
bool "LPI2C0"
|
||||
default n
|
||||
select NXXX_LPI2C
|
||||
|
||||
if NXXX_LPI2C0
|
||||
|
||||
config NXXX_LPI2C0_BUSYIDLE
|
||||
int "Bus idle timeout period in clock cycles"
|
||||
default 0
|
||||
|
||||
config NXXX_LPI2C0_FILTSCL
|
||||
int "I2C master digital glitch filters for SCL input in clock cycles"
|
||||
default 0
|
||||
|
||||
config NXXX_LPI2C0_FILTSDA
|
||||
int "I2C master digital glitch filters for SDA input in clock cycles"
|
||||
default 0
|
||||
|
||||
endif # NXXX_LPI2C0
|
||||
|
||||
menuconfig NXXX_LPI2C1
|
||||
bool "LPI2C1"
|
||||
default n
|
||||
select NXXX_LPI2C
|
||||
|
||||
if NXXX_LPI2C1
|
||||
|
||||
config NXXX_LPI2C1_BUSYIDLE
|
||||
int "Bus idle timeout period in clock cycles"
|
||||
default 0
|
||||
|
||||
config NXXX_LPI2C1_DMA
|
||||
bool "Enable DMA for I2C1"
|
||||
default n
|
||||
depends on NXXX_LPI2C_DMA
|
||||
|
||||
config NXXX_LPI2C1_FILTSCL
|
||||
int "I2C master digital glitch filters for SCL input in clock cycles"
|
||||
default 0
|
||||
|
||||
config NXXX_LPI2C1_FILTSDA
|
||||
int "I2C master digital glitch filters for SDA input in clock cycles"
|
||||
default 0
|
||||
|
||||
endif # NXXX_LPI2C1
|
||||
|
||||
menuconfig NXXX_LPI2C2
|
||||
bool "LPI2C2"
|
||||
default n
|
||||
select NXXX_LPI2C
|
||||
|
||||
if NXXX_LPI2C2
|
||||
|
||||
config NXXX_LPI2C2_BUSYIDLE
|
||||
int "Bus idle timeout period in clock cycles"
|
||||
default 0
|
||||
|
||||
config NXXX_LPI2C2_DMA
|
||||
bool "Enable DMA for I2C2"
|
||||
default n
|
||||
depends on NXXX_LPI2C_DMA
|
||||
|
||||
config NXXX_LPI2C2_FILTSCL
|
||||
int "I2C master digital glitch filters for SCL input in clock cycles"
|
||||
default 0
|
||||
|
||||
config NXXX_LPI2C2_FILTSDA
|
||||
int "I2C master digital glitch filters for SDA input in clock cycles"
|
||||
default 0
|
||||
|
||||
endif # NXXX_LPI2C2
|
||||
|
||||
menuconfig NXXX_LPI2C3
|
||||
bool "LPI2C3"
|
||||
default n
|
||||
select NXXX_LPI2C
|
||||
|
||||
if NXXX_LPI2C3
|
||||
|
||||
config NXXX_LPI2C3_BUSYIDLE
|
||||
int "Bus idle timeout period in clock cycles"
|
||||
default 0
|
||||
|
||||
config NXXX_LPI2C3_DMA
|
||||
bool "Enable DMA for I2C3"
|
||||
default n
|
||||
depends on NXXX_LPI2C_DMA
|
||||
|
||||
config NXXX_LPI2C3_FILTSCL
|
||||
int "I2C master digital glitch filters for SCL input in clock cycles"
|
||||
default 0
|
||||
|
||||
config NXXX_LPI2C3_FILTSDA
|
||||
int "I2C master digital glitch filters for SDA input in clock cycles"
|
||||
default 0
|
||||
|
||||
endif # NXXX_LPI2C3
|
||||
|
||||
menuconfig NXXX_LPI2C4
|
||||
bool "LPI2C4"
|
||||
default n
|
||||
select NXXX_LPI2C
|
||||
|
||||
if NXXX_LPI2C4
|
||||
|
||||
config NXXX_LPI2C4_BUSYIDLE
|
||||
int "Bus idle timeout period in clock cycles"
|
||||
default 0
|
||||
|
||||
config NXXX_LPI2C4_DMA
|
||||
bool "Enable DMA for I2C4"
|
||||
default n
|
||||
depends on NXXX_LPI2C_DMA
|
||||
|
||||
config NXXX_LPI2C4_FILTSCL
|
||||
int "I2C master digital glitch filters for SCL input in clock cycles"
|
||||
default 0
|
||||
|
||||
config NXXX_LPI2C4_FILTSDA
|
||||
int "I2C master digital glitch filters for SDA input in clock cycles"
|
||||
default 0
|
||||
|
||||
endif # NXXX_LPI2C4
|
||||
|
||||
menuconfig NXXX_LPI2C5
|
||||
bool "LPI2C5"
|
||||
default n
|
||||
select NXXX_LPI2C
|
||||
|
||||
if NXXX_LPI2C5
|
||||
|
||||
config NXXX_LPI2C5_BUSYIDLE
|
||||
int "Bus idle timeout period in clock cycles"
|
||||
default 0
|
||||
|
||||
config NXXX_LPI2C5_FILTSCL
|
||||
int "I2C master digital glitch filters for SCL input in clock cycles"
|
||||
default 0
|
||||
|
||||
config NXXX_LPI2C5_FILTSDA
|
||||
int "I2C master digital glitch filters for SDA input in clock cycles"
|
||||
default 0
|
||||
|
||||
endif # NXXX_LPI2C5
|
||||
|
||||
menuconfig NXXX_LPI2C6
|
||||
bool "LPI2C6"
|
||||
default n
|
||||
select NXXX_LPI2C
|
||||
|
||||
if NXXX_LPI2C6
|
||||
|
||||
config NXXX_LPI2C6_BUSYIDLE
|
||||
int "Bus idle timeout period in clock cycles"
|
||||
default 0
|
||||
|
||||
config NXXX_LPI2C6_FILTSCL
|
||||
int "I2C master digital glitch filters for SCL input in clock cycles"
|
||||
default 0
|
||||
|
||||
config NXXX_LPI2C6_FILTSDA
|
||||
int "I2C master digital glitch filters for SDA input in clock cycles"
|
||||
default 0
|
||||
|
||||
endif # NXXX_LPI2C6
|
||||
|
||||
menuconfig NXXX_LPI2C7
|
||||
bool "LPI2C7"
|
||||
default n
|
||||
select NXXX_LPI2C
|
||||
|
||||
if NXXX_LPI2C7
|
||||
|
||||
config NXXX_LPI2C7_BUSYIDLE
|
||||
int "Bus idle timeout period in clock cycles"
|
||||
default 0
|
||||
|
||||
config NXXX_LPI2C7_FILTSCL
|
||||
int "I2C master digital glitch filters for SCL input in clock cycles"
|
||||
default 0
|
||||
|
||||
config NXXX_LPI2C7_FILTSDA
|
||||
int "I2C master digital glitch filters for SDA input in clock cycles"
|
||||
default 0
|
||||
|
||||
endif # NXXX_LPI2C7
|
||||
|
||||
endmenu # LPI2C Peripherals
|
||||
|
||||
menu "LPI2C Configuration"
|
||||
depends on NXXX_LPI2C
|
||||
|
||||
config NXXX_LPI2C_DMA
|
||||
bool "I2C DMA Support"
|
||||
default n
|
||||
depends on NXXX_LPI2C && NXXX_EDMA && !I2C_POLLED
|
||||
---help---
|
||||
This option enables the DMA for I2C transfers.
|
||||
Note: The user can define CONFIG_I2C_DMAPRIO: a custom priority value
|
||||
for the I2C dma streams, else the default priority level is set to
|
||||
medium.
|
||||
|
||||
config NXXX_LPI2C_DMA_MAXMSG
|
||||
int "Maximum number messages that will be DMAed"
|
||||
default 8
|
||||
depends on NXXX_LPI2C_DMA
|
||||
---help---
|
||||
This option sets the number of mesg that can be in a transfer.
|
||||
It is used to allocate space for the 16 bit LPI2C commands
|
||||
that will be DMA-ed to the LPI2C device.
|
||||
|
||||
config NXXX_LPI2C_DYNTIMEO
|
||||
bool "Use dynamic timeouts"
|
||||
default n
|
||||
depends on NXXX_LPI2C
|
||||
|
||||
config NXXX_LPI2C_DYNTIMEO_USECPERBYTE
|
||||
int "Timeout Microseconds per Byte"
|
||||
default 500
|
||||
depends on NXXX_LPI2C_DYNTIMEO
|
||||
|
||||
config NXXX_LPI2C_DYNTIMEO_STARTSTOP
|
||||
int "Timeout for Start/Stop (Milliseconds)"
|
||||
default 1000
|
||||
depends on NXXX_LPI2C_DYNTIMEO
|
||||
|
||||
config NXXX_LPI2C_TIMEOSEC
|
||||
int "Timeout seconds"
|
||||
default 0
|
||||
depends on NXXX_LPI2C
|
||||
|
||||
config NXXX_LPI2C_TIMEOMS
|
||||
int "Timeout Milliseconds"
|
||||
default 500
|
||||
depends on NXXX_LPI2C && !NXXX_LPI2C_DYNTIMEO
|
||||
|
||||
config NXXX_LPI2C_TIMEOTICKS
|
||||
int "Timeout for Done and Stop (ticks)"
|
||||
default 500
|
||||
depends on NXXX_LPI2C && !NXXX_LPI2C_DYNTIMEO
|
||||
|
||||
endmenu # LPI2C Configuration
|
||||
|
||||
endmenu # NXXX Peripheral Selection
|
||||
|
||||
endif # ARCH_CHIP_NXXX
|
||||
|
||||
@@ -34,3 +34,7 @@ endif
|
||||
ifeq ($(CONFIG_NXXX_GPIO_IRQ),y)
|
||||
CHIP_CSRCS += nxxx_gpioirq.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NXXX_LPI2C),y)
|
||||
CHIP_CSRCS += nxxx_lpi2c.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,73 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/mcx-nxxx/nxxx_lpi2c.h
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* 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_ARM_SRC_MCX_NXXX_NXXX_LPI2C_H
|
||||
#define __ARCH_ARM_SRC_MCX_NXXX_NXXX_LPI2C_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/i2c/i2c_master.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxxx_i2cbus_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the selected I2C port. And return a unique instance of struct
|
||||
* struct i2c_master_s. This function may be called to obtain multiple
|
||||
* instances of the interface, each of which may be set up with a
|
||||
* different frequency and slave address.
|
||||
*
|
||||
* Input Parameters:
|
||||
* Port number (for hardware that has multiple I2C interfaces)
|
||||
*
|
||||
* Returned Value:
|
||||
* Valid I2C device structure reference on success; a NULL on failure
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
struct i2c_master_s *nxxx_i2cbus_initialize(int port);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxxx_i2cbus_uninitialize
|
||||
*
|
||||
* Description:
|
||||
* De-initialize the selected I2C port, and power down the device.
|
||||
*
|
||||
* Input Parameters:
|
||||
* Device structure as returned by the nxxx_i2cbus_initialize()
|
||||
*
|
||||
* Returned Value:
|
||||
* OK on success, ERROR when internal reference count mismatch or dev
|
||||
* points to invalid hardware device.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nxxx_i2cbus_uninitialize(struct i2c_master_s *dev);
|
||||
|
||||
#endif /* __ARCH_ARM_SRC_MCX_NXXX_LPI2C_H */
|
||||
@@ -31,6 +31,7 @@ CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBC_LOCALTIME=y
|
||||
CONFIG_LPUART4_SERIAL_CONSOLE=y
|
||||
CONFIG_NXXX_LPUART4=y
|
||||
CONFIG_NXXX_LPI2C0=y
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_DISABLE_IFUPDOWN=y
|
||||
|
||||
@@ -36,6 +36,9 @@
|
||||
#define PORT_LPUART4_RX PORT_CFG(1, 8, PORT_PCR_MUX_ALT2 | PORT_PCR_IBE)
|
||||
#define PORT_LPUART4_TX PORT_CFG(1, 9, PORT_PCR_MUX_ALT2 | PORT_PCR_IBE)
|
||||
|
||||
#define PORT_LPI2C0_SCL PORT_CFG(4, 1, PORT_PCR_MUX_ALT2 | PORT_PCR_IBE)
|
||||
#define PORT_LPI2C0_SDA PORT_CFG(4, 0, PORT_PCR_MUX_ALT2 | PORT_PCR_IBE)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user