mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-29 01:20:19 +00:00
commit
981e227774
17
examples/device/hid_generic_inout/hid_test.js
Normal file
17
examples/device/hid_generic_inout/hid_test.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
var HID = require('node-hid');
|
||||||
|
var devices = HID.devices();
|
||||||
|
var deviceInfo = devices.find( function(d) {
|
||||||
|
var isNRF = d.vendorId===0Xcafe && d.productId===0X4004;
|
||||||
|
return isNRF;
|
||||||
|
});
|
||||||
|
if( deviceInfo ) {
|
||||||
|
console.log(deviceInfo)
|
||||||
|
var device = new HID.HID( deviceInfo.path );
|
||||||
|
device.on("data", function(data) {console.log(data)});
|
||||||
|
|
||||||
|
device.on("error", function(err) {console.log(err)});
|
||||||
|
|
||||||
|
setInterval(function () {
|
||||||
|
device.write([0x00, 0x01, 0x01, 0x05, 0xff, 0xff]);
|
||||||
|
},500)
|
||||||
|
}
|
@ -85,7 +85,7 @@ uint8_t const desc_configuration[] =
|
|||||||
TUD_CONFIG_DESCRIPTOR(ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
|
TUD_CONFIG_DESCRIPTOR(ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
|
||||||
|
|
||||||
// Interface number, string index, protocol, report descriptor len, EP In & Out address, size & polling interval
|
// Interface number, string index, protocol, report descriptor len, EP In & Out address, size & polling interval
|
||||||
TUD_HID_INOUT_DESCRIPTOR(ITF_NUM_HID, 0, HID_PROTOCOL_NONE, sizeof(desc_hid_report), 0x80 | EPNUM_HID, EPNUM_HID, 16, 10)
|
TUD_HID_INOUT_DESCRIPTOR(ITF_NUM_HID, 0, HID_PROTOCOL_NONE, sizeof(desc_hid_report), 0x80 | EPNUM_HID, EPNUM_HID, CFG_TUD_HID_BUFSIZE, 10)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ else
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
# Build directory
|
# Build directory
|
||||||
BUILD = build-$(BOARD)
|
BUILD = _build/build-$(BOARD)
|
||||||
|
|
||||||
# Board specific
|
# Board specific
|
||||||
include $(TOP)/hw/bsp/$(BOARD)/board.mk
|
include $(TOP)/hw/bsp/$(BOARD)/board.mk
|
||||||
|
@ -100,7 +100,7 @@ size: $(BUILD)/$(BOARD)-firmware.elf
|
|||||||
-@echo ''
|
-@echo ''
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf build-$(BOARD)
|
rm -rf $(BUILD)
|
||||||
|
|
||||||
# Flash binary using Jlink
|
# Flash binary using Jlink
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(OS),Windows_NT)
|
||||||
|
@ -78,7 +78,7 @@ bool tud_hid_ready(void)
|
|||||||
|
|
||||||
bool tud_hid_report(uint8_t report_id, void const* report, uint8_t len)
|
bool tud_hid_report(uint8_t report_id, void const* report, uint8_t len)
|
||||||
{
|
{
|
||||||
TU_VERIFY( tud_hid_ready() && (len < CFG_TUD_HID_BUFSIZE) );
|
TU_VERIFY( tud_hid_ready() && (len <= CFG_TUD_HID_BUFSIZE) );
|
||||||
|
|
||||||
uint8_t itf = 0;
|
uint8_t itf = 0;
|
||||||
hidd_interface_t * p_hid = &_hidd_itf[itf];
|
hidd_interface_t * p_hid = &_hidd_itf[itf];
|
||||||
|
@ -636,7 +636,7 @@ static inline uint8_t get_new_address(void)
|
|||||||
{
|
{
|
||||||
if (_usbh_devices[addr].state == TUSB_DEVICE_STATE_UNPLUG) return addr;
|
if (_usbh_devices[addr].state == TUSB_DEVICE_STATE_UNPLUG) return addr;
|
||||||
}
|
}
|
||||||
return CFG_TUSB_HOST_DEVICE_MAX;
|
return CFG_TUSB_HOST_DEVICE_MAX+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint8_t get_configure_number_for_device(tusb_desc_device_t* dev_desc)
|
static inline uint8_t get_configure_number_for_device(tusb_desc_device_t* dev_desc)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user