Rename up_i2c initialize and uninitialize functions using the correct MCU-specific naming

This commit is contained in:
Gregory Nutt 2016-02-02 12:08:23 -06:00
parent d2571985ef
commit 1e4f2ae2c1
25 changed files with 527 additions and 189 deletions

View File

@ -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;

View File

@ -0,0 +1,86 @@
/****************************************************************************
* arch/arm/src/efm32/efm32_i2c.h
*
* Copyright (C) 2009, 2011, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 <nuttx/config.h>
#include <nuttx/i2c/i2c_master.h>
/****************************************************************************
* 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 */

View File

@ -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;

View File

@ -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 <gnutt@nuttx.org>
*
* 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 <nuttx/config.h>
#include <nuttx/i2c/i2c_master.h>
#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 */

View File

@ -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;

View File

@ -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 <nuttx/config.h>
#include <nuttx/i2c/i2c_master.h>
#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 */

View File

@ -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;

View File

@ -46,7 +46,7 @@
************************************************************************************/
#include <nuttx/config.h>
#include <nuttx/i2c/i2c_master.h>
#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 */

View File

@ -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 */

View File

@ -41,6 +41,7 @@
************************************************************************************************/
#include <nuttx/config.h>
#include <nuttx/i2c/i2c_master.h>
#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 */

View File

@ -4472,7 +4472,7 @@ exit_terminate:
#else
/* Wake up the waiting thread */
sam_givesem(&epinfo->iocsem);
lpc43_givesem(&epinfo->iocsem);
#endif
errout_with_sem:

View File

@ -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;

View File

@ -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 <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -41,26 +41,47 @@
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/i2c/i2c_master.h>
#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 */

View File

@ -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;

View File

@ -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 <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -44,20 +44,44 @@
#include <nuttx/i2c/i2c_master.h>
#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 */

View File

@ -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;

View File

@ -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 <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -44,20 +44,44 @@
#include <nuttx/i2c/i2c_master.h>
#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 */

View File

@ -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;

View File

@ -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 <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -44,20 +44,44 @@
#include <nuttx/i2c/i2c_master.h>
#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 */

View File

@ -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 <nuttx/config.h>
#include <nuttx/i2c/i2c_master.h>
#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 <nuttx/config.h>
#include <nuttx/i2c/i2c_master.h>
#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 */

View File

@ -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;

View File

@ -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 */

View File

@ -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 <gnutt@nuttx.org>
*
* 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;

View File

@ -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
}

View File

@ -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;