comparison Output/usbMuxUart/output_com.c @ 309:4f47971c45c2

Merge remote-tracking branch 'upstream/master'
author Rowan Decker <Smasher816@gmail.com>
date Sun, 08 Mar 2015 20:17:39 -0700
parents ab4515606277 7119c2149abb
children a6bafeb5fecf
comparison
equal deleted inserted replaced
308:ab4515606277 309:4f47971c45c2
31 #include <scan_loop.h> 31 #include <scan_loop.h>
32 32
33 // USB Includes 33 // USB Includes
34 #if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_) 34 #if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_)
35 #elif defined(_mk20dx128_) || defined(_mk20dx128vlf5_) || defined(_mk20dx256_) || defined(_mk20dx256vlh7_) 35 #elif defined(_mk20dx128_) || defined(_mk20dx128vlf5_) || defined(_mk20dx256_) || defined(_mk20dx256vlh7_)
36 #include <uartOut/arm/uart_serial.h> 36 #include <arm/uart_serial.h>
37 #include <pjrcUSB/arm/usb_dev.h> 37 #include <arm/usb_dev.h>
38 #include <pjrcUSB/arm/usb_keyboard.h> 38 #include <arm/usb_keyboard.h>
39 #include <pjrcUSB/arm/usb_serial.h> 39 #include <arm/usb_serial.h>
40 #endif 40 #endif
41 41
42 // Local Includes 42 // Local Includes
43 #include "output_com.h" 43 #include "output_com.h"
44 44
133 // Indicates whether the Output module is fully functional 133 // Indicates whether the Output module is fully functional
134 // 0 - Not fully functional, 1 - Fully functional 134 // 0 - Not fully functional, 1 - Fully functional
135 // 0 is often used to show that a USB cable is not plugged in (but has power) 135 // 0 is often used to show that a USB cable is not plugged in (but has power)
136 uint8_t Output_Available = 0; 136 uint8_t Output_Available = 0;
137 137
138 // Debug control variable for Output modules
139 // 0 - Debug disabled (default)
140 // 1 - Debug enabled
141 uint8_t Output_DebugMode = 0;
142
138 143
139 144
140 // ----- Capabilities ----- 145 // ----- Capabilities -----
146
147 // Set Boot Keyboard Protocol
148 void Output_kbdProtocolBoot_capability( uint8_t state, uint8_t stateType, uint8_t *args )
149 {
150 // Display capability name
151 if ( stateType == 0xFF && state == 0xFF )
152 {
153 print("Output_kbdProtocolBoot()");
154 return;
155 }
156
157 // Only set if necessary
158 if ( USBKeys_Protocol == 0 )
159 return;
160
161 // TODO Analog inputs
162 // Only set on key press
163 if ( stateType != 0x01 )
164 return;
165
166 // Flush the key buffers
167 Output_flushBuffers();
168
169 // Set the keyboard protocol to Boot Mode
170 USBKeys_Protocol = 0;
171 }
172
173
174 // Set NKRO Keyboard Protocol
175 void Output_kbdProtocolNKRO_capability( uint8_t state, uint8_t stateType, uint8_t *args )
176 {
177 // Display capability name
178 if ( stateType == 0xFF && state == 0xFF )
179 {
180 print("Output_kbdProtocolNKRO()");
181 return;
182 }
183
184 // Only set if necessary
185 if ( USBKeys_Protocol == 1 )
186 return;
187
188 // TODO Analog inputs
189 // Only set on key press
190 if ( stateType != 0x01 )
191 return;
192
193 // Flush the key buffers
194 Output_flushBuffers();
195
196 // Set the keyboard protocol to NKRO Mode
197 USBKeys_Protocol = 1;
198 }
199
141 200
142 // Sends a Consumer Control code to the USB Output buffer 201 // Sends a Consumer Control code to the USB Output buffer
143 void Output_consCtrlSend_capability( uint8_t state, uint8_t stateType, uint8_t *args ) 202 void Output_consCtrlSend_capability( uint8_t state, uint8_t stateType, uint8_t *args )
144 { 203 {
145 // Display capability name 204 // Display capability name
372 431
373 432
374 433
375 // ----- Functions ----- 434 // ----- Functions -----
376 435
436 // Flush Key buffers
437 void Output_flushBuffers()
438 {
439 // Zero out USBKeys_Keys array
440 for ( uint8_t c = 0; c < USB_NKRO_BITFIELD_SIZE_KEYS; c++ )
441 USBKeys_Keys[ c ] = 0;
442
443 // Zero out other key buffers
444 USBKeys_ConsCtrl = 0;
445 USBKeys_Modifiers = 0;
446 USBKeys_SysCtrl = 0;
447 }
448
449
377 // USB Module Setup 450 // USB Module Setup
378 inline void Output_setup() 451 inline void Output_setup()
379 { 452 {
380 // Setup UART 453 // Setup UART
381 uart_serial_setup(); 454 uart_serial_setup();