summaryrefslogtreecommitdiff
path: root/chip/nrf51/i2c.c
diff options
context:
space:
mode:
authorDenis Brockus <dbrockus@chromium.org>2019-06-25 12:44:16 -0600
committerCommit Bot <commit-bot@chromium.org>2019-07-19 21:11:02 +0000
commitd1a18f82ed831d4e640336ff5571f5fa64bc7b36 (patch)
treec46aeb6136de1c27c66e3d5f662e9620161bef7b /chip/nrf51/i2c.c
parent1f14229fa7e499dfcee07d17add187598ff0a46c (diff)
downloadchrome-ec-d1a18f82ed831d4e640336ff5571f5fa64bc7b36.tar.gz
Use 7bit I2C/SPI slave addresses in EC
Opt for 7bit slave addresses in EC code. If 8bit is expected by a driver, make it local and show this in the naming. Use __7b, __7bf and __8b as name extensions for i2c/spi addresses used in the EC codebase. __7b indicates a 7bit address by itself. __7bf indicates a 7bit address with optional flags attached. __8b indicates a 8bit address by itself. Allow space for 10bit addresses, even though this is not currently being used by any of our attached devices. These extensions are for verification purposes only and will be removed in the last pass of this ticket. I want to make sure the variable names reflect the type to help eliminate future 7/8/7-flags confusion. BUG=chromium:971296 BRANCH=none TEST=make buildall -j Change-Id: I2fc3d1b52ce76184492b2aaff3060f486ca45f45 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1699893 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'chip/nrf51/i2c.c')
-rw-r--r--chip/nrf51/i2c.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/chip/nrf51/i2c.c b/chip/nrf51/i2c.c
index 440506511b..7f4903ee1b 100644
--- a/chip/nrf51/i2c.c
+++ b/chip/nrf51/i2c.c
@@ -141,13 +141,13 @@ static void handle_i2c_error(int port, int rv)
i2c_recover(port);
}
-static int i2c_master_write(int port, int slave_addr, const uint8_t *data,
- int size, int stop)
+static int i2c_master_write__7bf(const int port, const uint16_t slave_addr__7bf,
+ const uint8_t *data, int size, int stop)
{
int bytes_sent;
int timeout = I2C_TIMEOUT;
- NRF51_TWI_ADDRESS(port) = slave_addr >> 1;
+ NRF51_TWI_ADDRESS__7b(port) = I2C_GET_ADDR__7b(slave_addr__7bf);
/* Clear the sent bit */
NRF51_TWI_TXDSENT(port) = 0;
@@ -187,12 +187,13 @@ static int i2c_master_write(int port, int slave_addr, const uint8_t *data,
return EC_SUCCESS;
}
-static int i2c_master_read(int port, int slave_addr, uint8_t *data, int size)
+static int i2c_master_read__7bf(const int port, const uint16_t slave__addr__7bf,
+ uint8_t *data, int size)
{
int curr_byte;
int timeout = I2C_TIMEOUT;
- NRF51_TWI_ADDRESS(port) = slave_addr >> 1;
+ NRF51_TWI_ADDRESS__7b(port) = I2C_GET_ADDR__7b(slave_addr__7bf);
if (size == 1) /* Last byte: stop after this one. */
NRF51_PPI_TEP(i2c_ppi_chan[port]) =
@@ -252,7 +253,8 @@ static int i2c_master_read(int port, int slave_addr, uint8_t *data, int size)
return EC_SUCCESS;
}
-int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_bytes,
+int chip_i2c_xfer__7bf(const int port, const uint16_t slave_addr__7bf,
+ const uint8_t *out, int out_bytes,
uint8_t *in, int in_bytes, int flags)
{
int rv = EC_SUCCESS;
@@ -261,10 +263,12 @@ int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_bytes,
ASSERT(in || !in_bytes);
if (out_bytes)
- rv = i2c_master_write(port, slave_addr, out, out_bytes,
- in_bytes ? 0 : 1);
+ rv = i2c_master_write__7bf(port, slave_addr__7bf,
+ out, out_bytes,
+ in_bytes ? 0 : 1);
if (rv == EC_SUCCESS && in_bytes)
- rv = i2c_master_read(port, slave_addr, in, in_bytes);
+ rv = i2c_master_read__7bf(port, slave_addr__7bf,
+ in, in_bytes);
handle_i2c_error(port, rv);