From d43bd8fe8ec10eae625263e5d2d65e82e5646a52 Mon Sep 17 00:00:00 2001 From: bboulet Date: Mon, 22 Jul 2019 16:50:17 +0200 Subject: [PATCH] coding style modification --- libloragw/src/loragw_hal.c | 8 ++++---- libloragw/src/loragw_stts751.c | 30 +++++++++++++++--------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/libloragw/src/loragw_hal.c b/libloragw/src/loragw_hal.c index affe532..5b8f47b 100644 --- a/libloragw/src/loragw_hal.c +++ b/libloragw/src/loragw_hal.c @@ -564,7 +564,7 @@ int lgw_debug_setconf(struct lgw_conf_debug_s * conf) { /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ int lgw_start(void) { - int i, err, err_ID1,err_ID2; + int i, err, err_id_1,err_id_2; int reg_stat; if (CONTEXT_STARTED == true) { @@ -714,9 +714,9 @@ int lgw_start(void) { #endif /* Open I2C */ - err_ID1 = i2c_linuxdev_open(I2C_DEVICE, I2C_PORT_TEMP_SENSOR_1, &lgw_i2c_target); - err_ID2 = i2c_linuxdev_open(I2C_DEVICE, I2C_PORT_TEMP_SENSOR_2, &lgw_i2c_target); - if (((err_ID1 != 0) || (lgw_i2c_target <= 0)) && ((err_ID2 != 0) || (lgw_i2c_target <= 0))) { + err_id_1 = i2c_linuxdev_open(I2C_DEVICE, I2C_PORT_TEMP_SENSOR_1, &lgw_i2c_target); + err_id_2 = i2c_linuxdev_open(I2C_DEVICE, I2C_PORT_TEMP_SENSOR_2, &lgw_i2c_target); + if (((err_id_1 != 0) || (lgw_i2c_target <= 0)) && ((err_id_2 != 0) || (lgw_i2c_target <= 0))) { printf("ERROR: failed to open I2C device %s (err=%i)\n", I2C_DEVICE, err); return LGW_HAL_ERROR; } diff --git a/libloragw/src/loragw_stts751.c b/libloragw/src/loragw_stts751.c index 776524e..788c569 100644 --- a/libloragw/src/loragw_stts751.c +++ b/libloragw/src/loragw_stts751.c @@ -75,7 +75,7 @@ License: Revised BSD License, see LICENSE.TXT file include in the project /* --- INTERNAL SHARED VARIABLES -------------------------------------------- */ extern int lgw_i2c_target; -uint8_t SlaveAddr; +uint8_t slave_addr; /* -------------------------------------------------------------------------- */ /* --- PRIVATE FUNCTIONS ---------------------------------------------------- */ @@ -107,11 +107,11 @@ int stts751_configure( int i2c_fd ) { if ( err_1 == 0 ) { - SlaveAddr = I2C_PORT_TEMP_SENSOR_1; + slave_addr = I2C_PORT_TEMP_SENSOR_1; } if( err_2 == 0 ) { - SlaveAddr = I2C_PORT_TEMP_SENSOR_2; + slave_addr = I2C_PORT_TEMP_SENSOR_2; } } @@ -129,10 +129,10 @@ int stts751_configure( int i2c_fd ) } /* Get Manufacturer ID */ - err = i2c_linuxdev_read( i2c_fd, SlaveAddr, STTS751_REG_MAN_ID, &val ); + err = i2c_linuxdev_read( i2c_fd, slave_addr, STTS751_REG_MAN_ID, &val ); if ( err != 0 ) { - printf( "ERROR: failed to read I2C device 0x%02X (err=%i)\n", SlaveAddr, err ); + printf( "ERROR: failed to read I2C device 0x%02X (err=%i)\n", slave_addr, err ); return LGW_I2C_ERROR; } if ( val != ST_MAN_ID ) @@ -146,27 +146,27 @@ int stts751_configure( int i2c_fd ) } /* Get revision number */ - err = i2c_linuxdev_read( i2c_fd, SlaveAddr, STTS751_REG_REV_ID, &val ); + err = i2c_linuxdev_read( i2c_fd, slave_addr, STTS751_REG_REV_ID, &val ); if ( err != 0 ) { - printf( "ERROR: failed to read I2C device 0x%02X (err=%i)\n", SlaveAddr, err ); + printf( "ERROR: failed to read I2C device 0x%02X (err=%i)\n", slave_addr, err ); return LGW_I2C_ERROR; } DEBUG_PRINTF("INFO: Revision number: 0x%02X\n", val); /* Set conversion resolution to 12 bits */ - err = i2c_linuxdev_write( i2c_fd, SlaveAddr, STTS751_REG_CONF, 0x8C ); /* TODO: do not hardcode the whole byte */ + err = i2c_linuxdev_write( i2c_fd, slave_addr, STTS751_REG_CONF, 0x8C ); /* TODO: do not hardcode the whole byte */ if ( err != 0 ) { - printf( "ERROR: failed to write I2C device 0x%02X (err=%i)\n", SlaveAddr, err ); + printf( "ERROR: failed to write I2C device 0x%02X (err=%i)\n", slave_addr, err ); return LGW_I2C_ERROR; } /* Set conversion rate to 1 / second */ - err = i2c_linuxdev_write( i2c_fd, SlaveAddr, STTS751_REG_RATE, 0x04 ); + err = i2c_linuxdev_write( i2c_fd, slave_addr, STTS751_REG_RATE, 0x04 ); if ( err != 0 ) { - printf( "ERROR: failed to write I2C device 0x%02X (err=%i)\n", SlaveAddr, err ); + printf( "ERROR: failed to write I2C device 0x%02X (err=%i)\n", slave_addr, err ); return LGW_I2C_ERROR; } @@ -189,18 +189,18 @@ int stts751_get_temperature( int i2c_fd, float * temperature) } /* Read Temperature LSB */ - err = i2c_linuxdev_read( i2c_fd, SlaveAddr, STTS751_REG_TEMP_L, &low_byte ); + err = i2c_linuxdev_read( i2c_fd, slave_addr, STTS751_REG_TEMP_L, &low_byte ); if ( err != 0 ) { - printf( "ERROR: failed to read I2C device 0x%02X (err=%i)\n", SlaveAddr, err ); + printf( "ERROR: failed to read I2C device 0x%02X (err=%i)\n", slave_addr, err ); return LGW_I2C_ERROR; } /* Read Temperature MSB */ - err = i2c_linuxdev_read( i2c_fd, SlaveAddr, STTS751_REG_TEMP_H, &high_byte ); + err = i2c_linuxdev_read( i2c_fd, slave_addr, STTS751_REG_TEMP_H, &high_byte ); if ( err != 0 ) { - printf( "ERROR: failed to read I2C device 0x%02X (err=%i)\n", SlaveAddr, err ); + printf( "ERROR: failed to read I2C device 0x%02X (err=%i)\n", slave_addr, err ); return LGW_I2C_ERROR; }