summaryrefslogtreecommitdiffstats
path: root/app/i2c_hw.c
diff options
context:
space:
mode:
Diffstat (limited to 'app/i2c_hw.c')
-rw-r--r--app/i2c_hw.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/app/i2c_hw.c b/app/i2c_hw.c
index 7fc901e..1dd352c 100644
--- a/app/i2c_hw.c
+++ b/app/i2c_hw.c
@@ -64,7 +64,7 @@ int
i2cp_send (uint8_t v)
{
uint32_t reg;
- uint32_t timeout=1000;
+ uint32_t timeout = 1000;
i2c_send_data (I2C, v);
@@ -77,7 +77,8 @@ i2cp_send (uint8_t v)
reg & ~(I2C_SR1_BERR | I2C_SR1_ARLO | I2C_SR1_AF | I2C_SR1_PECERR |
I2C_SR1_TIMEOUT | I2C_SR1_SMBALERT);
- if (!timeout) return 1;
+ if (!timeout)
+ return 1;
return (reg & I2C_SR1_BTF) ? 0 : -1;
@@ -89,13 +90,14 @@ i2cp_start_transaction (uint8_t a, int wnr)
{
uint32_t reg;
uint32_t __attribute__((unused)) dummy;
- uint32_t timeout=1000;
+ uint32_t timeout = 1000;
i2c_send_start (I2C);
while (!((I2C_SR1 (I2C) & I2C_SR1_SB)
& (I2C_SR2 (I2C) & (I2C_SR2_MSL | I2C_SR2_BUSY))) && (timeout--));
- if (!timeout) return -1;
+ if (!timeout)
+ return -1;
i2c_send_7bit_address (I2C, a, wnr);
@@ -104,7 +106,8 @@ i2cp_start_transaction (uint8_t a, int wnr)
I2C_SR1 (I2C)) & (I2C_SR1_ADDR | I2C_SR1_BERR | I2C_SR1_ARLO |
I2C_SR1_AF | I2C_SR1_PECERR | I2C_SR1_TIMEOUT |
I2C_SR1_SMBALERT)) && (timeout--));
- if (!timeout) return -1;
+ if (!timeout)
+ return -1;
dummy = I2C_SR2 (I2C);
@@ -123,31 +126,31 @@ i2cp_reset_sm (void)
{
int i;
- MAP_OUTPUT_PP(SCL);
- MAP_OUTPUT_PP(SDA);
+ MAP_OUTPUT_PP (SCL);
+ MAP_OUTPUT_PP (SDA);
- SET(SDA);
- SET(SCL);
+ SET (SDA);
+ SET (SCL);
delay_us (10);
- CLEAR(SDA);
+ CLEAR (SDA);
delay_us (10);
- CLEAR(SCL);
+ CLEAR (SCL);
for (i = 0; i < 9; ++i)
{
delay_us (10);
- SET(SCL);
+ SET (SCL);
delay_us (10);
- CLEAR(SCL);
+ CLEAR (SCL);
delay_us (10);
}
- SET(SCL);
+ SET (SCL);
delay_us (10);
- SET(SDA);
+ SET (SDA);
delay_us (10);
- MAP_AF_OD(SCL);
- MAP_AF_OD(SDA);
+ MAP_AF_OD (SCL);
+ MAP_AF_OD (SDA);
}