diff --git a/arch/arm/src/efm32/efm32_i2c.c b/arch/arm/src/efm32/efm32_i2c.c index ca3c7cf83a1..8517f90837f 100644 --- a/arch/arm/src/efm32/efm32_i2c.c +++ b/arch/arm/src/efm32/efm32_i2c.c @@ -5,6 +5,9 @@ * Copyright (C) 2015 Pierre-noel Bouteville . All rights reserved. * Authors: Pierre-noel Bouteville * + * Copyright (C) 2016 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: @@ -277,8 +280,6 @@ struct efm32_i2c_inst_s */ uint32_t frequency; /* Frequency used in this instantiation */ - int address; /* Address used in this instantiation */ - uint32_t flags; /* Flags used in this instantiation */ }; /**************************************************************************** @@ -328,7 +329,6 @@ static int efm32_i2c_init(FAR struct efm32_i2c_priv_s *priv, int frequency); static int efm32_i2c_deinit(FAR struct efm32_i2c_priv_s *priv); static uint32_t efm32_i2c_setfrequency(FAR struct i2c_master_s *dev, uint32_t frequency); -static int efm32_i2c_setaddress(FAR struct i2c_master_s *dev, int addr, int nbits); static int efm32_i2c_process(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s *msgs, int count); static int efm32_i2c_transfer(FAR struct i2c_master_s *dev, @@ -405,7 +405,6 @@ static struct efm32_i2c_priv_s efm32_i2c1_priv = static const struct i2c_ops_s efm32_i2c_ops = { .setfrequency = efm32_i2c_setfrequency, - .setaddress = efm32_i2c_setaddress, .transfer = efm32_i2c_transfer }; @@ -1465,25 +1464,6 @@ static uint32_t efm32_i2c_setfrequency(FAR struct i2c_master_s *dev, return frequency; } -/**************************************************************************** - * Name: efm32_i2c_setaddress - * - * Description: - * Set the I2C slave address - * - ****************************************************************************/ - -static int efm32_i2c_setaddress(FAR struct i2c_master_s *dev, int addr, int nbits) -{ - efm32_i2c_sem_wait(dev); - - ((struct efm32_i2c_inst_s *)dev)->address = addr; - ((struct efm32_i2c_inst_s *)dev)->flags = (nbits == 10) ? I2C_M_TEN : 0; - - efm32_i2c_sem_post(dev); - return OK; -} - /**************************************************************************** * Name: efm32_i2c_process * @@ -1632,7 +1612,6 @@ static int efm32_i2c_process(FAR struct i2c_master_s *dev, priv->ptr = NULL; efm32_i2c_sem_post(dev); - return -errval; } @@ -1701,8 +1680,6 @@ FAR struct i2c_master_s *up_i2cinitialize(int port) inst->ops = &efm32_i2c_ops; inst->priv = priv; inst->frequency = 100000; - inst->address = 0; - inst->flags = 0; /* Initialize private data for the first time, increment reference count, * power-up hardware and configure GPIOs. diff --git a/arch/arm/src/lpc11xx/lpc11_i2c.c b/arch/arm/src/lpc11xx/lpc11_i2c.c index cecf091fcc2..0d478ac8d39 100644 --- a/arch/arm/src/lpc11xx/lpc11_i2c.c +++ b/arch/arm/src/lpc11xx/lpc11_i2c.c @@ -2,9 +2,10 @@ * arch/arm/src/lpc11xx/lpc11_i2c.c * * Copyright (C) 2012, 2014-2016 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * * Copyright (C) 2011 Li Zhuoyi. All rights reserved. * Author: Li Zhuoyi (Original author) - * Gregory Nutt * * Derived from arch/arm/src/lpc31xx/lpc31_i2c.c * @@ -105,7 +106,6 @@ struct lpc11_i2cdev_s { struct i2c_master_s dev; /* Generic I2C device */ - struct i2c_msg_s msg; /* a single message for legacy read/write */ unsigned int base; /* Base address of registers */ uint16_t irqid; /* IRQ for this device */ @@ -114,11 +114,11 @@ struct lpc11_i2cdev_s volatile uint8_t state; /* State of state machine */ WDOG_ID timeout; /* watchdog to timeout when bus hung */ - struct i2c_msg_s *msgs; /* remaining transfers - first one is in progress */ - unsigned int nmsg; /* number of transfer remaining */ + struct i2c_msg_s *msgs; /* Remaining transfers - first one is in progress */ + unsigned int nmsg; /* Number of transfer remaining */ - uint16_t wrcnt; /* number of bytes sent to tx fifo */ - uint16_t rdcnt; /* number of bytes read from rx fifo */ + uint16_t wrcnt; /* Number of bytes sent to tx fifo */ + uint16_t rdcnt; /* Number of bytes read from rx fifo */ }; /**************************************************************************** @@ -134,8 +134,6 @@ static void lpc11_i2c_timeout(int argc, uint32_t arg, ...); static uint32_t lpc11_i2c_setfrequency(FAR struct i2c_master_s *dev, uint32_t frequency); -static int lpc11_i2c_setaddress(FAR struct i2c_master_s *dev, int addr, - int nbits); static int lpc11_i2c_transfer(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s *msgs, int count); static void lpc11_stopnext(struct lpc11_i2cdev_s *priv); @@ -157,7 +155,6 @@ static struct lpc11_i2cdev_s g_i2c2dev; struct i2c_ops_s lpc11_i2c_ops = { .setfrequency = lpc11_i2c_setfrequency, - .setaddress = lpc11_i2c_setaddress, .transfer = lpc11_i2c_transfer }; @@ -198,27 +195,6 @@ static uint32_t lpc11_i2c_setfrequency(FAR struct i2c_master_s *dev, return frequency; } -/**************************************************************************** - * Name: lpc11_i2c_setaddress - * - * Description: - * Set the I2C slave address for a subsequent read/write - * - ****************************************************************************/ - -static int lpc11_i2c_setaddress(FAR struct i2c_master_s *dev, int addr, - int nbits) -{ - struct lpc11_i2cdev_s *priv = (struct lpc11_i2cdev_s *)dev; - - DEBUGASSERT(dev != NULL); - DEBUGASSERT(nbits == 7); - - priv->msg.addr = addr; - - return OK; -} - /**************************************************************************** * Name: lpc11_i2c_start * diff --git a/arch/arm/src/lpc17xx/lpc17_i2c.c b/arch/arm/src/lpc17xx/lpc17_i2c.c index 80324bbb23f..3464c5a0424 100644 --- a/arch/arm/src/lpc17xx/lpc17_i2c.c +++ b/arch/arm/src/lpc17xx/lpc17_i2c.c @@ -2,9 +2,10 @@ * arch/arm/src/lpc17xx/lpc17_i2c.c * * Copyright (C) 2012, 2014-2016 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * * Copyright (C) 2011 Li Zhuoyi. All rights reserved. * Author: Li Zhuoyi (Original author) - * Gregory Nutt * * Derived from arch/arm/src/lpc31xx/lpc31_i2c.c * @@ -105,7 +106,6 @@ struct lpc17_i2cdev_s { struct i2c_master_s dev; /* Generic I2C device */ - struct i2c_msg_s msg; /* a single message for legacy read/write */ unsigned int base; /* Base address of registers */ uint16_t irqid; /* IRQ for this device */ @@ -134,8 +134,6 @@ static void lpc17_i2c_timeout(int argc, uint32_t arg, ...); static uint32_t lpc17_i2c_setfrequency(FAR struct i2c_master_s *dev, uint32_t frequency); -static int lpc17_i2c_setaddress(FAR struct i2c_master_s *dev, int addr, - int nbits); static int lpc17_i2c_transfer(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s *msgs, int count); static void lpc17_stopnext(struct lpc17_i2cdev_s *priv); @@ -157,7 +155,6 @@ static struct lpc17_i2cdev_s g_i2c2dev; struct i2c_ops_s lpc17_i2c_ops = { .setfrequency = lpc17_i2c_setfrequency, - .setaddress = lpc17_i2c_setaddress, .transfer = lpc17_i2c_transfer }; @@ -198,27 +195,6 @@ static uint32_t lpc17_i2c_setfrequency(FAR struct i2c_master_s *dev, return frequency; } -/**************************************************************************** - * Name: lpc17_i2c_setaddress - * - * Description: - * Set the I2C slave address for a subsequent read/write - * - ****************************************************************************/ - -static int lpc17_i2c_setaddress(FAR struct i2c_master_s *dev, int addr, - int nbits) -{ - struct lpc17_i2cdev_s *priv = (struct lpc17_i2cdev_s *)dev; - - DEBUGASSERT(dev != NULL); - DEBUGASSERT(nbits == 7); - - priv->msg.addr = addr; - - return OK; -} - /**************************************************************************** * Name: lpc17_i2c_start * diff --git a/arch/arm/src/lpc2378/lpc23xx_i2c.c b/arch/arm/src/lpc2378/lpc23xx_i2c.c index 78f4de2345d..1c5c9b74588 100644 --- a/arch/arm/src/lpc2378/lpc23xx_i2c.c +++ b/arch/arm/src/lpc2378/lpc23xx_i2c.c @@ -7,9 +7,10 @@ * Derived from arch/arm/src/lpc17xx/lpc17xx_i2c.c * * Copyright (C) 2012, 2014-2016 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * * Copyright (C) 2011 Li Zhuoyi. All rights reserved. * Author: Li Zhuoyi (Original author) - * Gregory Nutt * * Derived from arch/arm/src/lpc31xx/lpc31_i2c.c * @@ -110,7 +111,6 @@ struct lpc2378_i2cdev_s { struct i2c_master_s dev; /* Generic I2C device */ - struct i2c_msg_s msg; /* a single message for legacy read/write */ unsigned int base; /* Base address of registers */ uint16_t irqid; /* IRQ for this device */ @@ -139,8 +139,6 @@ static void lpc2378_i2c_timeout(int argc, uint32_t arg, ...); static uint32_t lpc2378_i2c_setfrequency(FAR struct i2c_master_s *dev, uint32_t frequency); -static int lpc2378_i2c_setaddress(FAR struct i2c_master_s *dev, int addr, - int nbits); static int lpc2378_i2c_transfer(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s *msgs, int count); static void lpc2378_stopnext(struct lpc2378_i2cdev_s *priv); @@ -162,7 +160,6 @@ static struct lpc2378_i2cdev_s g_i2c2dev; struct i2c_ops_s lpc2378_i2c_ops = { .setfrequency = lpc2378_i2c_setfrequency, - .setaddress = lpc2378_i2c_setaddress, .transfer = lpc2378_i2c_transfer }; @@ -203,27 +200,6 @@ static uint32_t lpc2378_i2c_setfrequency(FAR struct i2c_master_s *dev, return frequency; } -/**************************************************************************** - * Name: lpc2378_i2c_setaddress - * - * Description: - * Set the I2C slave address for a subsequent read/write - * - ****************************************************************************/ - -static int lpc2378_i2c_setaddress(FAR struct i2c_master_s *dev, int addr, - int nbits) -{ - struct lpc2378_i2cdev_s *priv = (struct lpc2378_i2cdev_s *)dev; - - DEBUGASSERT(dev != NULL); - DEBUGASSERT(nbits == 7); - - priv->msg.addr = addr; - - return OK; -} - /**************************************************************************** * Name: lpc2378_i2c_start * diff --git a/arch/arm/src/lpc31xx/lpc31_i2c.c b/arch/arm/src/lpc31xx/lpc31_i2c.c index f10d8317501..551a7fea231 100644 --- a/arch/arm/src/lpc31xx/lpc31_i2c.c +++ b/arch/arm/src/lpc31xx/lpc31_i2c.c @@ -3,7 +3,7 @@ * * Author: David Hewson * - * Copyright (C) 2010-2011, 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2010-2011, 2014, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -80,7 +80,6 @@ struct lpc31_i2cdev_s { struct i2c_master_s dev; /* Generic I2C device */ - struct i2c_msg_s msg; /* a single message for legacy read/write */ unsigned int base; /* Base address of registers */ uint16_t clkid; /* Clock for this device */ uint16_t rstid; /* Reset for this device */ @@ -127,15 +126,12 @@ static void i2c_reset(struct lpc31_i2cdev_s *priv); static uint32_t i2c_setfrequency(FAR struct i2c_master_s *dev, uint32_t frequency); -static int i2c_setaddress(FAR struct i2c_master_s *dev, int addr, - int nbits); static int i2c_transfer(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s *msgs, int count); struct i2c_ops_s lpc31_i2c_ops = { .setfrequency = i2c_setfrequency, - .setaddress = i2c_setaddress, .transfer = i2c_transfer }; @@ -249,27 +245,6 @@ static uint32_t i2c_setfrequency(FAR struct i2c_master_s *dev, uint32_t frequenc return frequency; } -/**************************************************************************** - * Name: lpc31_i2c_setaddress - * - * Description: - * Set the I2C slave address for a subsequent read/write - * - ****************************************************************************/ - -static int i2c_setaddress(FAR struct i2c_master_s *dev, int addr, int nbits) -{ - struct lpc31_i2cdev_s *priv = (struct lpc31_i2cdev_s *) dev; - - DEBUGASSERT(dev != NULL); - DEBUGASSERT(nbits == 7 || nbits == 10); - - priv->msg.addr = addr; - priv->msg.flags = (nbits == 7) ? 0 : I2C_M_TEN; - - return OK; -} - /**************************************************************************** * Name: i2c_transfer * diff --git a/arch/arm/src/lpc43xx/lpc43_i2c.c b/arch/arm/src/lpc43xx/lpc43_i2c.c index d30a2a91da3..658f5520528 100644 --- a/arch/arm/src/lpc43xx/lpc43_i2c.c +++ b/arch/arm/src/lpc43xx/lpc43_i2c.c @@ -99,7 +99,6 @@ struct lpc43_i2cdev_s { struct i2c_master_s dev; /* Generic I2C device */ - struct i2c_msg_s msg; /* a single message for legacy read/write */ unsigned int base; /* Base address of registers */ uint16_t irqid; /* IRQ for this device */ uint32_t baseFreq; /* branch frequency */ @@ -138,15 +137,12 @@ static void lpc43_i2c_timeout(int argc, uint32_t arg, ...); static uint32_t lpc43_i2c_setfrequency(FAR struct i2c_master_s *dev, uint32_t frequency); -static int lpc43_i2c_setaddress(FAR struct i2c_master_s *dev, int addr, - int nbits); static int lpc43_i2c_transfer(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s *msgs, int count); struct i2c_ops_s lpc43_i2c_ops = { .setfrequency = lpc43_i2c_setfrequency, - .setaddress = lpc43_i2c_setaddress, .transfer = lpc43_i2c_transfer }; @@ -187,27 +183,6 @@ static uint32_t lpc43_i2c_setfrequency(FAR struct i2c_master_s *dev, return frequency; } -/**************************************************************************** - * Name: lpc43_i2c_setaddress - * - * Description: - * Set the I2C slave address for a subsequent read/write - * - ****************************************************************************/ - -static int lpc43_i2c_setaddress(FAR struct i2c_master_s *dev, int addr, - int nbits) -{ - struct lpc43_i2cdev_s *priv = (struct lpc43_i2cdev_s *)dev; - - DEBUGASSERT(dev != NULL); - DEBUGASSERT(nbits == 7); - - priv->msg.addr = addr; - - return OK; -} - /**************************************************************************** * Name: lpc43_i2c_start * diff --git a/arch/arm/src/sam34/sam_twi.c b/arch/arm/src/sam34/sam_twi.c index d76bf8fdc5a..b04da8159b3 100644 --- a/arch/arm/src/sam34/sam_twi.c +++ b/arch/arm/src/sam34/sam_twi.c @@ -122,8 +122,6 @@ struct twi_dev_s uint32_t frequency; /* TWI input clock frequency */ uint32_t deffreq; /* Selected TWI frequency */ uint16_t irq; /* IRQ number for this device */ - uint16_t address; /* Slave address */ - uint16_t flags; /* Transfer flags */ uint8_t msgc; /* Number of message in the message list */ uint8_t twi; /* TWI peripheral number (for debug output) */ uint8_t pid; /* TWI peripheral ID */ @@ -191,7 +189,6 @@ static void twi_startmessage(struct twi_dev_s *priv, struct i2c_msg_s *msg); static uint32_t twi_setfrequency(FAR struct i2c_master_s *dev, uint32_t frequency); -static int twi_setaddress(FAR struct i2c_master_s *dev, int addr, int nbits); static int twi_transfer(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s *msgs, int count); @@ -217,7 +214,6 @@ static struct twi_dev_s g_twi1; struct i2c_ops_s g_twiops = { .setfrequency = twi_setfrequency, - .setaddress = twi_setaddress, .transfer = twi_transfer }; @@ -719,34 +715,6 @@ static uint32_t twi_setfrequency(FAR struct i2c_master_s *dev, uint32_t frequenc return actual; } -/**************************************************************************** - * Name: twi_setaddress - * - * Description: - * Set the I2C slave address for a subsequent read/write - * - ****************************************************************************/ - -static int twi_setaddress(FAR struct i2c_master_s *dev, int addr, int nbits) -{ - struct twi_dev_s *priv = (struct twi_dev_s *) dev; - - i2cvdbg("TWI%d address: %02x nbits: %d\n", priv->twi, addr, nbits); - DEBUGASSERT(dev != NULL && nbits == 7); - - /* Get exclusive access to the device */ - - twi_takesem(&priv->exclsem); - - /* Remember 7- or 10-bit address */ - - priv->address = addr; - priv->flags = (nbits == 10) ? I2C_M_TEN : 0; - - twi_givesem(&priv->exclsem); - return OK; -} - /**************************************************************************** * Name: twi_transfer * @@ -1023,8 +991,6 @@ struct i2c_master_s *up_i2cinitialize(int bus) /* Initialize the device structure */ priv->dev.ops = &g_twiops; - priv->address = 0; - priv->flags = 0; sem_init(&priv->exclsem, 0, 1); sem_init(&priv->waitsem, 0, 0); diff --git a/arch/arm/src/sama5/sam_twi.c b/arch/arm/src/sama5/sam_twi.c index c3c072094f1..802ff9110ff 100644 --- a/arch/arm/src/sama5/sam_twi.c +++ b/arch/arm/src/sama5/sam_twi.c @@ -165,8 +165,6 @@ struct twi_dev_s #ifdef CONFIG_I2C_RESET uint32_t frequency; /* TWI transfer clock frequency */ #endif - uint16_t address; /* Slave address */ - uint16_t flags; /* Transfer flags */ uint8_t msgc; /* Number of message in the message list */ sem_t exclsem; /* Only one thread can access at a time */ @@ -238,7 +236,6 @@ static void twi_startmessage(struct twi_dev_s *priv, struct i2c_msg_s *msg); static uint32_t twi_setfrequency(FAR struct i2c_master_s *dev, uint32_t frequency); -static int twi_setaddress(FAR struct i2c_master_s *dev, int addr, int nbits); static int twi_transfer(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s *msgs, int count); @@ -315,7 +312,6 @@ static struct twi_dev_s g_twi3; struct i2c_ops_s g_twiops = { .setfrequency = twi_setfrequency, - .setaddress = twi_setaddress, .transfer = twi_transfer }; @@ -849,34 +845,6 @@ static uint32_t twi_setfrequency(FAR struct i2c_master_s *dev, uint32_t frequenc return actual; } -/**************************************************************************** - * Name: twi_setaddress - * - * Description: - * Set the I2C slave address for a subsequent read/write - * - ****************************************************************************/ - -static int twi_setaddress(FAR struct i2c_master_s *dev, int addr, int nbits) -{ - struct twi_dev_s *priv = (struct twi_dev_s *) dev; - - i2cvdbg("TWI%d address: %02x nbits: %d\n", priv->attr->twi, addr, nbits); - DEBUGASSERT(dev != NULL && nbits == 7); - - /* Get exclusive access to the device */ - - twi_takesem(&priv->exclsem); - - /* Remember 7- or 10-bit address */ - - priv->address = addr; - priv->flags = (nbits == 10) ? I2C_M_TEN : 0; - - twi_givesem(&priv->exclsem); - return OK; -} - /**************************************************************************** * Name: twi_transfer * @@ -1240,8 +1208,6 @@ struct i2c_master_s *up_i2cinitialize(int bus) /* Initialize the TWI driver structure */ priv->dev.ops = &g_twiops; - priv->address = 0; - priv->flags = 0; (void)sem_init(&priv->exclsem, 0, 1); (void)sem_init(&priv->waitsem, 0, 0); diff --git a/arch/arm/src/samv7/sam_twihs.c b/arch/arm/src/samv7/sam_twihs.c index 66993661388..77b05bca503 100644 --- a/arch/arm/src/samv7/sam_twihs.c +++ b/arch/arm/src/samv7/sam_twihs.c @@ -162,8 +162,6 @@ struct twi_dev_s #ifdef CONFIG_I2C_RESET uint32_t frequency; /* TWIHS transfer clock frequency */ #endif - uint16_t address; /* Slave address */ - uint16_t flags; /* Transfer flags */ bool initd; /* True :device has been initialized */ uint8_t msgc; /* Number of message in the message list */ @@ -233,7 +231,6 @@ static void twi_startmessage(struct twi_dev_s *priv, struct i2c_msg_s *msg); static uint32_t twi_setfrequency(FAR struct i2c_master_s *dev, uint32_t frequency); -static int twi_setaddress(FAR struct i2c_master_s *dev, int addr, int nbits); static int twi_transfer(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s *msgs, int count); @@ -295,7 +292,6 @@ static struct twi_dev_s g_twi2; struct i2c_ops_s g_twiops = { .setfrequency = twi_setfrequency, - .setaddress = twi_setaddress, .transfer = twi_transfer }; @@ -876,34 +872,6 @@ static uint32_t twi_setfrequency(FAR struct i2c_master_s *dev, uint32_t frequenc return actual; } -/**************************************************************************** - * Name: twi_setaddress - * - * Description: - * Set the I2C slave address for a subsequent read/write - * - ****************************************************************************/ - -static int twi_setaddress(FAR struct i2c_master_s *dev, int addr, int nbits) -{ - struct twi_dev_s *priv = (struct twi_dev_s *) dev; - - i2cvdbg("TWIHS%d address: %02x nbits: %d\n", priv->attr->twi, addr, nbits); - DEBUGASSERT(dev != NULL && nbits == 7); - - /* Get exclusive access to the device */ - - twi_takesem(&priv->exclsem); - - /* Remember 7- or 10-bit address */ - - priv->address = addr; - priv->flags = (nbits == 10) ? I2C_M_TEN : 0; - - twi_givesem(&priv->exclsem); - return OK; -} - /**************************************************************************** * Name: twi_transfer * @@ -1257,8 +1225,6 @@ struct i2c_master_s *up_i2cinitialize(int bus) /* Initialize the TWIHS driver structure */ priv->dev.ops = &g_twiops; - priv->address = 0; - priv->flags = 0; (void)sem_init(&priv->exclsem, 0, 1); (void)sem_init(&priv->waitsem, 0, 0); diff --git a/arch/arm/src/stm32/stm32_i2c.c b/arch/arm/src/stm32/stm32_i2c.c index 42d01c6c9ee..3b2aca1990f 100644 --- a/arch/arm/src/stm32/stm32_i2c.c +++ b/arch/arm/src/stm32/stm32_i2c.c @@ -285,8 +285,6 @@ struct stm32_i2c_inst_s struct stm32_i2c_priv_s *priv; /* Common driver private data structure */ uint32_t frequency; /* Frequency used in this instantiation */ - int address; /* Address used in this instantiation */ - uint16_t flags; /* Flags used in this instantiation */ }; /************************************************************************************ @@ -350,7 +348,6 @@ static int stm32_i2c_init(FAR struct stm32_i2c_priv_s *priv); static int stm32_i2c_deinit(FAR struct stm32_i2c_priv_s *priv); static uint32_t stm32_i2c_setfrequency(FAR struct i2c_master_s *dev, uint32_t frequency); -static int stm32_i2c_setaddress(FAR struct i2c_master_s *dev, int addr, int nbits); static int stm32_i2c_process(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s *msgs, int count); static int stm32_i2c_transfer(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s *msgs, @@ -473,7 +470,6 @@ static struct stm32_i2c_priv_s stm32_i2c3_priv = static const struct i2c_ops_s stm32_i2c_ops = { .setfrequency = stm32_i2c_setfrequency, - .setaddress = stm32_i2c_setaddress, .transfer = stm32_i2c_transfer }; @@ -1624,25 +1620,6 @@ static uint32_t stm32_i2c_setfrequency(FAR struct i2c_master_s *dev, uint32_t fr return ((struct stm32_i2c_inst_s *)dev)->frequency; } -/************************************************************************************ - * Name: stm32_i2c_setaddress - * - * Description: - * Set the I2C slave address - * - ************************************************************************************/ - -static int stm32_i2c_setaddress(FAR struct i2c_master_s *dev, int addr, int nbits) -{ - stm32_i2c_sem_wait(dev); - - ((struct stm32_i2c_inst_s *)dev)->address = addr; - ((struct stm32_i2c_inst_s *)dev)->flags = (nbits == 10) ? I2C_M_TEN : 0; - - stm32_i2c_sem_post(dev); - return OK; -} - /************************************************************************************ * Name: stm32_i2c_process * @@ -1921,8 +1898,6 @@ FAR struct i2c_master_s *up_i2cinitialize(int port) inst->ops = &stm32_i2c_ops; inst->priv = priv; inst->frequency = 100000; - inst->address = 0; - inst->flags = 0; /* Initialize private data for the first time, increment reference count, * power-up hardware and configure GPIOs. diff --git a/arch/arm/src/stm32/stm32_i2c_alt.c b/arch/arm/src/stm32/stm32_i2c_alt.c index c0dd5a7af69..653631c9dd5 100644 --- a/arch/arm/src/stm32/stm32_i2c_alt.c +++ b/arch/arm/src/stm32/stm32_i2c_alt.c @@ -314,8 +314,6 @@ struct stm32_i2c_inst_s struct stm32_i2c_priv_s *priv; /* Common driver private data structure */ uint32_t frequency; /* Frequency used in this instantiation */ - int address; /* Address used in this instantiation */ - uint16_t flags; /* Flags used in this instantiation */ }; /************************************************************************************ @@ -379,7 +377,6 @@ static int stm32_i2c_init(FAR struct stm32_i2c_priv_s *priv); static int stm32_i2c_deinit(FAR struct stm32_i2c_priv_s *priv); static uint32_t stm32_i2c_setfrequency(FAR struct i2c_master_s *dev, uint32_t frequency); -static int stm32_i2c_setaddress(FAR struct i2c_master_s *dev, int addr, int nbits); static int stm32_i2c_process(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s *msgs, int count); static int stm32_i2c_transfer(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s *msgs, @@ -481,7 +478,6 @@ static struct stm32_i2c_priv_s stm32_i2c3_priv = static const struct i2c_ops_s stm32_i2c_ops = { .setfrequency = stm32_i2c_setfrequency, - .setaddress = stm32_i2c_setaddress, .transfer = stm32_i2c_transfer }; @@ -2055,25 +2051,6 @@ static uint32_t stm32_i2c_setfrequency(FAR struct i2c_master_s *dev, uint32_t fr return ((struct stm32_i2c_inst_s *)dev)->frequency; } -/************************************************************************************ - * Name: stm32_i2c_setaddress - * - * Description: - * Set the I2C slave address - * - ************************************************************************************/ - -static int stm32_i2c_setaddress(FAR struct i2c_master_s *dev, int addr, int nbits) -{ - stm32_i2c_sem_wait(dev); - - ((struct stm32_i2c_inst_s *)dev)->address = addr; - ((struct stm32_i2c_inst_s *)dev)->flags = (nbits == 10) ? I2C_M_TEN : 0; - - stm32_i2c_sem_post(dev); - return OK; -} - /************************************************************************************ * Name: stm32_i2c_process * @@ -2365,8 +2342,6 @@ FAR struct i2c_master_s *up_i2cinitialize(int port) inst->ops = &stm32_i2c_ops; inst->priv = priv; inst->frequency = 100000; - inst->address = 0; - inst->flags = 0; /* Initialize private data for the first time, increment reference count, * power-up hardware and configure GPIOs. diff --git a/arch/arm/src/stm32/stm32f30xxx_i2c.c b/arch/arm/src/stm32/stm32f30xxx_i2c.c index 9412fd23d0a..8739982cbca 100644 --- a/arch/arm/src/stm32/stm32f30xxx_i2c.c +++ b/arch/arm/src/stm32/stm32f30xxx_i2c.c @@ -278,8 +278,6 @@ struct stm32_i2c_inst_s struct stm32_i2c_priv_s *priv; /* Common driver private data structure */ uint32_t frequency; /* Frequency used in this instantiation */ - int address; /* Address used in this instantiation */ - uint16_t flags; /* Flags used in this instantiation */ }; /************************************************************************************ @@ -336,7 +334,6 @@ static int stm32_i2c_init(FAR struct stm32_i2c_priv_s *priv); static int stm32_i2c_deinit(FAR struct stm32_i2c_priv_s *priv); static uint32_t stm32_i2c_setfrequency(FAR struct i2c_master_s *dev, uint32_t frequency); -static int stm32_i2c_setaddress(FAR struct i2c_master_s *dev, int addr, int nbits); static int stm32_i2c_process(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s *msgs, int count); static int stm32_i2c_transfer(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s *msgs, @@ -438,7 +435,6 @@ struct stm32_i2c_priv_s stm32_i2c3_priv = struct i2c_ops_s stm32_i2c_ops = { .setfrequency = stm32_i2c_setfrequency, - .setaddress = stm32_i2c_setaddress, .transfer = stm32_i2c_transfer }; @@ -1651,25 +1647,6 @@ static uint32_t stm32_i2c_setfrequency(FAR struct i2c_master_s *dev, uint32_t fr return ((struct stm32_i2c_inst_s *)dev)->frequency; } -/************************************************************************************ - * Name: stm32_i2c_setaddress - * - * Description: - * Set the I2C slave address - * - ************************************************************************************/ - -static int stm32_i2c_setaddress(FAR struct i2c_master_s *dev, int addr, int nbits) -{ - stm32_i2c_sem_wait(dev); - - ((struct stm32_i2c_inst_s *)dev)->address = addr; - ((struct stm32_i2c_inst_s *)dev)->flags = (nbits == 10) ? I2C_M_TEN : 0; - - stm32_i2c_sem_post(dev); - return OK; -} - /************************************************************************************ * Name: stm32_i2c_process * @@ -1922,8 +1899,6 @@ FAR struct i2c_master_s *up_i2cinitialize(int port) inst->ops = &stm32_i2c_ops; inst->priv = priv; inst->frequency = 400000; - inst->address = 0; - inst->flags = 0; /* Init private data for the first time, increment refs count, * power-up hardware and configure GPIOs. diff --git a/arch/arm/src/tiva/tiva_i2c.c b/arch/arm/src/tiva/tiva_i2c.c index 15651b87879..61ede0b3473 100644 --- a/arch/arm/src/tiva/tiva_i2c.c +++ b/arch/arm/src/tiva/tiva_i2c.c @@ -260,8 +260,6 @@ struct tiva_i2c_inst_s struct tiva_i2c_priv_s *priv; /* Common driver private data structure */ uint32_t frequency; /* Frequency used in this instantiation */ - uint16_t address; /* Address used in this instantiation */ - uint16_t flags; /* Flags used in this instantiation */ }; /************************************************************************************ @@ -342,7 +340,6 @@ static uint32_t tiva_i2c_setclock(struct tiva_i2c_priv_s *priv, uint32_t frequency); static uint32_t tiva_i2c_setfrequency(struct i2c_master_s *dev, uint32_t frequency); -static int tiva_i2c_setaddress(struct i2c_master_s *dev, int addr, int nbits); static int tiva_i2c_process(struct i2c_master_s *dev, struct i2c_msg_s *msgv, int msgc); static int tiva_i2c_transfer(struct i2c_master_s *dev, struct i2c_msg_s *msgv, @@ -577,7 +574,6 @@ static struct tiva_i2c_priv_s tiva_i2c9_priv; static const struct i2c_ops_s tiva_i2c_ops = { .setfrequency = tiva_i2c_setfrequency, - .setaddress = tiva_i2c_setaddress, .transfer = tiva_i2c_transfer }; @@ -1903,30 +1899,6 @@ static uint32_t tiva_i2c_setfrequency(struct i2c_master_s *dev, uint32_t frequen return frequency; } -/************************************************************************************ - * Name: tiva_i2c_setaddress - * - * Description: - * Set the I2C slave address - * - ************************************************************************************/ - -static int tiva_i2c_setaddress(struct i2c_master_s *dev, int addr, int nbits) -{ - struct tiva_i2c_inst_s *inst = (struct tiva_i2c_inst_s *)dev; - - DEBUGASSERT(inst && inst->priv && inst->priv->config); - i2cvdbg("I2C%d: addr: %02x nbits=%d\n", inst->priv->config->devno, addr, nbits); - - tiva_i2c_sem_wait(dev); - - inst->address = addr; - inst->flags = (nbits == 10) ? I2C_M_TEN : 0; - - tiva_i2c_sem_post(dev); - return OK; -} - /************************************************************************************ * Name: tiva_i2c_process * @@ -2201,8 +2173,6 @@ struct i2c_master_s *up_i2cinitialize(int port) inst->ops = &tiva_i2c_ops; inst->priv = priv; inst->frequency = 100000; - inst->address = 0; - inst->flags = 0; /* Initialize private data for the first time, increment reference count, * power-up hardware and configure GPIOs. diff --git a/arch/z80/src/ez80/ez80_i2c.c b/arch/z80/src/ez80/ez80_i2c.c index c3491fbe8a9..c342939553b 100644 --- a/arch/z80/src/ez80/ez80_i2c.c +++ b/arch/z80/src/ez80/ez80_i2c.c @@ -98,8 +98,6 @@ static int ez80_i2c_write_transfer(FAR struct ez80_i2cdev_s *priv, static uint32_t ez80_i2c_setfrequency(FAR struct i2c_master_s *dev, uint32_t frequency); -static int ez80_i2c_setaddress(FAR struct i2c_master_s *dev, - int addr, int nbits); static int ez80_i2c_transfer(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s *msgs, int count); @@ -122,7 +120,6 @@ static sem_t g_i2csem; /* Serialize I2C transfers */ const struct i2c_ops_s g_ops = { ez80_i2c_setfrequency, - ez80_i2c_setaddress, ez80_i2c_transfer }; @@ -819,37 +816,6 @@ static uint32_t ez80_i2c_setfrequency(FAR struct i2c_master_s *dev, return frequency; } -/**************************************************************************** - * Name: ez80_i2c_setaddress - * - * Description: - * Set the I2C slave address. This frequency will be retained in the struct - * i2c_master_s instance and will be used with all transfers. Required. - * - * Input Parameters: - * dev - Device-specific state data - * address - The I2C slave address - * nbits - The number of address bits provided (7 or 10) - * - * Returned Value: - * Returns the actual frequency selected - * - ****************************************************************************/ - -static int ez80_i2c_setaddress(FAR struct i2c_master_s *dev, int addr, - int nbits) -{ - FAR struct ez80_i2cdev_s *priv = (FAR struct ez80_i2cdev_s *)dev; - - DEBUGASSERT(dev != NULL && (unsigned)addr < 0x80 && (nbits == 7 || nbits == 10)); - - /* Save the 7- or 10-bit address */ - - priv->addr = addr; - priv->addr10 = (nbits == 10); - return OK; -} - /**************************************************************************** * Name: ez80_i2c_transfer * @@ -893,7 +859,12 @@ static int ez80_i2c_transfer(FAR struct i2c_master_s *dev, for (i = 0; i < count; i++) { - msg = &msgs[i]; + msg = &msgs[i]; + + /* Set the I2C address */ + + priv->addr = msg->addr; + priv->addr10 = (msg->flags & I2C_M_TEN) != 0); /* Is this the last message in the sequence? */ diff --git a/arch/z80/src/z8/z8_i2c.c b/arch/z80/src/z8/z8_i2c.c index 0f0ec1fc786..3b7690b4f9b 100644 --- a/arch/z80/src/z8/z8_i2c.c +++ b/arch/z80/src/z8/z8_i2c.c @@ -92,8 +92,6 @@ static int z8_i2c_write_transfer(FAR struct z8_i2cdev_s *priv, static uint32_t z8_i2c_setfrequency(FAR struct i2c_master_s *dev, uint32_t frequency); -static int z8_i2c_setaddress(FAR struct i2c_master_s *dev, int addr, - int nbits); static int z8_i2c_transfer(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s *msgs, int count); @@ -116,7 +114,6 @@ static sem_t g_i2csem; /* Serialize I2C transfers */ const struct i2c_ops_s g_ops = { z8_i2c_setfrequency, - z8_i2c_setaddress, z8_i2c_transfer, }; @@ -498,45 +495,6 @@ static uint32_t z8_i2c_setfrequency(FAR struct i2c_master_s *dev, return OK; } -/**************************************************************************** - * Name: z8_i2c_setaddress - * - * Description: - * Set the I2C slave address. This frequency will be retained in the struct - * i2c_master_s instance and will be used with all transfers. Required. - * - * Input Parameters: - * dev - Device-specific state data - * address - The I2C slave address - * nbits - The number of address bits provided (7 or 10) - * - * Returned Value: - * Returns the actual frequency selected - * - ****************************************************************************/ - -static int z8_i2c_setaddress(FAR struct i2c_master_s *dev, int addr, - int nbits) -{ - FAR struct z8_i2cdev_s *priv = (FAR struct z8_i2cdev_s *)dev; - - /* Sanity Check */ - -#ifdef CONFIG_DEBUG - if (!dev || (unsigned)addr > 0x7f) - { - dbg("Invalid inputs\n"); - return -EINVAL; - } -#endif - - /* Save the 7-bit address (10-bit address not yet supported) */ - - DEBUGASSERT(nbits == 7); - priv->addr = (uint8_t)addr; - return OK; -} - /**************************************************************************** * Name: z8_i2c_transfer * @@ -580,7 +538,12 @@ static int z8_i2c_transfer(FAR struct i2c_master_s *dev, for (i = 0; i < count; i++) { - msg = &msgs[i]; + msg = &msgs[i]; + + /* Set the I2C address */ + + priv->addr = msg->addr; + DEBUGASSERT((msg->flags & I2C_M_TEN) == 0); /* Is this the last message in the sequence? */