Skip to content

Commit

Permalink
Rework of specifying i2c bus number
Browse files Browse the repository at this point in the history
  • Loading branch information
dimerr committed Jan 15, 2025
1 parent 929840d commit a5c11e8
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/hal/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include "chipid.h"
#include "hal/common.h"

int i2c_adapter_nr = 0;
sensor_addr_t *possible_i2c_addrs;

int (*open_i2c_sensor_fd)();
int (*open_spi_sensor_fd)();
bool (*close_sensor_fd)(int fd);
Expand Down
1 change: 1 addition & 0 deletions src/hal/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ typedef struct {
unsigned char *addrs;
} sensor_addr_t;

extern int i2c_adapter_nr;
extern sensor_addr_t *possible_i2c_addrs;

typedef int (*read_register_t)(int fd, unsigned char i2c_addr,
Expand Down
2 changes: 1 addition & 1 deletion src/hal/hisi/hal_hisi.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static sensor_addr_t my_possible_i2c_addrs[] = {

static float hisi_get_temp();

static int hisi_open_i2c_fd(int i2c_adapter_nr) {
static int hisi_open_i2c_fd() {
char filename[FILENAME_MAX];

snprintf(filename, sizeof(filename), "/dev/i2c-%d", i2c_adapter_nr);
Expand Down
2 changes: 0 additions & 2 deletions src/i2cspi.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

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

int i2c_adapter_nr = 0;

static int prepare_i2c_sensor(unsigned char i2c_addr) {
if (!getchipname()) {
puts("Unknown chip");
Expand Down
2 changes: 0 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
#define RESET_CL "\x1b[0m"
#define FG_RED "\x1b[31m"

extern int i2c_adapter_nr;

void print_usage() {
#ifndef SKIP_VERSION
printf("ipctool, version: ");
Expand Down

0 comments on commit a5c11e8

Please sign in to comment.