diff options
| author | QMK Bot <hello@qmk.fm> | 2022-02-12 10:29:31 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-12 18:29:31 +0000 |
| commit | 63646e8906e062d1c1de3925cba70c4e3426a855 (patch) | |
| tree | 4e91648b77b838e1125cf86331d7e84bde6d07a9 /drivers/ps2 | |
| parent | afcdd7079c774dec2aa4b7f2d08adf8b7310919b (diff) | |
Format code according to conventions (#16322)
Diffstat (limited to 'drivers/ps2')
| -rw-r--r-- | drivers/ps2/ps2_busywait.c | 6 | ||||
| -rw-r--r-- | drivers/ps2/ps2_interrupt.c | 16 | ||||
| -rw-r--r-- | drivers/ps2/ps2_mouse.c | 28 |
3 files changed, 33 insertions, 17 deletions
diff --git a/drivers/ps2/ps2_busywait.c b/drivers/ps2/ps2_busywait.c index 983194eea8..c5a0183bb7 100644 --- a/drivers/ps2/ps2_busywait.c +++ b/drivers/ps2/ps2_busywait.c | |||
| @@ -71,12 +71,12 @@ uint8_t ps2_host_send(uint8_t data) { | |||
| 71 | 71 | ||
| 72 | /* terminate a transmission if we have */ | 72 | /* terminate a transmission if we have */ |
| 73 | inhibit(); | 73 | inhibit(); |
| 74 | wait_us(100); // 100us [4]p.13, [5]p.50 | 74 | wait_us(100); // 100us [4]p.13, [5]p.50 |
| 75 | 75 | ||
| 76 | /* 'Request to Send' and Start bit */ | 76 | /* 'Request to Send' and Start bit */ |
| 77 | data_lo(); | 77 | data_lo(); |
| 78 | clock_hi(); | 78 | clock_hi(); |
| 79 | WAIT(clock_lo, 10000, 10); // 10ms [5]p.50 | 79 | WAIT(clock_lo, 10000, 10); // 10ms [5]p.50 |
| 80 | 80 | ||
| 81 | /* Data bit */ | 81 | /* Data bit */ |
| 82 | for (uint8_t i = 0; i < 8; i++) { | 82 | for (uint8_t i = 0; i < 8; i++) { |
| @@ -143,7 +143,7 @@ uint8_t ps2_host_recv(void) { | |||
| 143 | idle(); | 143 | idle(); |
| 144 | 144 | ||
| 145 | /* start bit [1] */ | 145 | /* start bit [1] */ |
| 146 | WAIT(clock_lo, 100, 1); // TODO: this is enough? | 146 | WAIT(clock_lo, 100, 1); // TODO: this is enough? |
| 147 | WAIT(data_lo, 1, 2); | 147 | WAIT(data_lo, 1, 2); |
| 148 | WAIT(clock_hi, 50, 3); | 148 | WAIT(clock_hi, 50, 3); |
| 149 | 149 | ||
diff --git a/drivers/ps2/ps2_interrupt.c b/drivers/ps2/ps2_interrupt.c index 70debd02f7..c49b4f8b75 100644 --- a/drivers/ps2/ps2_interrupt.c +++ b/drivers/ps2/ps2_interrupt.c | |||
| @@ -43,7 +43,7 @@ POSSIBILITY OF SUCH DAMAGE. | |||
| 43 | 43 | ||
| 44 | #if defined(__AVR__) | 44 | #if defined(__AVR__) |
| 45 | # include <avr/interrupt.h> | 45 | # include <avr/interrupt.h> |
| 46 | #elif defined(PROTOCOL_CHIBIOS) // TODO: or STM32 ? | 46 | #elif defined(PROTOCOL_CHIBIOS) // TODO: or STM32 ? |
| 47 | // chibiOS headers | 47 | // chibiOS headers |
| 48 | # include "ch.h" | 48 | # include "ch.h" |
| 49 | # include "hal.h" | 49 | # include "hal.h" |
| @@ -71,7 +71,9 @@ static inline void pbuf_clear(void); | |||
| 71 | 71 | ||
| 72 | #if defined(PROTOCOL_CHIBIOS) | 72 | #if defined(PROTOCOL_CHIBIOS) |
| 73 | void ps2_interrupt_service_routine(void); | 73 | void ps2_interrupt_service_routine(void); |
| 74 | void palCallback(void *arg) { ps2_interrupt_service_routine(); } | 74 | void palCallback(void *arg) { |
| 75 | ps2_interrupt_service_routine(); | ||
| 76 | } | ||
| 75 | 77 | ||
| 76 | # define PS2_INT_INIT() \ | 78 | # define PS2_INT_INIT() \ |
| 77 | { palSetLineMode(PS2_CLOCK_PIN, PAL_MODE_INPUT); } \ | 79 | { palSetLineMode(PS2_CLOCK_PIN, PAL_MODE_INPUT); } \ |
| @@ -85,7 +87,7 @@ void palCallback(void *arg) { ps2_interrupt_service_routine(); } | |||
| 85 | # define PS2_INT_OFF() \ | 87 | # define PS2_INT_OFF() \ |
| 86 | { palDisableLineEvent(PS2_CLOCK_PIN); } \ | 88 | { palDisableLineEvent(PS2_CLOCK_PIN); } \ |
| 87 | while (0) | 89 | while (0) |
| 88 | #endif // PROTOCOL_CHIBIOS | 90 | #endif // PROTOCOL_CHIBIOS |
| 89 | 91 | ||
| 90 | void ps2_host_init(void) { | 92 | void ps2_host_init(void) { |
| 91 | idle(); | 93 | idle(); |
| @@ -103,12 +105,12 @@ uint8_t ps2_host_send(uint8_t data) { | |||
| 103 | 105 | ||
| 104 | /* terminate a transmission if we have */ | 106 | /* terminate a transmission if we have */ |
| 105 | inhibit(); | 107 | inhibit(); |
| 106 | wait_us(100); // 100us [4]p.13, [5]p.50 | 108 | wait_us(100); // 100us [4]p.13, [5]p.50 |
| 107 | 109 | ||
| 108 | /* 'Request to Send' and Start bit */ | 110 | /* 'Request to Send' and Start bit */ |
| 109 | data_lo(); | 111 | data_lo(); |
| 110 | clock_hi(); | 112 | clock_hi(); |
| 111 | WAIT(clock_lo, 10000, 10); // 10ms [5]p.50 | 113 | WAIT(clock_lo, 10000, 10); // 10ms [5]p.50 |
| 112 | 114 | ||
| 113 | /* Data bit[2-9] */ | 115 | /* Data bit[2-9] */ |
| 114 | for (uint8_t i = 0; i < 8; i++) { | 116 | for (uint8_t i = 0; i < 8; i++) { |
| @@ -244,7 +246,9 @@ RETURN: | |||
| 244 | } | 246 | } |
| 245 | 247 | ||
| 246 | #if defined(__AVR__) | 248 | #if defined(__AVR__) |
| 247 | ISR(PS2_INT_VECT) { ps2_interrupt_service_routine(); } | 249 | ISR(PS2_INT_VECT) { |
| 250 | ps2_interrupt_service_routine(); | ||
| 251 | } | ||
| 248 | #endif | 252 | #endif |
| 249 | 253 | ||
| 250 | /* send LED state to keyboard */ | 254 | /* send LED state to keyboard */ |
diff --git a/drivers/ps2/ps2_mouse.c b/drivers/ps2/ps2_mouse.c index 8a6668b410..ccb0a929ae 100644 --- a/drivers/ps2/ps2_mouse.c +++ b/drivers/ps2/ps2_mouse.c | |||
| @@ -42,7 +42,7 @@ static inline void ps2_mouse_scroll_button_task(report_mouse_t *mouse_report); | |||
| 42 | void ps2_mouse_init(void) { | 42 | void ps2_mouse_init(void) { |
| 43 | ps2_host_init(); | 43 | ps2_host_init(); |
| 44 | 44 | ||
| 45 | wait_ms(PS2_MOUSE_INIT_DELAY); // wait for powering up | 45 | wait_ms(PS2_MOUSE_INIT_DELAY); // wait for powering up |
| 46 | 46 | ||
| 47 | PS2_MOUSE_SEND(PS2_MOUSE_RESET, "ps2_mouse_init: sending reset"); | 47 | PS2_MOUSE_SEND(PS2_MOUSE_RESET, "ps2_mouse_init: sending reset"); |
| 48 | 48 | ||
| @@ -113,9 +113,13 @@ void ps2_mouse_task(void) { | |||
| 113 | ps2_mouse_clear_report(&mouse_report); | 113 | ps2_mouse_clear_report(&mouse_report); |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | void ps2_mouse_disable_data_reporting(void) { PS2_MOUSE_SEND(PS2_MOUSE_DISABLE_DATA_REPORTING, "ps2 mouse disable data reporting"); } | 116 | void ps2_mouse_disable_data_reporting(void) { |
| 117 | PS2_MOUSE_SEND(PS2_MOUSE_DISABLE_DATA_REPORTING, "ps2 mouse disable data reporting"); | ||
| 118 | } | ||
| 117 | 119 | ||
| 118 | void ps2_mouse_enable_data_reporting(void) { PS2_MOUSE_SEND(PS2_MOUSE_ENABLE_DATA_REPORTING, "ps2 mouse enable data reporting"); } | 120 | void ps2_mouse_enable_data_reporting(void) { |
| 121 | PS2_MOUSE_SEND(PS2_MOUSE_ENABLE_DATA_REPORTING, "ps2 mouse enable data reporting"); | ||
| 122 | } | ||
| 119 | 123 | ||
| 120 | void ps2_mouse_set_remote_mode(void) { | 124 | void ps2_mouse_set_remote_mode(void) { |
| 121 | PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_REMOTE_MODE, "ps2 mouse set remote mode"); | 125 | PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_REMOTE_MODE, "ps2 mouse set remote mode"); |
| @@ -127,13 +131,21 @@ void ps2_mouse_set_stream_mode(void) { | |||
| 127 | ps2_mouse_mode = PS2_MOUSE_STREAM_MODE; | 131 | ps2_mouse_mode = PS2_MOUSE_STREAM_MODE; |
| 128 | } | 132 | } |
| 129 | 133 | ||
| 130 | void ps2_mouse_set_scaling_2_1(void) { PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_SCALING_2_1, "ps2 mouse set scaling 2:1"); } | 134 | void ps2_mouse_set_scaling_2_1(void) { |
| 135 | PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_SCALING_2_1, "ps2 mouse set scaling 2:1"); | ||
| 136 | } | ||
| 131 | 137 | ||
| 132 | void ps2_mouse_set_scaling_1_1(void) { PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_SCALING_1_1, "ps2 mouse set scaling 1:1"); } | 138 | void ps2_mouse_set_scaling_1_1(void) { |
| 139 | PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_SCALING_1_1, "ps2 mouse set scaling 1:1"); | ||
| 140 | } | ||
| 133 | 141 | ||
| 134 | void ps2_mouse_set_resolution(ps2_mouse_resolution_t resolution) { PS2_MOUSE_SET_SAFE(PS2_MOUSE_SET_RESOLUTION, resolution, "ps2 mouse set resolution"); } | 142 | void ps2_mouse_set_resolution(ps2_mouse_resolution_t resolution) { |
| 143 | PS2_MOUSE_SET_SAFE(PS2_MOUSE_SET_RESOLUTION, resolution, "ps2 mouse set resolution"); | ||
| 144 | } | ||
| 135 | 145 | ||
| 136 | void ps2_mouse_set_sample_rate(ps2_mouse_sample_rate_t sample_rate) { PS2_MOUSE_SET_SAFE(PS2_MOUSE_SET_SAMPLE_RATE, sample_rate, "ps2 mouse set sample rate"); } | 146 | void ps2_mouse_set_sample_rate(ps2_mouse_sample_rate_t sample_rate) { |
| 147 | PS2_MOUSE_SET_SAFE(PS2_MOUSE_SET_SAMPLE_RATE, sample_rate, "ps2 mouse set sample rate"); | ||
| 148 | } | ||
| 137 | 149 | ||
| 138 | /* ============================= HELPERS ============================ */ | 150 | /* ============================= HELPERS ============================ */ |
| 139 | 151 | ||
| @@ -165,7 +177,7 @@ static inline void ps2_mouse_convert_report_to_hid(report_mouse_t *mouse_report) | |||
| 165 | #ifdef PS2_MOUSE_INVERT_X | 177 | #ifdef PS2_MOUSE_INVERT_X |
| 166 | mouse_report->x = -mouse_report->x; | 178 | mouse_report->x = -mouse_report->x; |
| 167 | #endif | 179 | #endif |
| 168 | #ifndef PS2_MOUSE_INVERT_Y // NOTE if not! | 180 | #ifndef PS2_MOUSE_INVERT_Y // NOTE if not! |
| 169 | // invert coordinate of y to conform to USB HID mouse | 181 | // invert coordinate of y to conform to USB HID mouse |
| 170 | mouse_report->y = -mouse_report->y; | 182 | mouse_report->y = -mouse_report->y; |
| 171 | #endif | 183 | #endif |
