Skip to content

Commit 504f260

Browse files
committed
rtmouse.hをrtmouse.cと同じ階層へ
1 parent b9fe2a2 commit 504f260

File tree

3 files changed

+181
-12
lines changed

3 files changed

+181
-12
lines changed

src/drivers/Makefile.header_from_apt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@ clean-files:= *.o *.ko *.mod.[co] *~
55
LINUX_SRC_DIR:=/usr/src/linux-headers-$(shell uname -r)
66
VERBOSE:=0
77

8-
EXTRA_CFLAGS += -I$(PWD)/include
9-
EXTRA_CFLAGS += -I$(shell pwd)/include
10-
ccflags-y += -I$(PWD)/include
11-
ccflags-y += -I$(shell pwd)/include
12-
13-
rtmouse.ko: rtmouse.c
8+
rtmouse.ko: rtmouse.c rtmouse.h
149
make -C $(LINUX_SRC_DIR) M=$(shell pwd) V=$(VERBOSE) modules
1510

1611
clean:

src/drivers/Makefile.header_from_source

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@ clean-files:= *.o *.ko *.mod.[co] *~
55
LINUX_SRC_DIR:=/usr/src/linux
66
VERBOSE:=0
77

8-
EXTRA_CFLAGS += -I$(PWD)/include
9-
EXTRA_CFLAGS += -I$(shell pwd)/include
10-
ccflags-y += -I$(PWD)/include
11-
ccflags-y += -I$(shell pwd)/include
12-
13-
rtmouse.ko: rtmouse.c
8+
rtmouse.ko: rtmouse.c rtmouse.h
149
make -C $(LINUX_SRC_DIR) M=$(shell pwd) V=$(VERBOSE) modules
1510

1611
clean:

src/drivers/rtmouse.h

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
// define the Raspberry Pi version here
2+
// Raspberry Pi 1 B/A/B+/A+: 1
3+
// Raspberry Pi 2 B : 2
4+
// Raspberry Pi 3 B/A+/B+ : 2
5+
// Raspberry Pi 4 B : 4
6+
#define RASPBERRYPI 4
7+
8+
/* --- Device ID --- */
9+
#define ID_DEV_LED 0
10+
#define ID_DEV_SWITCH 1
11+
#define ID_DEV_SENSOR 2
12+
#define ID_DEV_BUZZER 3
13+
#define ID_DEV_MOTORRAWR 4
14+
#define ID_DEV_MOTORRAWL 5
15+
#define ID_DEV_MOTOREN 6
16+
#define ID_DEV_MOTOR 7
17+
#define ID_DEV_CNT 8
18+
#define ID_DEV_SIZE 9
19+
20+
#define NUM_DEV_TOTAL \
21+
(NUM_DEV[ID_DEV_LED] + NUM_DEV[ID_DEV_SWITCH] + \
22+
NUM_DEV[ID_DEV_SENSOR] + NUM_DEV[ID_DEV_BUZZER] + \
23+
NUM_DEV[ID_DEV_MOTORRAWR] + NUM_DEV[ID_DEV_MOTORRAWL] + \
24+
NUM_DEV[ID_DEV_MOTOREN] + NUM_DEV[ID_DEV_MOTOR])
25+
26+
#define DEVNAME_SENSOR "rtlightsensor"
27+
#define DEVNAME_CNTR "rtcounter_r"
28+
#define DEVNAME_CNTL "rtcounter_l"
29+
#define DRIVER_NAME "rtmouse"
30+
31+
/* --- Device Major and Minor Numbers --- */
32+
#define DEV_MAJOR 0
33+
#define DEV_MINOR 0
34+
35+
/* --- GPIO Pin Definitions --- */
36+
#define R_AD_CH 3
37+
#define L_AD_CH 0
38+
#define RF_AD_CH 2
39+
#define LF_AD_CH 1
40+
41+
#define R_LED_BASE 22
42+
#define L_LED_BASE 4
43+
#define RF_LED_BASE 27
44+
#define LF_LED_BASE 17
45+
46+
#define LED0_BASE 25
47+
#define LED1_BASE 24
48+
#define LED2_BASE 23
49+
#define LED3_BASE 18
50+
51+
#define SW1_PIN 20
52+
#define SW2_PIN 26
53+
#define SW3_PIN 21
54+
55+
#define BUZZER_BASE 19
56+
57+
#define MOTCLK_L_BASE 12
58+
#define MOTDIR_L_BASE 16
59+
60+
#define MOTCLK_R_BASE 13
61+
#define MOTDIR_R_BASE 6
62+
63+
#define MOTEN_BASE 5
64+
65+
#define PWM_ORG0_BASE 40
66+
#define PWM_ORG1_BASE 45
67+
68+
/* --- Register Address --- */
69+
/* Base Addr */
70+
#if RASPBERRYPI == 1
71+
#define RPI_REG_BASE 0x20000000
72+
#elif RASPBERRYPI == 2
73+
#define RPI_REG_BASE 0x3f000000
74+
#elif RASPBERRYPI == 4
75+
#define RPI_REG_BASE 0xfe000000
76+
/* 2711 has a different mechanism for pin pull-up/down/enable */
77+
#define GPPUPPDN0 57 /* Pin pull-up/down for pins 15:0 */
78+
#define GPPUPPDN1 58 /* Pin pull-up/down for pins 31:16 */
79+
#define GPPUPPDN2 59 /* Pin pull-up/down for pins 47:32 */
80+
#define GPPUPPDN3 60 /* Pin pull-up/down for pins 57:48 */
81+
#endif
82+
83+
/* GPIO Addr */
84+
#define RPI_GPIO_OFFSET 0x200000
85+
#define RPI_GPIO_SIZE 0xC0
86+
#define RPI_GPIO_BASE (RPI_REG_BASE + RPI_GPIO_OFFSET)
87+
#define REG_GPIO_NAME "RPi mouse GPIO"
88+
89+
/* Pwm Addr */
90+
#define RPI_PWM_OFFSET 0x20C000
91+
#define RPI_PWM_SIZE 0xC0
92+
#define RPI_PWM_BASE (RPI_REG_BASE + RPI_PWM_OFFSET)
93+
#define REG_PWM_NAME "RPi mouse PWM"
94+
95+
/* Clock Addr */
96+
#define RPI_CLK_OFFSET 0x101000
97+
#define RPI_CLK_SIZE 0x100
98+
#define RPI_CLK_BASE (RPI_REG_BASE + RPI_CLK_OFFSET)
99+
#define REG_CLK_NAME "RPi mouse CLK"
100+
101+
/* --- General Options --- */
102+
/* Clock Offset */
103+
#define CLK_PWM_INDEX 0xa0
104+
#define CLK_PWMDIV_INDEX 0xa4
105+
106+
/* GPIO PUPD select */
107+
#if RASPBERRYPI == 4
108+
#define GPIO_PULLNONE 0x0
109+
#define GPIO_PULLUP 0x1
110+
#define GPIO_PULLDOWN 0x2
111+
#else
112+
#define GPIO_PULLNONE 0x0
113+
#define GPIO_PULLDOWN 0x1
114+
#define GPIO_PULLUP 0x2
115+
#endif
116+
117+
/* GPIO Function */
118+
#define RPI_GPF_INPUT 0x00
119+
#define RPI_GPF_OUTPUT 0x01
120+
#define RPI_GPF_ALT0 0x04
121+
#define RPI_GPF_ALT5 0x02
122+
123+
/* GPIO Register Index */
124+
#define RPI_GPFSEL0_INDEX 0
125+
#define RPI_GPFSEL1_INDEX 1
126+
#define RPI_GPFSEL2_INDEX 2
127+
#define RPI_GPFSEL3_INDEX 3
128+
129+
#define RPI_GPSET0_INDEX 7
130+
#define RPI_GPCLR0_INDEX 10
131+
132+
/* GPIO Mask */
133+
#define RPI_GPIO_P1MASK \
134+
(uint32_t)((0x01 << 2) | (0x01 << 3) | (0x01 << 4) | (0x01 << 7) | \
135+
(0x01 << 8) | (0x01 << 9) | (0x01 << 10) | (0x01 << 11) | \
136+
(0x01 << 14) | (0x01 << 15) | (0x01 << 17) | (0x01 << 18) | \
137+
(0x01 << 22) | (0x01 << 23) | (0x01 << 24) | (0x01 << 25) | \
138+
(0x01 << 27))
139+
#define RPI_GPIO_P2MASK (uint32_t)0xffffffff
140+
141+
/* PWM Index */
142+
#define RPI_PWM_CTRL 0x0
143+
#define RPI_PWM_STA 0x4
144+
#define RPI_PWM_DMAC 0x8
145+
#define RPI_PWM_RNG1 0x10
146+
#define RPI_PWM_DAT1 0x14
147+
#define RPI_PWM_FIF1 0x18
148+
#define RPI_PWM_RNG2 0x20
149+
#define RPI_PWM_DAT2 0x24
150+
151+
#if RASPBERRYPI == 4
152+
#define PWM_BASECLK 27000000
153+
#else
154+
#define PWM_BASECLK 9600000
155+
#endif
156+
157+
/* A/D Parameter */
158+
#define MCP320X_PACKET_SIZE 3
159+
#define MCP320X_DIFF 0
160+
#define MCP320X_SINGLE 1
161+
#define MCP3204_CHANNELS 4
162+
163+
/* I2C Parameter */
164+
#define DEV_ADDR_CNTL 0x10
165+
#define DEV_ADDR_CNTR 0x11
166+
#define CNT_ADDR_MSB 0x10
167+
#define CNT_ADDR_LSB 0x11
168+
169+
/* Motor Parameter */
170+
#define MOTOR_UNCONTROLLABLE_FREQ 5
171+
172+
/* I2C */
173+
#define SIGNED_COUNT_SIZE 32767
174+
#define MAX_PULSE_COUNT 65535
175+
176+
/* -- Buffer -- */
177+
#define MAX_BUFLEN 64
178+
// static int buflen = 0;
179+

0 commit comments

Comments
 (0)