aboutsummaryrefslogtreecommitdiff
path: root/tmk_core/protocol/ps2.h
diff options
context:
space:
mode:
authorskullY <skullydazed@gmail.com>2019-08-30 11:19:03 -0700
committerskullydazed <skullydazed@users.noreply.github.com>2019-08-30 15:01:52 -0700
commitb624f32f944acdc59dcb130674c09090c5c404cb (patch)
treebc13adbba137d122d9a2c2fb2fafcbb08ac10e25 /tmk_core/protocol/ps2.h
parent61af76a10d00aba185b8338604171de490a13e3b (diff)
downloadqmk_firmware-b624f32f944acdc59dcb130674c09090c5c404cb.tar.gz
qmk_firmware-b624f32f944acdc59dcb130674c09090c5c404cb.zip
clang-format changes
Diffstat (limited to 'tmk_core/protocol/ps2.h')
-rw-r--r--tmk_core/protocol/ps2.h70
1 files changed, 39 insertions, 31 deletions
diff --git a/tmk_core/protocol/ps2.h b/tmk_core/protocol/ps2.h
index acde679cf..e32cc9603 100644
--- a/tmk_core/protocol/ps2.h
+++ b/tmk_core/protocol/ps2.h
@@ -67,66 +67,74 @@ POSSIBILITY OF SUCH DAMAGE.
67 * [5] TrackPoint Engineering Specifications for version 3E 67 * [5] TrackPoint Engineering Specifications for version 3E
68 * https://web.archive.org/web/20100526161812/http://wwwcssrv.almaden.ibm.com/trackpoint/download.html 68 * https://web.archive.org/web/20100526161812/http://wwwcssrv.almaden.ibm.com/trackpoint/download.html
69 */ 69 */
70#define PS2_ACK 0xFA 70#define PS2_ACK 0xFA
71#define PS2_RESEND 0xFE 71#define PS2_RESEND 0xFE
72#define PS2_SET_LED 0xED 72#define PS2_SET_LED 0xED
73 73
74// TODO: error numbers 74// TODO: error numbers
75#define PS2_ERR_NONE 0 75#define PS2_ERR_NONE 0
76#define PS2_ERR_STARTBIT1 1 76#define PS2_ERR_STARTBIT1 1
77#define PS2_ERR_STARTBIT2 2 77#define PS2_ERR_STARTBIT2 2
78#define PS2_ERR_STARTBIT3 3 78#define PS2_ERR_STARTBIT3 3
79#define PS2_ERR_PARITY 0x10 79#define PS2_ERR_PARITY 0x10
80#define PS2_ERR_NODATA 0x20 80#define PS2_ERR_NODATA 0x20
81 81
82#define PS2_LED_SCROLL_LOCK 0 82#define PS2_LED_SCROLL_LOCK 0
83#define PS2_LED_NUM_LOCK 1 83#define PS2_LED_NUM_LOCK 1
84#define PS2_LED_CAPS_LOCK 2 84#define PS2_LED_CAPS_LOCK 2
85
86 85
87extern uint8_t ps2_error; 86extern uint8_t ps2_error;
88 87
89void ps2_host_init(void); 88void ps2_host_init(void);
90uint8_t ps2_host_send(uint8_t data); 89uint8_t ps2_host_send(uint8_t data);
91uint8_t ps2_host_recv_response(void); 90uint8_t ps2_host_recv_response(void);
92uint8_t ps2_host_recv(void); 91uint8_t ps2_host_recv(void);
93void ps2_host_set_led(uint8_t usb_led); 92void ps2_host_set_led(uint8_t usb_led);
94
95 93
96/*-------------------------------------------------------------------- 94/*--------------------------------------------------------------------
97 * static functions 95 * static functions
98 *------------------------------------------------------------------*/ 96 *------------------------------------------------------------------*/
99static inline uint16_t wait_clock_lo(uint16_t us) 97static inline uint16_t wait_clock_lo(uint16_t us) {
100{ 98 while (clock_in() && us) {
101 while (clock_in() && us) { asm(""); wait_us(1); us--; } 99 asm("");
100 wait_us(1);
101 us--;
102 }
102 return us; 103 return us;
103} 104}
104static inline uint16_t wait_clock_hi(uint16_t us) 105static inline uint16_t wait_clock_hi(uint16_t us) {
105{ 106 while (!clock_in() && us) {
106 while (!clock_in() && us) { asm(""); wait_us(1); us--; } 107 asm("");
108 wait_us(1);
109 us--;
110 }
107 return us; 111 return us;
108} 112}
109static inline uint16_t wait_data_lo(uint16_t us) 113static inline uint16_t wait_data_lo(uint16_t us) {
110{ 114 while (data_in() && us) {
111 while (data_in() && us) { asm(""); wait_us(1); us--; } 115 asm("");
116 wait_us(1);
117 us--;
118 }
112 return us; 119 return us;
113} 120}
114static inline uint16_t wait_data_hi(uint16_t us) 121static inline uint16_t wait_data_hi(uint16_t us) {
115{ 122 while (!data_in() && us) {
116 while (!data_in() && us) { asm(""); wait_us(1); us--; } 123 asm("");
124 wait_us(1);
125 us--;
126 }
117 return us; 127 return us;
118} 128}
119 129
120/* idle state that device can send */ 130/* idle state that device can send */
121static inline void idle(void) 131static inline void idle(void) {
122{
123 clock_hi(); 132 clock_hi();
124 data_hi(); 133 data_hi();
125} 134}
126 135
127/* inhibit device to send */ 136/* inhibit device to send */
128static inline void inhibit(void) 137static inline void inhibit(void) {
129{
130 clock_lo(); 138 clock_lo();
131 data_hi(); 139 data_hi();
132} 140}