Skip to content

Commit

Permalink
rtmouse_i2c.cを作成してI2C関連の関数を移す
Browse files Browse the repository at this point in the history
  • Loading branch information
YusukeKato committed Nov 7, 2024
1 parent c1f774a commit f6cd192
Show file tree
Hide file tree
Showing 6 changed files with 439 additions and 388 deletions.
4 changes: 2 additions & 2 deletions src/drivers/Makefile.header_from_apt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
MODULE:= rtmouse
obj-m:= $(MODULE).o
$(MODULE)-y:= $(MODULE)_main.o $(MODULE)_dev_fops.o $(MODULE)_spi.o
$(MODULE)-y:= $(MODULE)_main.o $(MODULE)_dev_fops.o $(MODULE)_spi.o $(MODULE)_i2c.o
clean-files:= *.o *.ko *.mod.[co] *~

LINUX_SRC_DIR:=/usr/src/linux-headers-$(shell uname -r)
VERBOSE:=0

$(MODULE).ko: $(MODULE)_main.c $(MODULE)_dev_fops.c $(MODULE)_spi.c $(MODULE).h
$(MODULE).ko: $(MODULE)_main.c $(MODULE)_dev_fops.c $(MODULE)_spi.c $(MODULE)_i2c.c $(MODULE).h
make -C $(LINUX_SRC_DIR) M=$(shell pwd) V=$(VERBOSE) modules

clean:
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/Makefile.header_from_source
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
MODULE:= rtmouse
obj-m:= $(MODULE).o
$(MODULE)-y:= $(MODULE)_main.o $(MODULE)_dev_fops.o $(MODULE)_spi.o
$(MODULE)-y:= $(MODULE)_main.o $(MODULE)_dev_fops.o $(MODULE)_spi.o $(MODULE)_i2c.o
clean-files:= *.o *.ko *.mod.[co] *~

LINUX_SRC_DIR:=/usr/src/linux
VERBOSE:=0

$(MODULE).ko: $(MODULE)_main.c $(MODULE)_dev_fops.c $(MODULE)_spi.c $(MODULE).h
$(MODULE).ko: $(MODULE)_main.c $(MODULE)_dev_fops.c $(MODULE)_spi.c $(MODULE)_i2c.c $(MODULE).h
make -C $(LINUX_SRC_DIR) M=$(shell pwd) V=$(VERBOSE) modules

clean:
Expand Down
7 changes: 7 additions & 0 deletions src/drivers/rtmouse.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,4 +271,11 @@ void rpi_pwm_write32(uint32_t offset, uint32_t val);
int mcp3204_init(void);
void mcp3204_exit(void);

/* --- used in rtmouse_i2c.c --- */
extern const unsigned int NUM_DEV[ID_DEV_SIZE];
extern struct cdev *cdev_array;
extern volatile int cdev_index;
int i2c_counter_init(void);
void i2c_counter_exit(void);

#endif // RTMOUSE_H
6 changes: 5 additions & 1 deletion src/drivers/rtmouse_dev_fops.c
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,11 @@ static ssize_t motor_write(struct file *filep, const char __user *buf,
return bufcnt;
}

/* --- Device File Operations --- */
/*
* Device File Operations
* used in register_dev(), rtcntr_i2c_create_cdev()
* and rtcntl_i2c_create_cdev()
*/
struct file_operations dev_fops[ID_DEV_SIZE] = {
[ID_DEV_LED].open = dev_open,
[ID_DEV_LED].release = dev_release,
Expand Down
Loading

0 comments on commit f6cd192

Please sign in to comment.