Skip to content

Commit a5c11e8

Browse files
committed
Rework of specifying i2c bus number
1 parent 929840d commit a5c11e8

File tree

5 files changed

+3
-6
lines changed

5 files changed

+3
-6
lines changed

src/hal/common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#include "chipid.h"
1111
#include "hal/common.h"
1212

13+
int i2c_adapter_nr = 0;
1314
sensor_addr_t *possible_i2c_addrs;
14-
1515
int (*open_i2c_sensor_fd)();
1616
int (*open_spi_sensor_fd)();
1717
bool (*close_sensor_fd)(int fd);

src/hal/common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ typedef struct {
6868
unsigned char *addrs;
6969
} sensor_addr_t;
7070

71+
extern int i2c_adapter_nr;
7172
extern sensor_addr_t *possible_i2c_addrs;
7273

7374
typedef int (*read_register_t)(int fd, unsigned char i2c_addr,

src/hal/hisi/hal_hisi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static sensor_addr_t my_possible_i2c_addrs[] = {
4040

4141
static float hisi_get_temp();
4242

43-
static int hisi_open_i2c_fd(int i2c_adapter_nr) {
43+
static int hisi_open_i2c_fd() {
4444
char filename[FILENAME_MAX];
4545

4646
snprintf(filename, sizeof(filename), "/dev/i2c-%d", i2c_adapter_nr);

src/i2cspi.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
#define SELECT_WIDE(reg_addr) reg_addr > 0xff ? 2 : 1
1111

12-
int i2c_adapter_nr = 0;
13-
1412
static int prepare_i2c_sensor(unsigned char i2c_addr) {
1513
if (!getchipname()) {
1614
puts("Unknown chip");

src/main.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939
#define RESET_CL "\x1b[0m"
4040
#define FG_RED "\x1b[31m"
4141

42-
extern int i2c_adapter_nr;
43-
4442
void print_usage() {
4543
#ifndef SKIP_VERSION
4644
printf("ipctool, version: ");

0 commit comments

Comments
 (0)