diff options
author | William Chang <william@factual.com> | 2019-11-20 22:17:07 -0800 |
---|---|---|
committer | William Chang <william@factual.com> | 2019-11-20 22:17:07 -0800 |
commit | e7f4d56592b3975c38af329e77b4efd9108495e8 (patch) | |
tree | 0a416bccbf70bfdbdb9ffcdb3bf136b47378c014 /tmk_core/protocol/ps2.h | |
parent | 71493b2f9bbd5f3d18373c518fa14ccafcbf48fc (diff) | |
parent | 8416a94ad27b3ff058576f09f35f0704a8b39ff3 (diff) |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'tmk_core/protocol/ps2.h')
-rw-r--r-- | tmk_core/protocol/ps2.h | 70 |
1 files changed, 39 insertions, 31 deletions
diff --git a/tmk_core/protocol/ps2.h b/tmk_core/protocol/ps2.h index acde679cf4..e32cc9603f 100644 --- a/tmk_core/protocol/ps2.h +++ b/tmk_core/protocol/ps2.h @@ -67,66 +67,74 @@ POSSIBILITY OF SUCH DAMAGE. * [5] TrackPoint Engineering Specifications for version 3E * https://web.archive.org/web/20100526161812/http://wwwcssrv.almaden.ibm.com/trackpoint/download.html */ -#define PS2_ACK 0xFA -#define PS2_RESEND 0xFE -#define PS2_SET_LED 0xED +#define PS2_ACK 0xFA +#define PS2_RESEND 0xFE +#define PS2_SET_LED 0xED // TODO: error numbers -#define PS2_ERR_NONE 0 -#define PS2_ERR_STARTBIT1 1 -#define PS2_ERR_STARTBIT2 2 -#define PS2_ERR_STARTBIT3 3 -#define PS2_ERR_PARITY 0x10 -#define PS2_ERR_NODATA 0x20 +#define PS2_ERR_NONE 0 +#define PS2_ERR_STARTBIT1 1 +#define PS2_ERR_STARTBIT2 2 +#define PS2_ERR_STARTBIT3 3 +#define PS2_ERR_PARITY 0x10 +#define PS2_ERR_NODATA 0x20 #define PS2_LED_SCROLL_LOCK 0 -#define PS2_LED_NUM_LOCK 1 -#define PS2_LED_CAPS_LOCK 2 - +#define PS2_LED_NUM_LOCK 1 +#define PS2_LED_CAPS_LOCK 2 extern uint8_t ps2_error; -void ps2_host_init(void); +void ps2_host_init(void); uint8_t ps2_host_send(uint8_t data); uint8_t ps2_host_recv_response(void); uint8_t ps2_host_recv(void); -void ps2_host_set_led(uint8_t usb_led); - +void ps2_host_set_led(uint8_t usb_led); /*-------------------------------------------------------------------- * static functions *------------------------------------------------------------------*/ -static inline uint16_t wait_clock_lo(uint16_t us) -{ - while (clock_in() && us) { asm(""); wait_us(1); us--; } +static inline uint16_t wait_clock_lo(uint16_t us) { + while (clock_in() && us) { + asm(""); + wait_us(1); + us--; + } return us; } -static inline uint16_t wait_clock_hi(uint16_t us) -{ - while (!clock_in() && us) { asm(""); wait_us(1); us--; } +static inline uint16_t wait_clock_hi(uint16_t us) { + while (!clock_in() && us) { + asm(""); + wait_us(1); + us--; + } return us; } -static inline uint16_t wait_data_lo(uint16_t us) -{ - while (data_in() && us) { asm(""); wait_us(1); us--; } +static inline uint16_t wait_data_lo(uint16_t us) { + while (data_in() && us) { + asm(""); + wait_us(1); + us--; + } return us; } -static inline uint16_t wait_data_hi(uint16_t us) -{ - while (!data_in() && us) { asm(""); wait_us(1); us--; } +static inline uint16_t wait_data_hi(uint16_t us) { + while (!data_in() && us) { + asm(""); + wait_us(1); + us--; + } return us; } /* idle state that device can send */ -static inline void idle(void) -{ +static inline void idle(void) { clock_hi(); data_hi(); } /* inhibit device to send */ -static inline void inhibit(void) -{ +static inline void inhibit(void) { clock_lo(); data_hi(); } |