aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2014-06-20 14:39:49 +0900
committertmk <nobody@nowhere>2014-07-30 14:07:43 +0900
commitb4a91ecf4e46ee533563fd759e26dd249bf6b4de (patch)
treecc52fa874d471a3f15d5cdda64fc3e6232d88303
parent4c8e0fd0bd1712421f957ec5e0ca16fc6bbb3856 (diff)
downloadqmk_firmware-b4a91ecf4e46ee533563fd759e26dd249bf6b4de.tar.gz
qmk_firmware-b4a91ecf4e46ee533563fd759e26dd249bf6b4de.zip
Add LED indicator support in mbed
-rw-r--r--protocol/mbed/HIDKeyboard.cpp45
-rw-r--r--protocol/mbed/HIDKeyboard.h4
-rw-r--r--protocol/mbed/mbed_driver.cpp2
3 files changed, 35 insertions, 16 deletions
diff --git a/protocol/mbed/HIDKeyboard.cpp b/protocol/mbed/HIDKeyboard.cpp
index f40c2d2f2..947077cd2 100644
--- a/protocol/mbed/HIDKeyboard.cpp
+++ b/protocol/mbed/HIDKeyboard.cpp
@@ -17,6 +17,10 @@ bool HIDKeyboard::sendReport(report_keyboard_t report) {
17 return true; 17 return true;
18} 18}
19 19
20uint8_t HIDKeyboard::leds() {
21 return led_state;
22}
23
20bool HIDKeyboard::USBCallback_setConfiguration(uint8_t configuration) { 24bool HIDKeyboard::USBCallback_setConfiguration(uint8_t configuration) {
21 if (configuration != DEFAULT_CONFIGURATION) { 25 if (configuration != DEFAULT_CONFIGURATION) {
22 return false; 26 return false;
@@ -228,29 +232,40 @@ bool HIDKeyboard::USBCallback_request() {
228 } 232 }
229 233
230 // Process class-specific requests 234 // Process class-specific requests
231/*
232 if (transfer->setup.bmRequestType.Type == CLASS_TYPE) 235 if (transfer->setup.bmRequestType.Type == CLASS_TYPE)
233 { 236 {
234 switch (transfer->setup.bRequest) 237 switch (transfer->setup.bRequest) {
235 { 238 case SET_REPORT:
236 case SET_REPORT: 239 // LED indicator
237 // First byte will be used for report ID 240 // TODO: check Interface and Report length?
238 //outputReport.data[0] = transfer->setup.wValue & 0xff; 241 // if (transfer->setup.wIndex == INTERFACE_KEYBOAD) { }
239 //outputReport.length = transfer->setup.wLength + 1; 242 // if (transfer->setup.wLength == 1)
240 outputReport.length = transfer->setup.wLength; 243
241 244 transfer->remaining = 1;
242 //transfer->remaining = sizeof(outputReport.data) - 1; 245 //transfer->ptr = ?? what ptr should be set when OUT(not used?)
243 //transfer->ptr = &outputReport.data[1];
244 transfer->remaining = sizeof(outputReport.data);
245 transfer->ptr = &outputReport.data[0];
246 transfer->direction = HOST_TO_DEVICE; 246 transfer->direction = HOST_TO_DEVICE;
247 transfer->notify = true; 247 transfer->notify = true; /* notify with USBCallback_requestCompleted */
248 success = true; 248 success = true;
249 default: 249 default:
250 break; 250 break;
251 } 251 }
252 } 252 }
253*/
254 253
255 return success; 254 return success;
256} 255}
256
257void HIDKeyboard::USBCallback_requestCompleted(uint8_t * buf, uint32_t length)
258{
259 if (length > 0) {
260 CONTROL_TRANSFER *transfer = getTransferPtr();
261 if (transfer->setup.bmRequestType.Type == CLASS_TYPE) {
262 switch (transfer->setup.bRequest) {
263 case SET_REPORT:
264 led_state = buf[0];
265 break;
266 default:
267 break;
268 }
269 }
270 }
271}
diff --git a/protocol/mbed/HIDKeyboard.h b/protocol/mbed/HIDKeyboard.h
index 4ebe610a6..c537e5ece 100644
--- a/protocol/mbed/HIDKeyboard.h
+++ b/protocol/mbed/HIDKeyboard.h
@@ -11,6 +11,7 @@ public:
11 HIDKeyboard(uint16_t vendor_id = 0xFEED, uint16_t product_id = 0xabed, uint16_t product_release = 0x0001); 11 HIDKeyboard(uint16_t vendor_id = 0xFEED, uint16_t product_id = 0xabed, uint16_t product_release = 0x0001);
12 12
13 bool sendReport(report_keyboard_t report); 13 bool sendReport(report_keyboard_t report);
14 uint8_t leds(void);
14protected: 15protected:
15 uint16_t reportLength; 16 uint16_t reportLength;
16 virtual bool USBCallback_setConfiguration(uint8_t configuration); 17 virtual bool USBCallback_setConfiguration(uint8_t configuration);
@@ -22,6 +23,9 @@ protected:
22 virtual uint8_t * configurationDesc(); 23 virtual uint8_t * configurationDesc();
23 //virtual uint8_t * deviceDesc(); 24 //virtual uint8_t * deviceDesc();
24 virtual bool USBCallback_request(); 25 virtual bool USBCallback_request();
26 virtual void USBCallback_requestCompleted(uint8_t * buf, uint32_t length);
27private:
28 uint8_t led_state;
25}; 29};
26 30
27#endif 31#endif
diff --git a/protocol/mbed/mbed_driver.cpp b/protocol/mbed/mbed_driver.cpp
index 333f8e378..6c7b16e23 100644
--- a/protocol/mbed/mbed_driver.cpp
+++ b/protocol/mbed/mbed_driver.cpp
@@ -24,7 +24,7 @@ host_driver_t mbed_driver = {
24 24
25static uint8_t keyboard_leds(void) 25static uint8_t keyboard_leds(void)
26{ 26{
27 return 0; 27 return keyboard.leds();
28} 28}
29static void send_keyboard(report_keyboard_t *report) 29static void send_keyboard(report_keyboard_t *report)
30{ 30{