Skip to content

Commit 8ebb234

Browse files
committed
Formatting change - II
1 parent c91b61e commit 8ebb234

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F437xG/TARGET_UBLOX_C030/min_battery_voltage.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,11 @@ void set_minimum_battery_voltage()
3232
i2c_frequency(&i2c_obj, I2C_FREQUENCY);
3333
i2c_init(&i2c_obj, I2C_SDA_B, I2C_SCL_B);
3434

35-
if (read_from_i2c(BQ24295_I2C_ADDRESS, 0, &data_read, i2c_obj)){
35+
if (read_from_i2c(BQ24295_I2C_ADDRESS, 0, &data_read, i2c_obj)) {
3636
data_read = data_read & MIN_BATTERY_VOLTAGE_MASK;
3737
write_to_i2c(BQ24295_I2C_ADDRESS, 0, data_read, i2c_obj);
3838
//Battery Voltage is set to 3880mV
39-
}
40-
else{
39+
} else {
4140
// Minimum battery voltage could not be set. This is not a critical error, no need to stop execution
4241
// It simply means that longer cabling or USB ports with lower output voltages may cause problems.
4342
}
@@ -46,11 +45,12 @@ void set_minimum_battery_voltage()
4645
char write_to_i2c(int slave_addr, int reg_addr, int data_write, i2c_t i2c_obj)
4746
{
4847
char ret_code = 0;
49-
if(!i2c_start(&i2c_obj)){
50-
if(i2c_byte_write(&i2c_obj, slave_addr << 1) == 1)
51-
if(i2c_byte_write(&i2c_obj, reg_addr) == 1)
52-
if(i2c_byte_write(&i2c_obj,data_write) ==1)
53-
ret_code = 1;
48+
if (!i2c_start(&i2c_obj)) {
49+
if ((i2c_byte_write(&i2c_obj, slave_addr << 1) == 1) &&
50+
(i2c_byte_write(&i2c_obj, reg_addr) == 1) &&
51+
(i2c_byte_write(&i2c_obj,data_write) ==1)) {
52+
ret_code = 1;
53+
}
5454
i2c_stop(&i2c_obj);
5555
}
5656
return ret_code;
@@ -59,14 +59,14 @@ char write_to_i2c(int slave_addr, int reg_addr, int data_write, i2c_t i2c_obj)
5959
char read_from_i2c(int slave_addr, int reg_addr, int* data_read, i2c_t i2c_obj)
6060
{
6161
char ret_code = 0;
62-
if(!i2c_start(&i2c_obj)){
63-
if(i2c_byte_write(&i2c_obj,(slave_addr << 1))==1)
64-
if(i2c_byte_write(&i2c_obj, reg_addr)==1)
65-
if(!i2c_start(&i2c_obj))
66-
if(i2c_byte_write(&i2c_obj, ((slave_addr << 1) | 0x01)) == 1){
67-
*data_read = i2c_byte_read(&i2c_obj,1);
68-
ret_code = 1;
69-
}
62+
if (!i2c_start(&i2c_obj)) {
63+
if ((i2c_byte_write(&i2c_obj,(slave_addr << 1))==1) &&
64+
(i2c_byte_write(&i2c_obj, reg_addr)==1) &&
65+
(!i2c_start(&i2c_obj)) &&
66+
(i2c_byte_write(&i2c_obj, ((slave_addr << 1) | 0x01)) == 1)) {
67+
*data_read = i2c_byte_read(&i2c_obj,1);
68+
ret_code = 1;
69+
}
7070
i2c_stop(&i2c_obj);
7171
}
7272
return ret_code;

0 commit comments

Comments
 (0)