SAML21 I2C driver. Developed for and contributed with permissin from Filament company.

This commit is contained in:
Alan Carvalho de Assis 2017-07-11 06:58:58 -06:00 committed by Gregory Nutt
parent 7193a4153a
commit 5b9526b4c1
7 changed files with 1939 additions and 6 deletions

View File

@ -582,6 +582,7 @@ choice
config SAMDL_SERCOM0_ISI2C
bool "I2C"
select I2C
select SAMDL_HAVE_I2C
config SAMDL_SERCOM0_ISSPI
bool "SPI"
@ -615,6 +616,7 @@ choice
config SAMDL_SERCOM1_ISI2C
bool "I2C"
select I2C
select SAMDL_HAVE_I2C
config SAMDL_SERCOM1_ISSPI
bool "SPI"
@ -634,6 +636,7 @@ choice
config SAMDL_SERCOM2_ISI2C
bool "I2C"
select I2C
select SAMDL_HAVE_I2C
config SAMDL_SERCOM2_ISSPI
bool "SPI"
@ -653,6 +656,7 @@ choice
config SAMDL_SERCOM3_ISI2C
bool "I2C"
select I2C
select SAMDL_HAVE_I2C
config SAMDL_SERCOM3_ISSPI
bool "SPI"
@ -672,6 +676,7 @@ choice
config SAMDL_SERCOM4_ISI2C
bool "I2C"
select I2C
select SAMDL_HAVE_I2C
config SAMDL_SERCOM4_ISSPI
bool "SPI"
@ -691,6 +696,7 @@ choice
config SAMDL_SERCOM5_ISI2C
bool "I2C"
select I2C
select SAMDL_HAVE_I2C
config SAMDL_SERCOM5_ISSPI
bool "SPI"
@ -716,3 +722,18 @@ config SAMDL_SPI_REGDEBUG
Enable very low-level register access debug. Depends on DEBUG_SPI.
endif # SAMDL_HAVE_SPI
config SAMDL_HAVE_I2C
bool
select I2C
if SAMDL_HAVE_I2C
config SAMDL_I2C_REGDEBUG
bool "I2C register-Level Debug"
default n
depends on DEBUG_I2C_INFO
---help---
Enable very low-level register access debug. Depends on DEBUG_I2C.
endif # SAMDL_HAVE_I2C

View File

@ -1,7 +1,7 @@
############################################################################
# arch/arm/src/samdl/Make.defs
#
# Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
# Copyright (C) 2014-2015, 2017 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
@ -94,3 +94,7 @@ endif
ifeq ($(CONFIG_SAMDL_HAVE_SPI),y)
CHIP_CSRCS += sam_spi.c
endif
ifeq ($(CONFIG_SAMDL_HAVE_I2C),y)
CHIP_CSRCS += sam_i2c_master.c
endif

View File

@ -277,7 +277,8 @@
#define PORT_SERCOM1_PAD2_2 (PORT_FUNCD | PORTA | PORT_PIN30)
#define PORT_SERCOM1_PAD3_1 (PORT_FUNCC | PORTA | PORT_PIN19)
#define PORT_SERCOM1_PAD3_2 (PORT_FUNCD | PORTA | PORT_PIN31)
#define PORT_SERCOM2_PAD0 (PORT_FUNCC | PORTA | PORT_PIN12)
#define PORT_SERCOM2_PAD0_1 (PORT_FUNCC | PORTA | PORT_PIN12)
#define PORT_SERCOM2_PAD0_2 (PORT_FUNCD | PORTA | PORT_PIN8)
#define PORT_SERCOM2_PAD1_1 (PORT_FUNCC | PORTA | PORT_PIN13)
#define PORT_SERCOM2_PAD1_2 (PORT_FUNCD | PORTA | PORT_PIN8)
#define PORT_SERCOM2_PAD1_3 (PORT_FUNCD | PORTA | PORT_PIN9)

View File

@ -153,7 +153,7 @@
# define I2C_CTRLA_MODE_MASTER (5 << I2C_CTRLA_MODE_SHIFT) /* I2C master mode */
#define I2C_CTRLA_RUNSTDBY (1 << 7) /* Bit 7: Run in standby */
#define I2C_CTRLA_PINOUT (1 << 16) /* Bit 16: Transmit data pinout */
# define I2C_CTRLA_2WIRE (0) /* 4-wire operation disable */
# define I2C_CTRLA_1WIRE (0) /* 4-wire operation disable */
# define I2C_CTRLA_4WIRE I2C_CTRLA_PINOUT /* 4-wire operation enable */
#define I2C_CTRLA_SDAHOLD_SHIFT (20) /* Bits 20-21: SDA Hold Time */
#define I2C_CTRLA_SDAHOLD_MASK (3 << I2C_CTRLA_SDAHOLD_SHIFT)
@ -212,6 +212,7 @@
#define I2C_INT_MB (1 << 0) /* Bit 0: Master on bus interrupt */
#define I2C_INT_SB (1 << 1) /* Bit 1: Slave on bus interrupt */
#define I2C_INT_ERR (1 << 7) /* Bit 7: Bus Error */
#define I2C_INT_ALL (0x03)

File diff suppressed because it is too large Load Diff

View File

@ -134,7 +134,7 @@ static inline void sam_configinput(uintptr_t base, port_pinset_t pinset)
/* Set the pin configuration */
regval = (PORT_WRCONFIG_WRPINCFG | PORT_WRCONFIG_WRPMUX | PORT_WRCONFIG_INEN);
if (pin > 16)
if (pin >= 16)
{
/* Select the upper half word and adjust the bit setting */
@ -531,7 +531,7 @@ int sam_dumpport(uint32_t pinset, const char *msg)
/* Get the base address associated with the PIO port */
pin = (pinset & PORT_PIN_MASK) >> PORT_PIN_SHIFT;
pin = sam_portpin(pinset);
port = (pinset & PORT_MASK) >> PORT_SHIFT;
base = SAM_PORTN_BASE(port);

View File

@ -379,7 +379,7 @@ bool sam_portread(port_pinset_t pinset);
*
****************************************************************************/
#ifdef CONFIG_DEBUG_FEATURES
#ifdef CONFIG_DEBUG_GPIO_INFO
int sam_dumpport(port_pinset_t pinset, const char *msg);
#else
# define sam_dumpport(p,m)