diff --git a/arch/arm/src/efm32/efm32_i2c.c b/arch/arm/src/efm32/efm32_i2c.c index 949f3579606..fa398440c60 100644 --- a/arch/arm/src/efm32/efm32_i2c.c +++ b/arch/arm/src/efm32/efm32_i2c.c @@ -1724,14 +1724,14 @@ out: ****************************************************************************/ /**************************************************************************** - * Name: up_i2cinitialize + * Name: efm32_i2cbus_initialize * * Description: * Initialize one I2C bus * ****************************************************************************/ -FAR struct i2c_master_s *up_i2cinitialize(int port) +FAR struct i2c_master_s *efm32_i2cbus_initialize(int port) { struct efm32_i2c_priv_s *priv = NULL; irqstate_t irqs; @@ -1773,14 +1773,14 @@ FAR struct i2c_master_s *up_i2cinitialize(int port) } /**************************************************************************** - * Name: up_i2cuninitialize + * Name: efm32_i2cbus_uninitialize * * Description: * Uninitialize an I2C bus * ****************************************************************************/ -int up_i2cuninitialize(FAR struct i2c_master_s *dev) +int efm32_i2cbus_uninitialize(FAR struct i2c_master_s *dev) { FAR struct efm32_i2c_priv_s *priv = (struct efm32_i2c_priv_s *)dev; irqstate_t irqs; diff --git a/arch/arm/src/efm32/efm32_i2c.h b/arch/arm/src/efm32/efm32_i2c.h new file mode 100644 index 00000000000..16e51434bef --- /dev/null +++ b/arch/arm/src/efm32/efm32_i2c.h @@ -0,0 +1,86 @@ +/**************************************************************************** + * arch/arm/src/efm32/efm32_i2c.h + * + * Copyright (C) 2009, 2011, 2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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. + * + ****************************************************************************/ + +#ifndef __ARCH_ARM_SRC_EFM32_EFM32_I2C_H +#define __ARCH_ARM_SRC_EFM32_EFM32_I2C_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: efm32_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 *efm32_i2cbus_initialize(int port); + +/**************************************************************************** + * Name: efm32_i2cbus_uninitialize + * + * Description: + * De-initialize the selected I2C port, and power down the device. + * + * Input Parameter: + * Device structure as returned by the efm32_i2cbus_initialize() + * + * Returned Value: + * OK on success, ERROR when internal reference count mismatch or dev + * points to invalid hardware device. + * + ****************************************************************************/ + +int efm32_i2cbus_uninitialize(FAR struct i2c_master_s *dev); + +#endif /* __ARCH_ARM_SRC_EFM32_EFM32_I2C_H */ diff --git a/arch/arm/src/lpc11xx/lpc11_i2c.c b/arch/arm/src/lpc11xx/lpc11_i2c.c index 220a30e09b3..66afcde90e0 100644 --- a/arch/arm/src/lpc11xx/lpc11_i2c.c +++ b/arch/arm/src/lpc11xx/lpc11_i2c.c @@ -472,14 +472,14 @@ static int lpc11_i2c_reset(FAR struct i2c_master_s * dev) ****************************************************************************/ /**************************************************************************** - * Name: up_i2cinitialize + * Name: lpc11_i2cbus_initialize * * Description: * Initialise an I2C device * ****************************************************************************/ -struct i2c_master_s *up_i2cinitialize(int port) +struct i2c_master_s *lpc11_i2cbus_initialize(int port) { struct lpc11_i2cdev_s *priv; @@ -607,14 +607,14 @@ struct i2c_master_s *up_i2cinitialize(int port) } /**************************************************************************** - * Name: up_i2cuninitalize + * Name: lpc11_i2cbus_uninitialize * * Description: * Uninitialise an I2C device * ****************************************************************************/ -int up_i2cuninitialize(FAR struct i2c_master_s * dev) +int lpc11_i2cbus_uninitialize(FAR struct i2c_master_s * dev) { struct lpc11_i2cdev_s *priv = (struct lpc11_i2cdev_s *) dev; diff --git a/arch/arm/src/lpc11xx/lpc11_i2c.h b/arch/arm/src/lpc11xx/lpc11_i2c.h index 4b5097a955f..a9bc6fa3f75 100644 --- a/arch/arm/src/lpc11xx/lpc11_i2c.h +++ b/arch/arm/src/lpc11xx/lpc11_i2c.h @@ -1,7 +1,7 @@ -/************************************************************************************ +/**************************************************************************** * arch/arm/src/lpc11xx/lpc11_i2c.h * - * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2015, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -31,32 +31,57 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ************************************************************************************/ + ****************************************************************************/ #ifndef __ARCH_ARM_SRC_LPC11XX_LPC11_I2C_H #define __ARCH_ARM_SRC_LPC11XX_LPC11_I2C_H -/************************************************************************************ +/**************************************************************************** * Included Files - ************************************************************************************/ + ****************************************************************************/ #include +#include #include "chip/lpc11_i2c.h" -/************************************************************************************ - * Pre-processor Definitions - ************************************************************************************/ - -/************************************************************************************ - * Public Types - ************************************************************************************/ - -/************************************************************************************ - * Public Data - ************************************************************************************/ - -/************************************************************************************ +/**************************************************************************** * Public Functions - ************************************************************************************/ + ****************************************************************************/ + +/**************************************************************************** + * Name: lpc11_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 *lpc11_i2cbus_initialize(int port); + +/**************************************************************************** + * Name: lpc11_i2cbus_uninitialize + * + * Description: + * De-initialize the selected I2C port, and power down the device. + * + * Input Parameter: + * Device structure as returned by the lpc11_i2cbus_initialize() + * + * Returned Value: + * OK on success, ERROR when internal reference count mismatch or dev + * points to invalid hardware device. + * + ****************************************************************************/ + +int lpc11_i2cbus_uninitialize(FAR struct i2c_master_s *dev); #endif /* __ARCH_ARM_SRC_LPC11XX_LPC11_I2C_H */ diff --git a/arch/arm/src/lpc17xx/lpc17_i2c.c b/arch/arm/src/lpc17xx/lpc17_i2c.c index f40c8948c16..b195dd88da7 100644 --- a/arch/arm/src/lpc17xx/lpc17_i2c.c +++ b/arch/arm/src/lpc17xx/lpc17_i2c.c @@ -472,14 +472,14 @@ static int lpc17_i2c_reset(FAR struct i2c_master_s * dev) ****************************************************************************/ /**************************************************************************** - * Name: up_i2cinitialize + * Name: lpc17_i2cbus_initialize * * Description: * Initialise an I2C device * ****************************************************************************/ -struct i2c_master_s *up_i2cinitialize(int port) +struct i2c_master_s *lpc17_i2cbus_initialize(int port) { struct lpc17_i2cdev_s *priv; @@ -612,14 +612,14 @@ struct i2c_master_s *up_i2cinitialize(int port) } /**************************************************************************** - * Name: up_i2cuninitalize + * Name: lpc17_i2cbus_uninitialize * * Description: * Uninitialise an I2C device * ****************************************************************************/ -int up_i2cuninitialize(FAR struct i2c_master_s * dev) +int lpc17_i2cbus_uninitialize(FAR struct i2c_master_s * dev) { struct lpc17_i2cdev_s *priv = (struct lpc17_i2cdev_s *) dev; diff --git a/arch/arm/src/lpc17xx/lpc17_i2c.h b/arch/arm/src/lpc17xx/lpc17_i2c.h index 5d229f4529b..a7a63224619 100644 --- a/arch/arm/src/lpc17xx/lpc17_i2c.h +++ b/arch/arm/src/lpc17xx/lpc17_i2c.h @@ -1,4 +1,4 @@ -/************************************************************************************ +/**************************************************************************** * arch/arm/src/lpc17xx/lpc17_i2c.h * * Copyright (C) 2010, 2013 Gregory Nutt. All rights reserved. @@ -31,32 +31,57 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ************************************************************************************/ + ****************************************************************************/ #ifndef __ARCH_ARM_SRC_LPC17XX_LPC17_I2C_H #define __ARCH_ARM_SRC_LPC17XX_LPC17_I2C_H -/************************************************************************************ +/**************************************************************************** * Included Files - ************************************************************************************/ + ****************************************************************************/ #include +#include #include "chip/lpc17_i2c.h" -/************************************************************************************ - * Pre-processor Definitions - ************************************************************************************/ +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ -/************************************************************************************ - * Public Types - ************************************************************************************/ +/**************************************************************************** + * Name: lpc17_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 + * + ****************************************************************************/ -/************************************************************************************ - * Public Data - ************************************************************************************/ +FAR struct i2c_master_s *lpc17_i2cbus_initialize(int port); -/************************************************************************************ - * Public Functions - ************************************************************************************/ +/**************************************************************************** + * Name: lpc17_i2cbus_uninitialize + * + * Description: + * De-initialize the selected I2C port, and power down the device. + * + * Input Parameter: + * Device structure as returned by the lpc17_i2cbus_initialize() + * + * Returned Value: + * OK on success, ERROR when internal reference count mismatch or dev + * points to invalid hardware device. + * + ****************************************************************************/ + +int lpc17_i2cbus_uninitialize(FAR struct i2c_master_s *dev); #endif /* __ARCH_ARM_SRC_LPC17XX_LPC17_I2C_H */ diff --git a/arch/arm/src/lpc2378/lpc23xx_i2c.c b/arch/arm/src/lpc2378/lpc23xx_i2c.c index a13d71edc0a..857b2f7c14d 100644 --- a/arch/arm/src/lpc2378/lpc23xx_i2c.c +++ b/arch/arm/src/lpc2378/lpc23xx_i2c.c @@ -477,14 +477,14 @@ static int lpc2378_i2c_reset(FAR struct i2c_master_s * dev) ****************************************************************************/ /**************************************************************************** - * Name: up_i2cinitialize + * Name: lpc2378_i2cbus_initialize * * Description: * Initialise an I2C device * ****************************************************************************/ -struct i2c_master_s *up_i2cinitialize(int port) +struct i2c_master_s *lpc2378_i2cbus_initialize(int port) { struct lpc2378_i2cdev_s *priv; @@ -623,14 +623,14 @@ struct i2c_master_s *up_i2cinitialize(int port) } /**************************************************************************** - * Name: up_i2cuninitalize + * Name: lpc2378_i2cbus_uninitialize * * Description: * Uninitialise an I2C device * ****************************************************************************/ -int up_i2cuninitialize(FAR struct i2c_master_s * dev) +int lpc2378_i2cbus_uninitialize(FAR struct i2c_master_s * dev) { struct lpc2378_i2cdev_s *priv = (struct lpc2378_i2cdev_s *) dev; diff --git a/arch/arm/src/lpc2378/lpc23xx_i2c.h b/arch/arm/src/lpc2378/lpc23xx_i2c.h index c0f33660f02..5658269f20a 100644 --- a/arch/arm/src/lpc2378/lpc23xx_i2c.h +++ b/arch/arm/src/lpc2378/lpc23xx_i2c.h @@ -46,7 +46,7 @@ ************************************************************************************/ #include - +#include #include "chip.h" /************************************************************************************ @@ -151,15 +151,43 @@ /* Bits 16-31: Reserved */ /************************************************************************************ - * Public Types + * Public Function Prototypes ************************************************************************************/ /************************************************************************************ - * Public Data + * Name: lpc2378_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 *lpc2378_i2cbus_initialize(int port); + /************************************************************************************ - * Public Functions + * Name: lpc2378_i2cbus_uninitialize + * + * Description: + * De-initialize the selected I2C port, and power down the device. + * + * Input Parameter: + * Device structure as returned by the lpc2378_i2cbus_initialize() + * + * Returned Value: + * OK on success, ERROR when internal reference count mismatch or dev + * points to invalid hardware device. + * ************************************************************************************/ +int lpc2378_i2cbus_uninitialize(FAR struct i2c_master_s *dev); + #endif /* __ARCH_ARM_SRC_LPC2378_LPC23XX_I2C_H */ diff --git a/arch/arm/src/lpc31xx/lpc31_i2c.c b/arch/arm/src/lpc31xx/lpc31_i2c.c index e8ad8aff458..3500b06587b 100644 --- a/arch/arm/src/lpc31xx/lpc31_i2c.c +++ b/arch/arm/src/lpc31xx/lpc31_i2c.c @@ -538,14 +538,14 @@ static int i2c_reset(FAR struct i2c_master_s * dev) ****************************************************************************/ /**************************************************************************** - * Name: up_i2cinitialize + * Name: lpc31_i2cbus_initialize * * Description: * Initialise an I2C device * ****************************************************************************/ -struct i2c_master_s *up_i2cinitialize(int port) +struct i2c_master_s *lpc31_i2cbus_initialize(int port) { struct lpc31_i2cdev_s *priv = &i2cdevices[port]; @@ -587,14 +587,14 @@ struct i2c_master_s *up_i2cinitialize(int port) } /**************************************************************************** - * Name: up_i2cuninitalize + * Name: lpc31_i2cbus_uninitialize * * Description: * Uninitialise an I2C device * ****************************************************************************/ -void up_i2cuninitalize(struct lpc31_i2cdev_s *priv) +void lpc31_i2cbus_uninitialize(struct lpc31_i2cdev_s *priv) { /* Disable All Interrupts, soft reset the device */ diff --git a/arch/arm/src/lpc31xx/lpc31_i2c.h b/arch/arm/src/lpc31xx/lpc31_i2c.h index e7574c7027b..10280a57731 100644 --- a/arch/arm/src/lpc31xx/lpc31_i2c.h +++ b/arch/arm/src/lpc31xx/lpc31_i2c.h @@ -41,6 +41,7 @@ ************************************************************************************************/ #include +#include #include "lpc31_memorymap.h" /************************************************************************************************ @@ -192,16 +193,44 @@ #define I2C_STXFL_SHIFT (0) /* Bits 0-1: Slave Transmit FIFO level */ #define I2C_STXFL_MASK (3 << I2C_STXFL_SHIFT) -/************************************************************************************************ - * Public Types - ************************************************************************************************/ +/************************************************************************************ + * Public Function Prototypes + ************************************************************************************/ -/************************************************************************************************ - * Public Data - ************************************************************************************************/ +/************************************************************************************ + * Name: lpc31_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 + * + ************************************************************************************/ -/************************************************************************************************ - * Public Functions - ************************************************************************************************/ +FAR struct i2c_master_s *lpc31_i2cbus_initialize(int port); + +/************************************************************************************ + * Name: lpc31_i2cbus_uninitialize + * + * Description: + * De-initialize the selected I2C port, and power down the device. + * + * Input Parameter: + * Device structure as returned by the lpc31_i2cbus_initialize() + * + * Returned Value: + * OK on success, ERROR when internal reference count mismatch or dev + * points to invalid hardware device. + * + ************************************************************************************/ + +int lpc31_i2cbus_uninitialize(FAR struct i2c_master_s *dev); #endif /* __ARCH_ARM_SRC_LPC31XX_LPC31_I2C_H */ diff --git a/arch/arm/src/lpc43xx/lpc43_ehci.c b/arch/arm/src/lpc43xx/lpc43_ehci.c index f9ef7799dab..29f361bc851 100644 --- a/arch/arm/src/lpc43xx/lpc43_ehci.c +++ b/arch/arm/src/lpc43xx/lpc43_ehci.c @@ -4472,7 +4472,7 @@ exit_terminate: #else /* Wake up the waiting thread */ - sam_givesem(&epinfo->iocsem); + lpc43_givesem(&epinfo->iocsem); #endif errout_with_sem: diff --git a/arch/arm/src/lpc43xx/lpc43_i2c.c b/arch/arm/src/lpc43xx/lpc43_i2c.c index 065be78badd..639c158ccea 100644 --- a/arch/arm/src/lpc43xx/lpc43_i2c.c +++ b/arch/arm/src/lpc43xx/lpc43_i2c.c @@ -451,14 +451,14 @@ static int lpc43_i2c_reset(FAR struct i2c_master_s * dev) ****************************************************************************/ /**************************************************************************** - * Name: up_i2cinitialize + * Name: lpc43_i2cbus_initialize * * Description: * Initialise an I2C device * ****************************************************************************/ -struct i2c_master_s *up_i2cinitialize(int port) +struct i2c_master_s *lpc43_i2cbus_initialize(int port) { struct lpc43_i2cdev_s *priv; @@ -562,14 +562,14 @@ struct i2c_master_s *up_i2cinitialize(int port) } /**************************************************************************** - * Name: up_i2cuninitalize + * Name: lpc43_i2cbus_uninitialize * * Description: * Uninitialise an I2C device * ****************************************************************************/ -int up_i2cuninitialize(FAR struct i2c_master_s * dev) +int lpc43_i2cbus_uninitialize(FAR struct i2c_master_s * dev) { struct lpc43_i2cdev_s *priv = (struct lpc43_i2cdev_s *) dev; diff --git a/arch/arm/src/lpc43xx/lpc43_i2c.h b/arch/arm/src/lpc43xx/lpc43_i2c.h index 1ada7b9cf6c..ae8d94a7f88 100644 --- a/arch/arm/src/lpc43xx/lpc43_i2c.h +++ b/arch/arm/src/lpc43xx/lpc43_i2c.h @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/lpc43xx/lpc43_i2c.h * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -41,26 +41,47 @@ ****************************************************************************/ #include +#include #include "chip/lpc43_i2c.h" /**************************************************************************** - * Pre-processor Definitions + * Public Function Prototypes ****************************************************************************/ /**************************************************************************** - * Public Types + * Name: lpc43_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 + * ****************************************************************************/ -/**************************************************************************** - * Public Data - ****************************************************************************/ +FAR struct i2c_master_s *lpc43_i2cbus_initialize(int port); /**************************************************************************** - * Inline Functions + * Name: lpc43_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. + * ****************************************************************************/ -/**************************************************************************** - * Public Functions - ****************************************************************************/ +int lpc43_i2cbus_uninitialize(FAR struct i2c_master_s *dev); #endif /* __ARCH_ARM_SRC_LPC43XX_LPC43_I2C_H */ diff --git a/arch/arm/src/sam34/sam_twi.c b/arch/arm/src/sam34/sam_twi.c index df906c5a952..4ffd90b5a80 100644 --- a/arch/arm/src/sam34/sam_twi.c +++ b/arch/arm/src/sam34/sam_twi.c @@ -909,14 +909,14 @@ static void twi_hw_initialize(struct twi_dev_s *priv, unsigned int pid, ****************************************************************************/ /**************************************************************************** - * Name: up_i2cinitialize + * Name: sam_i2cbus_initialize * * Description: * Initialize a TWI device for I2C operation * ****************************************************************************/ -struct i2c_master_s *up_i2cinitialize(int bus) +struct i2c_master_s *sam_i2cbus_initialize(int bus) { struct twi_dev_s *priv; xcpt_t handler; @@ -1017,14 +1017,14 @@ struct i2c_master_s *up_i2cinitialize(int bus) } /**************************************************************************** - * Name: up_i2cuninitalize + * Name: sam_i2cbus_uninitialize * * Description: * Uninitialise an I2C device * ****************************************************************************/ -int up_i2cuninitialize(FAR struct i2c_master_s * dev) +int sam_i2cbus_uninitialize(FAR struct i2c_master_s * dev) { struct twi_dev_s *priv = (struct twi_dev_s *) dev; diff --git a/arch/arm/src/sam34/sam_twi.h b/arch/arm/src/sam34/sam_twi.h index f83a98cb5b3..87c31b30321 100644 --- a/arch/arm/src/sam34/sam_twi.h +++ b/arch/arm/src/sam34/sam_twi.h @@ -1,7 +1,7 @@ /************************************************************************************ * arch/arm/src/sam34/sam_twi.h * - * Copyright (C) 2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -44,20 +44,44 @@ #include #include "chip/sam_twi.h" -/************************************************************************************ - * Pre-processor Definitions - ************************************************************************************/ +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ -/************************************************************************************ - * Public Types - ************************************************************************************/ +/**************************************************************************** + * Name: sam_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 + * + ****************************************************************************/ -/************************************************************************************ - * Public Data - ************************************************************************************/ +FAR struct i2c_master_s *sam_i2cbus_initialize(int port); -/************************************************************************************ - * Public Functions - ************************************************************************************/ +/**************************************************************************** + * Name: sam_i2cbus_uninitialize + * + * Description: + * De-initialize the selected I2C port, and power down the device. + * + * Input Parameter: + * Device structure as returned by the sam_i2cbus_initialize() + * + * Returned Value: + * OK on success, ERROR when internal reference count mismatch or dev + * points to invalid hardware device. + * + ****************************************************************************/ + +int sam_i2cbus_uninitialize(FAR struct i2c_master_s *dev); #endif /* __ARCH_ARM_SRC_SAM34_SAM_TWI_H */ diff --git a/arch/arm/src/sama5/sam_twi.c b/arch/arm/src/sama5/sam_twi.c index cb78f2b1e2b..8599554c8c5 100644 --- a/arch/arm/src/sama5/sam_twi.c +++ b/arch/arm/src/sama5/sam_twi.c @@ -1213,14 +1213,14 @@ static void twi_hw_initialize(struct twi_dev_s *priv, uint32_t frequency) ****************************************************************************/ /**************************************************************************** - * Name: up_i2cinitialize + * Name: sam_i2cbus_initialize * * Description: * Initialize a TWI device for I2C operation * ****************************************************************************/ -struct i2c_master_s *up_i2cinitialize(int bus) +struct i2c_master_s *sam_i2cbus_initialize(int bus) { struct twi_dev_s *priv; uint32_t frequency; @@ -1335,14 +1335,14 @@ errout_with_irq: } /**************************************************************************** - * Name: up_i2cuninitalize + * Name: sam_i2cbus_uninitialize * * Description: * Uninitialize an I2C device * ****************************************************************************/ -int up_i2cuninitialize(FAR struct i2c_master_s *dev) +int sam_i2cbus_uninitialize(FAR struct i2c_master_s *dev) { struct twi_dev_s *priv = (struct twi_dev_s *) dev; diff --git a/arch/arm/src/sama5/sam_twi.h b/arch/arm/src/sama5/sam_twi.h index 7300f87a440..e8d75e13354 100644 --- a/arch/arm/src/sama5/sam_twi.h +++ b/arch/arm/src/sama5/sam_twi.h @@ -1,7 +1,7 @@ /************************************************************************************ * arch/arm/src/sama5/sam_twi.h * - * Copyright (C) 2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -44,20 +44,44 @@ #include #include "chip/sam_twi.h" -/************************************************************************************ - * Pre-processor Definitions - ************************************************************************************/ +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ -/************************************************************************************ - * Public Types - ************************************************************************************/ +/**************************************************************************** + * Name: sam_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 + * + ****************************************************************************/ -/************************************************************************************ - * Public Data - ************************************************************************************/ +FAR struct i2c_master_s *sam_i2cbus_initialize(int port); -/************************************************************************************ - * Public Functions - ************************************************************************************/ +/**************************************************************************** + * Name: sam_i2cbus_uninitialize + * + * Description: + * De-initialize the selected I2C port, and power down the device. + * + * Input Parameter: + * Device structure as returned by the sam_i2cbus_initialize() + * + * Returned Value: + * OK on success, ERROR when internal reference count mismatch or dev + * points to invalid hardware device. + * + ****************************************************************************/ + +int sam_i2cbus_uninitialize(FAR struct i2c_master_s *dev); #endif /* __ARCH_ARM_SRC_SAMA5_SAM_TWI_H */ diff --git a/arch/arm/src/samv7/sam_twihs.c b/arch/arm/src/samv7/sam_twihs.c index 7ca134bfe9f..6b54510226b 100644 --- a/arch/arm/src/samv7/sam_twihs.c +++ b/arch/arm/src/samv7/sam_twihs.c @@ -1240,14 +1240,14 @@ static void twi_hw_initialize(struct twi_dev_s *priv, uint32_t frequency) ****************************************************************************/ /**************************************************************************** - * Name: up_i2cinitialize + * Name: sam_i2cbus_initialize * * Description: * Initialize a TWIHS device for I2C operation * ****************************************************************************/ -struct i2c_master_s *up_i2cinitialize(int bus) +struct i2c_master_s *sam_i2cbus_initialize(int bus) { struct twi_dev_s *priv; uint32_t frequency; @@ -1358,14 +1358,14 @@ errout_with_irq: } /**************************************************************************** - * Name: up_i2cuninitalize + * Name: sam_i2cbus_uninitialize * * Description: * Uninitialize an I2C device * ****************************************************************************/ -int up_i2cuninitialize(FAR struct i2c_master_s *dev) +int sam_i2cbus_uninitialize(FAR struct i2c_master_s *dev) { struct twi_dev_s *priv = (struct twi_dev_s *) dev; irqstate_t flags; diff --git a/arch/arm/src/samv7/sam_twihs.h b/arch/arm/src/samv7/sam_twihs.h index 12c3da3f154..79f85a70e38 100644 --- a/arch/arm/src/samv7/sam_twihs.h +++ b/arch/arm/src/samv7/sam_twihs.h @@ -1,7 +1,7 @@ /************************************************************************************ * arch/arm/src/samv7/sam_twih.h * - * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2015, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -44,20 +44,44 @@ #include #include "chip/sam_twihs.h" -/************************************************************************************ - * Pre-processor Definitions - ************************************************************************************/ +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ -/************************************************************************************ - * Public Types - ************************************************************************************/ +/**************************************************************************** + * Name: sam_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 + * + ****************************************************************************/ -/************************************************************************************ - * Public Data - ************************************************************************************/ +FAR struct i2c_master_s *sam_i2cbus_initialize(int port); -/************************************************************************************ - * Public Functions - ************************************************************************************/ +/**************************************************************************** + * Name: sam_i2cbus_uninitialize + * + * Description: + * De-initialize the selected I2C port, and power down the device. + * + * Input Parameter: + * Device structure as returned by the sam_i2cbus_initialize() + * + * Returned Value: + * OK on success, ERROR when internal reference count mismatch or dev + * points to invalid hardware device. + * + ****************************************************************************/ + +int sam_i2cbus_uninitialize(FAR struct i2c_master_s *dev); #endif /* __ARCH_ARM_SRC_SAMV7_SAM_TWIHS_H */ diff --git a/arch/arm/src/stm32/stm32_i2c.h b/arch/arm/src/stm32/stm32_i2c.h index 2dc97303b3b..05f57ee46fb 100644 --- a/arch/arm/src/stm32/stm32_i2c.h +++ b/arch/arm/src/stm32/stm32_i2c.h @@ -1,4 +1,4 @@ -/************************************************************************************ +/**************************************************************************** * arch/arm/src/stm32/stm32_i2c.h * * Copyright (C) 2009, 2011, 2013 Gregory Nutt. All rights reserved. @@ -31,14 +31,28 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ************************************************************************************/ + ****************************************************************************/ #ifndef __ARCH_ARM_SRC_STM32_STM32_I2C_H #define __ARCH_ARM_SRC_STM32_STM32_I2C_H -/************************************************************************************ +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include "chip.h" +#if defined(CONFIG_STM32_STM32F30XX) +# include "chip/stm32f30xxx_i2c.h" +#else +# include "chip/stm32_i2c.h" +#endif + +/**************************************************************************** * Pre-processor Definitions - ************************************************************************************/ + ****************************************************************************/ /* If a dynamic timeout is selected, then a non-negative, non-zero micro- * seconds per byte value must be provided as well. @@ -51,19 +65,9 @@ # endif #endif -/************************************************************************************ - * Included Files - ************************************************************************************/ - -#include -#include - -#include "chip.h" -#if defined(CONFIG_STM32_STM32F30XX) -# include "chip/stm32f30xxx_i2c.h" -#else -# include "chip/stm32_i2c.h" -#endif +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ /**************************************************************************** * Name: stm32_i2cbus_initialize @@ -102,4 +106,3 @@ FAR struct i2c_master_s *stm32_i2cbus_initialize(int port); int stm32_i2cbus_uninitialize(FAR struct i2c_master_s *dev); #endif /* __ARCH_ARM_SRC_STM32_STM32_I2C_H */ - diff --git a/arch/arm/src/tiva/tiva_i2c.c b/arch/arm/src/tiva/tiva_i2c.c index 70e4bd18f3b..b567894db49 100644 --- a/arch/arm/src/tiva/tiva_i2c.c +++ b/arch/arm/src/tiva/tiva_i2c.c @@ -2131,14 +2131,14 @@ out: ************************************************************************************/ /************************************************************************************ - * Name: up_i2cinitialize + * Name: tiva_i2cbus_initialize * * Description: * Initialize one I2C bus * ************************************************************************************/ -struct i2c_master_s *up_i2cinitialize(int port) +struct i2c_master_s *tiva_i2cbus_initialize(int port) { struct tiva_i2c_priv_s *priv = NULL; const struct tiva_i2c_config_s *config; @@ -2253,14 +2253,14 @@ struct i2c_master_s *up_i2cinitialize(int port) } /************************************************************************************ - * Name: up_i2cuninitialize + * Name: tiva_i2cbus_uninitialize * * Description: * Uninitialize an I2C bus * ************************************************************************************/ -int up_i2cuninitialize(struct i2c_master_s *dev) +int tiva_i2cbus_uninitialize(struct i2c_master_s *dev) { struct tiva_i2c_priv_s *priv = (struct tiva_i2c_priv_s *)dev; int irqs; diff --git a/arch/arm/src/tiva/tiva_i2c.h b/arch/arm/src/tiva/tiva_i2c.h index b0b412d7447..33acca1116c 100644 --- a/arch/arm/src/tiva/tiva_i2c.h +++ b/arch/arm/src/tiva/tiva_i2c.h @@ -46,4 +46,44 @@ #include "chip.h" #include "chip/tiva_i2c.h" +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: tiva_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 *tiva_i2cbus_initialize(int port); + +/**************************************************************************** + * Name: tiva_i2cbus_uninitialize + * + * Description: + * De-initialize the selected I2C port, and power down the device. + * + * Input Parameter: + * Device structure as returned by the tiva_i2cbus_initialize() + * + * Returned Value: + * OK on success, ERROR when internal reference count mismatch or dev + * points to invalid hardware device. + * + ****************************************************************************/ + +int tiva_i2cbus_uninitialize(FAR struct i2c_master_s *dev); + #endif /* __ARCH_ARM_SRC_TIVA_TIVA_I2C_H */ diff --git a/arch/z80/src/ez80/ez80_i2c.c b/arch/z80/src/ez80/ez80_i2c.c index 22c4d2409d5..f1c8a2bcd1a 100644 --- a/arch/z80/src/ez80/ez80_i2c.c +++ b/arch/z80/src/ez80/ez80_i2c.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/z80/src/ez80/ez80_i2c.c * - * Copyright(C) 2009, 2011, 2013 Gregory Nutt. All rights reserved. + * Copyright(C) 2009, 2011, 2013, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -99,9 +99,6 @@ static void ez80_i2c_setfrequency(FAR struct ez80_i2cdev_s *priv, static int ez80_i2c_transfer(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s *msgs, int count); -#ifdef CONFIG_I2C_RESET -static int ez80_i2c_reset(FAR struct i2c_master_s *dev); -#endif /**************************************************************************** * Public Function Prototypes @@ -121,9 +118,6 @@ static sem_t g_i2csem; /* Serialize I2C transfers */ const struct i2c_ops_s g_ops = { ez80_i2c_transfer -#ifdef CONFIG_I2C_RESET - , ez80_i2c_reset -#endif }; /**************************************************************************** @@ -916,33 +910,12 @@ static int ez80_i2c_transfer(FAR struct i2c_master_s *dev, return ret; } -/************************************************************************************ - * Name: ez80_i2c_reset - * - * Description: - * Perform an I2C bus reset in an attempt to break loose stuck I2C devices. - * - * Input Parameters: - * dev - Device-specific state data - * - * Returned Value: - * Zero (OK) on success; a negated errno value on failure. - * - ************************************************************************************/ - -#ifdef CONFIG_I2C_RESET -static int ez80_i2c_reset(FAR struct i2c_master_s * dev) -{ - return OK; -} -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** - * Name: up_i2cinitialize + * Name: ez80_i2cbus_initialize * * Description: * Initialize the selected I2C port. And return a unique instance of struct @@ -958,7 +931,7 @@ static int ez80_i2c_reset(FAR struct i2c_master_s * dev) * ****************************************************************************/ -FAR struct i2c_master_s *up_i2cinitialize(int port) +FAR struct i2c_master_s *ez80_i2cbus_initialize(int port) { FAR struct ez80_i2cdev_s *i2c; uint16_t ccr; diff --git a/arch/z80/src/ez80/ez80f91_i2c.h b/arch/z80/src/ez80/ez80f91_i2c.h index f41fcfab3eb..b59d4ffc7b1 100644 --- a/arch/z80/src/ez80/ez80f91_i2c.h +++ b/arch/z80/src/ez80/ez80f91_i2c.h @@ -138,9 +138,45 @@ extern "C" #endif /* __cplusplus */ /************************************************************************************ - * Public Functions + * Public Function Prototypes ************************************************************************************/ +/************************************************************************************ + * Name: ez80_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 *ez80_i2cbus_initialize(int port); + +/************************************************************************************ + * Name: ez80_i2cbus_uninitialize + * + * Description: + * De-initialize the selected I2C port, and power down the device. + * + * Input Parameter: + * Device structure as returned by the ez80_i2cbus_initialize() + * + * Returned Value: + * OK on success, ERROR when internal reference count mismatch or dev + * points to invalid hardware device. + * + ************************************************************************************/ + +int ez80_i2cbus_uninitialize(FAR struct i2c_master_s *dev); + #undef EXTERN #ifdef __cplusplus } diff --git a/arch/z80/src/z8/z8_i2c.c b/arch/z80/src/z8/z8_i2c.c index 3817b517b4e..cc3508a564c 100644 --- a/arch/z80/src/z8/z8_i2c.c +++ b/arch/z80/src/z8/z8_i2c.c @@ -625,7 +625,7 @@ static int z8_i2c_reset(FAR struct i2c_master_s * dev) ****************************************************************************/ /**************************************************************************** - * Name: up_i2cinitialize + * Name: z8_i2cbus_initialize * * Description: * Initialize the selected I2C port. And return a unique instance of struct @@ -641,7 +641,7 @@ static int z8_i2c_reset(FAR struct i2c_master_s * dev) * ****************************************************************************/ -FAR struct i2c_master_s *up_i2cinitialize(int port) +FAR struct i2c_master_s *z8_i2cbus_initialize(int port) { FAR struct z8_i2cdev_s *i2c;