I2C0 support for kinetis/teensy-3.x (to be tested)

This commit is contained in:
v01d
2016-08-06 22:23:59 -03:00
parent c145159c6b
commit d483f7939f
8 changed files with 840 additions and 13 deletions
+4
View File
@@ -131,6 +131,10 @@ ifeq ($(CONFIG_PWM),y)
CHIP_CSRCS += kinetis_pwm.c
endif
ifeq ($(CONFIG_I2C),y)
CHIP_CSRCS += kinetis_i2c.c
endif
ifeq ($(CONFIG_NET),y)
ifeq ($(CONFIG_KINETIS_ENET),y)
CHIP_CSRCS += kinetis_enet.c
File diff suppressed because it is too large Load Diff
+52
View File
@@ -0,0 +1,52 @@
#ifndef __ARCH_ARM_SRC_KINETIS_KINETIS_I2C_H
#define __ARCH_ARM_SRC_KINETIS_KINETIS_I2C_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/i2c/i2c_master.h>
#include "chip/kinetis_i2c.h"
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: kinetis_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 Parameter:
* Port number (for hardware that has multiple I2C interfaces)
*
* Returned Value:
* Valid I2C device structure reference on succcess; a NULL on failure
*
****************************************************************************/
FAR struct i2c_master_s *kinetis_i2cbus_initialize(int port);
/****************************************************************************
* Name: kinetis_i2cbus_uninitialize
*
* Description:
* De-initialize the selected I2C port, and power down the device.
*
* Input Parameter:
* Device structure as returned by the lpc43_i2cbus_initialize()
*
* Returned Value:
* OK on success, ERROR when internal reference count mismatch or dev
* points to invalid hardware device.
*
****************************************************************************/
int kinetis_i2cbus_uninitialize(FAR struct i2c_master_s *dev);
#endif /* __ARCH_ARM_SRC_KINETIS_KINETIS_I2C_H */
+14
View File
@@ -232,6 +232,20 @@
# define PIN_UART0_TX PIN_UART1_TX_1
#endif
#ifdef CONFIG_KINETIS_I2C0
#ifndef CONFIG_TEENSY_3X_I2C_ALT_PINS
# define PIN_I2C0_SCL (PIN_I2C0_SCL_1 | PIN_ALT2_OPENDRAIN | PIN_ALT2_SLOW | PIN_ALT2_HIGHDRIVE)
# define PIN_I2C0_SDA (PIN_I2C0_SDA_1 | PIN_ALT2_OPENDRAIN | PIN_ALT2_SLOW | PIN_ALT2_HIGHDRIVE)
#else
# define PIN_I2C0_SCL (PIN_I2C0_SCL_2 | PIN_ALT2_OPENDRAIN | PIN_ALT2_SLOW | PIN_ALT2_HIGHDRIVE)
# define PIN_I2C0_SDA (PIN_I2C0_SDA_2 | PIN_ALT2_OPENDRAIN | PIN_ALT2_SLOW | PIN_ALT2_HIGHDRIVE)
#endif
#endif
#ifdef CONFIG_KINETIS_I2C1
#error I2C1 not currently supported
#endif
/************************************************************************************
* Public Data
************************************************************************************/
+32 -12
View File
@@ -8,19 +8,19 @@
#
# CONFIG_EXPERIMENTAL is not set
# CONFIG_DEFAULT_SMALL is not set
# CONFIG_HOST_LINUX is not set
CONFIG_HOST_LINUX=y
# CONFIG_HOST_OSX is not set
CONFIG_HOST_WINDOWS=y
# CONFIG_HOST_WINDOWS is not set
# CONFIG_HOST_OTHER is not set
# CONFIG_WINDOWS_NATIVE is not set
CONFIG_WINDOWS_CYGWIN=y
# CONFIG_WINDOWS_CYGWIN is not set
# CONFIG_WINDOWS_MSYS is not set
# CONFIG_WINDOWS_OTHER is not set
#
# Build Configuration
#
# CONFIG_APPS_DIR="../apps"
CONFIG_APPS_DIR="../apps"
CONFIG_BUILD_FLAT=y
# CONFIG_BUILD_2PASS is not set
@@ -140,13 +140,16 @@ CONFIG_ARM_HAVE_MPU_UNIFIED=y
# CONFIG_ARMV7M_HAVE_ITCM is not set
# CONFIG_ARMV7M_HAVE_DTCM is not set
# CONFIG_ARMV7M_TOOLCHAIN_IARW is not set
# CONFIG_ARMV7M_TOOLCHAIN_IARL is not set
# CONFIG_ARMV7M_TOOLCHAIN_ATOLLIC is not set
# CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT is not set
# CONFIG_ARMV7M_TOOLCHAIN_CODEREDL is not set
# CONFIG_ARMV7M_TOOLCHAIN_CODEREDW is not set
# CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYL is not set
# CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW is not set
# CONFIG_ARMV7M_TOOLCHAIN_DEVKITARM is not set
# CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL is not set
CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y
CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y
# CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW is not set
# CONFIG_ARMV7M_TOOLCHAIN_RAISONANCE is not set
# CONFIG_ARMV7M_HAVE_STACKCHECK is not set
# CONFIG_ARMV7M_ITMSYSLOG is not set
@@ -176,9 +179,17 @@ CONFIG_ARCH_CHIP_MK20DX256VLH7=y
# CONFIG_ARCH_CHIP_MK60N512VMD100 is not set
# CONFIG_ARCH_CHIP_MK60X256VLQ100 is not set
# CONFIG_ARCH_CHIP_MK60X256VMD100 is not set
# CONFIG_ARCH_CHIP_MK64FN1M0VLL12 is not set
# CONFIG_ARCH_CHIP_MK64FX512VLL12 is not set
# CONFIG_ARCH_CHIP_MK64FX512VDC12 is not set
# CONFIG_ARCH_CHIP_MK64FN1M0VDC12 is not set
# CONFIG_ARCH_CHIP_MK64FX512VLQ12 is not set
# CONFIG_ARCH_CHIP_MK64FX512VMD12 is not set
# CONFIG_ARCH_CHIP_MK64FN1M0VMD12 is not set
CONFIG_ARCH_FAMILY_K20=y
# CONFIG_ARCH_FAMILY_K40 is not set
# CONFIG_ARCH_FAMILY_K60 is not set
# CONFIG_ARCH_FAMILY_K64 is not set
#
# Kinetis Peripheral Support
@@ -304,12 +315,12 @@ CONFIG_ARCH_BOARD="teensy-3.x"
#
CONFIG_ARCH_HAVE_LEDS=y
CONFIG_ARCH_LEDS=y
CONFIG_NSH_MMCSDMINOR=0
#
# Board-Specific Options
#
# CONFIG_TEENSY_3X_OVERCLOCK is not set
# CONFIG_BOARD_CRASHDUMP is not set
# CONFIG_LIB_BOARDCTL is not set
#
@@ -328,6 +339,7 @@ CONFIG_DISABLE_OS_API=y
CONFIG_USEC_PER_TICK=10000
# CONFIG_SYSTEM_TIME64 is not set
# CONFIG_CLOCK_MONOTONIC is not set
# CONFIG_ARCH_HAVE_TIMEKEEPING is not set
# CONFIG_JULIAN_TIME is not set
CONFIG_START_YEAR=2011
CONFIG_START_MONTH=12
@@ -420,6 +432,7 @@ CONFIG_PTHREAD_STACK_DEFAULT=2048
CONFIG_DISABLE_POLL=y
CONFIG_DEV_NULL=y
# CONFIG_DEV_ZERO is not set
# CONFIG_DEV_URANDOM is not set
# CONFIG_DEV_LOOP is not set
#
@@ -457,7 +470,12 @@ CONFIG_SPI_EXCHANGE=y
# CONFIG_VIDEO_DEVICES is not set
# CONFIG_BCH is not set
# CONFIG_INPUT is not set
#
# IO Expander/GPIO Support
#
# CONFIG_IOEXPANDER is not set
# CONFIG_DEV_GPIO is not set
#
# LCD Driver Support
@@ -530,8 +548,10 @@ CONFIG_UART0_2STOP=0
# CONFIG_UART0_IFLOWCONTROL is not set
# CONFIG_UART0_OFLOWCONTROL is not set
# CONFIG_UART0_DMA is not set
# CONFIG_PSEUDOTERM is not set
# CONFIG_USBDEV is not set
# CONFIG_USBHOST is not set
# CONFIG_HAVE_USBTRACE is not set
# CONFIG_DRIVERS_WIRELESS is not set
#
@@ -546,6 +566,7 @@ CONFIG_SYSLOG_SERIAL_CONSOLE=y
CONFIG_SYSLOG_CONSOLE=y
# CONFIG_SYSLOG_NONE is not set
# CONFIG_SYSLOG_FILE is not set
# CONFIG_SYSLOG_CHARDEV is not set
#
# Networking Support
@@ -658,6 +679,7 @@ CONFIG_ARCH_HAVE_TLS=y
# CONFIG_LIB_CRC64_FAST is not set
# CONFIG_LIB_KBDCODEC is not set
# CONFIG_LIB_SLCDCODEC is not set
# CONFIG_LIB_HEX2BIN is not set
#
# Basic CXX Support
@@ -683,7 +705,6 @@ CONFIG_BUILTIN_PROXY_STACKSIZE=1024
#
# CONFIG_EXAMPLES_CHAT is not set
# CONFIG_EXAMPLES_CONFIGDATA is not set
# CONFIG_EXAMPLES_CPUHOG is not set
# CONFIG_EXAMPLES_DHCPD is not set
# CONFIG_EXAMPLES_ELF is not set
# CONFIG_EXAMPLES_FTPC is not set
@@ -700,16 +721,15 @@ CONFIG_BUILTIN_PROXY_STACKSIZE=1024
# CONFIG_EXAMPLES_NRF24L01TERM is not set
CONFIG_EXAMPLES_NSH=y
# CONFIG_EXAMPLES_NULL is not set
# CONFIG_EXAMPLES_NX is not set
# CONFIG_EXAMPLES_NXFFS is not set
# CONFIG_EXAMPLES_NXHELLO is not set
# CONFIG_EXAMPLES_NXIMAGE is not set
# CONFIG_EXAMPLES_NX is not set
# CONFIG_EXAMPLES_NXLINES is not set
# CONFIG_EXAMPLES_NXTERM is not set
# CONFIG_EXAMPLES_NXTEXT is not set
# CONFIG_EXAMPLES_OSTEST is not set
# CONFIG_EXAMPLES_PCA9635 is not set
# CONFIG_EXAMPLES_PIPE is not set
# CONFIG_EXAMPLES_POSIXSPAWN is not set
# CONFIG_EXAMPLES_PPPD is not set
# CONFIG_EXAMPLES_RGBLED is not set
@@ -816,7 +836,6 @@ CONFIG_NSH_DISABLE_LOSMART=y
# CONFIG_NSH_DISABLE_LS is not set
# CONFIG_NSH_DISABLE_MB is not set
# CONFIG_NSH_DISABLE_MKDIR is not set
# CONFIG_NSH_DISABLE_MKFIFO is not set
# CONFIG_NSH_DISABLE_MKRD is not set
# CONFIG_NSH_DISABLE_MH is not set
# CONFIG_NSH_DISABLE_MOUNT is not set
@@ -838,6 +857,7 @@ CONFIG_NSH_DISABLE_LOSMART=y
# CONFIG_NSH_DISABLE_USLEEP is not set
# CONFIG_NSH_DISABLE_WGET is not set
# CONFIG_NSH_DISABLE_XD is not set
CONFIG_NSH_MMCSDMINOR=0
#
# Configure Command Options
@@ -878,7 +898,7 @@ CONFIG_NSH_CONSOLE=y
# CONFIG_SYSTEM_CLE is not set
# CONFIG_SYSTEM_CUTERM is not set
# CONFIG_SYSTEM_FREE is not set
# CONFIG_LIB_HEX2BIN is not set
# CONFIG_SYSTEM_HEX2BIN is not set
# CONFIG_SYSTEM_HEXED is not set
# CONFIG_SYSTEM_INSTALL is not set
# CONFIG_SYSTEM_RAMTEST is not set
+1 -1
View File
@@ -36,7 +36,7 @@
-include $(TOPDIR)/Make.defs
ASRCS =
CSRCS = k20_boot.c k20_spi.c
CSRCS = k20_boot.c k20_spi.c k20_i2c.c
ifeq ($(CONFIG_ARCH_LEDS),y)
CSRCS += k20_autoleds.c
+46
View File
@@ -0,0 +1,46 @@
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <nuttx/i2c/i2c_master.h>
#include <arch/board/board.h>
#include "up_arch.h"
#include "chip.h"
#include "kinetis.h"
#include "teensy-3x.h"
#include "kinetis_i2c.h"
#if defined(CONFIG_KINETIS_I2C0) || defined(CONFIG_KINETIS_I2C1)
/************************************************************************************
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: kinetis_i2cdev_initialize
*
* Description:
* Called to configure I2C
*
************************************************************************************/
void weak_function kinetis_i2cdev_initialize(void)
{
#if defined(CONFIG_KINETIS_I2C0)
kinetis_i2cbus_initialize(0);
#endif
#if defined(CONFIG_KINETIS_I2C1)
kinetis_i2cbus_initialize(1);
#endif
}
#endif /* CONFIG_KINETIS_I2C0 || CONFIG_KINETIS_I2C1 */
+10
View File
@@ -92,6 +92,16 @@
extern void weak_function kinetis_spidev_initialize(void);
/************************************************************************************
* Name: kinetis_i2cdev_initialize
*
* Description:
* Called to configure I2C
*
************************************************************************************/
extern void weak_function kinetis_i2cdev_initialize(void);
/************************************************************************************
* Name: kinetis_usbinitialize
*