|
3 | 3 | * rtmouse.c |
4 | 4 | * Raspberry Pi Mouse device driver |
5 | 5 | * |
6 | | - * Version: 3.1.1 |
| 6 | + * Version: 3.2.0 |
7 | 7 | * |
8 | 8 | * Copyright (C) 2015-2021 RT Corporation <shop@rt-net.jp> |
9 | 9 | * |
|
55 | 55 |
|
56 | 56 | MODULE_AUTHOR("RT Corporation"); |
57 | 57 | MODULE_LICENSE("GPL"); |
58 | | -MODULE_VERSION("3.1.1"); |
| 58 | +MODULE_VERSION("3.2.0"); |
59 | 59 | MODULE_DESCRIPTION("Raspberry Pi Mouse device driver"); |
60 | 60 |
|
61 | 61 | /* --- Device Numbers --- */ |
@@ -272,6 +272,9 @@ static struct mutex lock; |
272 | 272 | #define CNT_ADDR_MSB 0x10 |
273 | 273 | #define CNT_ADDR_LSB 0x11 |
274 | 274 |
|
| 275 | +/* Motor Parameter */ |
| 276 | +#define MOTOR_UNCONTROLLABLE_FREQ 5 |
| 277 | + |
275 | 278 | /* --- Function Declarations --- */ |
276 | 279 | static void set_motor_r_freq(int freq); |
277 | 280 | static void set_motor_l_freq(int freq); |
@@ -467,6 +470,11 @@ static void set_motor_l_freq(int freq) |
467 | 470 |
|
468 | 471 | rpi_gpio_function_set(BUZZER_BASE, RPI_GPF_OUTPUT); |
469 | 472 |
|
| 473 | + // Reset uncontrollable frequency to zero. |
| 474 | + if (abs(freq) < MOTOR_UNCONTROLLABLE_FREQ) { |
| 475 | + freq = 0; |
| 476 | + } |
| 477 | + |
470 | 478 | if (freq == 0) { |
471 | 479 | rpi_gpio_function_set(MOTCLK_L_BASE, RPI_GPF_OUTPUT); |
472 | 480 | return; |
@@ -498,6 +506,11 @@ static void set_motor_r_freq(int freq) |
498 | 506 |
|
499 | 507 | rpi_gpio_function_set(BUZZER_BASE, RPI_GPF_OUTPUT); |
500 | 508 |
|
| 509 | + // Reset uncontrollable frequency to zero. |
| 510 | + if (abs(freq) < MOTOR_UNCONTROLLABLE_FREQ) { |
| 511 | + freq = 0; |
| 512 | + } |
| 513 | + |
501 | 514 | if (freq == 0) { |
502 | 515 | rpi_gpio_function_set(MOTCLK_R_BASE, RPI_GPF_OUTPUT); |
503 | 516 | return; |
|
0 commit comments