18 #define SYNC_PULSE 1306000
19 #define BIN0_PULSE 288000
20 #define BIN1_PULSE 438000
22 #define ANALOG_MIN_PULSE 318000
23 #define ANALOG_MAX_PULSE 878000
24 #define ANALOG_DELTA 80000
26 #define BIN_SAMPLE ((BIN0_PULSE + BIN1_PULSE) / 2)
30 #include <linux/kernel.h>
31 #include <linux/module.h>
32 #include <linux/parport.h>
33 #include <linux/input.h>
34 #include <linux/hrtimer.h>
40 static unsigned int walkera0701_pp_no;
43 "Parallel port adapter for Walkera WK-0701 TX (default is 0)");
52 unsigned char buf[25];
66 static inline void walkera0701_parse_frame(
struct walkera_dev *
w)
69 int val1, val2, val3, val4, val5, val6, val7, val8;
72 for (crc1 = crc2 = i = 0; i < 10; i++) {
73 crc1 += w->
buf[
i] & 7;
74 crc2 += (w->
buf[
i] & 8) >> 3;
76 if ((w->
buf[10] & 7) != (crc1 & 7))
78 if (((w->
buf[10] & 8) >> 3) != (((crc1 >> 3) + crc2) & 1))
80 for (crc1 = crc2 = 0, i = 11; i < 23; i++) {
81 crc1 += w->
buf[
i] & 7;
82 crc2 += (w->
buf[
i] & 8) >> 3;
84 if ((w->
buf[23] & 7) != (crc1 & 7))
86 if (((w->
buf[23] & 8) >> 3) != (((crc1 >> 3) + crc2) & 1))
88 val1 = ((w->
buf[0] & 7) * 256 + w->
buf[1] * 16 + w->
buf[2]) >> 2;
89 val1 *= ((w->
buf[0] >> 2) & 2) - 1;
90 val2 = (w->
buf[2] & 1) << 8 | (w->
buf[3] << 4) | w->
buf[4];
91 val2 *= (w->
buf[2] & 2) - 1;
92 val3 = ((w->
buf[5] & 7) * 256 + w->
buf[6] * 16 + w->
buf[7]) >> 2;
93 val3 *= ((w->
buf[5] >> 2) & 2) - 1;
94 val4 = (w->
buf[7] & 1) << 8 | (w->
buf[8] << 4) | w->
buf[9];
95 val4 *= (w->
buf[7] & 2) - 1;
96 val5 = ((w->
buf[11] & 7) * 256 + w->
buf[12] * 16 + w->
buf[13]) >> 2;
97 val5 *= ((w->
buf[11] >> 2) & 2) - 1;
98 val6 = (w->
buf[13] & 1) << 8 | (w->
buf[14] << 4) | w->
buf[15];
99 val6 *= (w->
buf[13] & 2) - 1;
100 val7 = ((w->
buf[16] & 7) * 256 + w->
buf[17] * 16 + w->
buf[18]) >> 2;
101 val7 *= ((w->
buf[16] >> 2) & 2) - 1;
102 val8 = (w->
buf[18] & 1) << 8 | (w->
buf[19] << 4) | w->
buf[20];
103 val8 *= (w->
buf[18] & 2) - 1;
107 int magic, magic_bit;
108 magic = (w->
buf[21] << 4) | w->
buf[22];
109 magic_bit = (w->
buf[24] & 8) >> 3;
111 "walkera0701: %4d %4d %4d %4d %4d %4d %4d %4d (magic %2x %d)\n",
112 val1, val2, val3, val4, val5, val6, val7, val8, magic,
125 static inline int read_ack(
struct pardevice *
p)
131 static void walkera0701_irq_handler(
void *handler_data)
155 walkera0701_parse_frame(w);
216 NULL,
NULL, walkera0701_irq_handler,
232 w->
input_dev->name =
"Walkera WK-0701 TX";
253 err = input_register_device(w->
input_dev);
272 static void walkera0701_disconnect(
struct walkera_dev *w)
281 static int __init walkera0701_init(
void)
283 return walkera0701_connect(&w_dev, walkera0701_pp_no);
286 static void __exit walkera0701_exit(
void)
288 walkera0701_disconnect(&w_dev);