summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/mts_util_lora2_reset.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/util/mts_util_lora2_reset.c b/util/mts_util_lora2_reset.c
index 51af81e..6cd6593 100644
--- a/util/mts_util_lora2_reset.c
+++ b/util/mts_util_lora2_reset.c
@@ -41,9 +41,6 @@
#define MAX_FPGA_LOADING_TIMER 10
-/* Initial value of the port expander
- I/O states (read or read/write). */
-int port_expander_val0 = -1;
int global_i2c_fd = -1;
int i2c_open( uint8_t i21c_addr )
@@ -88,7 +85,7 @@ void i2c_read( uint8_t i21c_addr, uint8_t reg_addr, uint8_t *bval )
if( ioctl(global_i2c_fd, I2C_RDWR, &b) < 0 )
{
- fprintf(stderr,"ERROR: Read from I2C Device failed (%d, 0x%02x, 0x%02x) - %s", global_i2c_fd, i21c_addr, reg_addr, strerror(errno) );
+ fprintf(stderr,"ERROR: Read from I2C Device failed (%d, 0x%02x, 0x%02x) - %s\n", global_i2c_fd, i21c_addr, reg_addr, strerror(errno) );
}
}
@@ -111,7 +108,7 @@ void i2c_write( uint8_t i21c_addr, uint8_t reg_addr, uint8_t bval )
if( ioctl(global_i2c_fd, I2C_RDWR, &b) < 0 )
{
- fprintf(stderr,"ERROR: Write to I2C Device failed (%d, 0x%02x, 0x%02x) - %s", global_i2c_fd, i21c_addr, reg_addr, strerror(errno) );
+ fprintf(stderr,"ERROR: Write to I2C Device failed (%d, 0x%02x, 0x%02x) - %s\n", global_i2c_fd, i21c_addr, reg_addr, strerror(errno) );
return;
}
@@ -174,7 +171,7 @@ int main( int argc, char ** argv )
}
if (!(opt_reset_fpga || opt_gps_reset)) {
- fprintf(stderr,"Nothing to do!");
+ fprintf(stderr,"Nothing to do!\n");
exit(0);
}
@@ -205,9 +202,8 @@ int main( int argc, char ** argv )
}
/* Configuration of the I2C port expander */
- i2c_read( I2CADDR_PORTEXPANDER, PORTEXPANDER_CONFIG_PORT0_REG, (uint8_t *)&port_expander_val0 );
+ i2c_read( I2CADDR_PORTEXPANDER, PORTEXPANDER_CONFIG_PORT0_REG, (uint8_t *)&val );
fprintf(stderr, "I2C expander Port 0 config initial state: register: 0x%02x\n", val );
- val = port_expander_val0;
if (opt_reset_fpga) {
val &= ~(1 << FPGA_nCE_PORT); /* CE_PORT as output */
val &= ~(1 << FPGA_nCONFIG_PORT); /* CONFIG_PORT as output */
@@ -355,8 +351,9 @@ int main( int argc, char ** argv )
fprintf(stderr, "ERRROR: failed to open I2C device (err=%i)\n", err );
return EXIT_FAILURE;
}
- fprintf(stderr, "I2C expander Port 0 config register: 0x%02x\n", port_expander_val0 );
- i2c_write( I2CADDR_PORTEXPANDER, PORTEXPANDER_CONFIG_PORT0_REG, port_expander_val0 );
+ val = 0xff;
+ fprintf(stderr, "Completed reset(s). Disabling I2C expander Port 0 config register: 0x%02x\n", val );
+ i2c_write( I2CADDR_PORTEXPANDER, PORTEXPANDER_CONFIG_PORT0_REG, val );
i2c_close();
return 0;