Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
5b3a5beb32
|
|||
|
8a8ec23d87
|
+1
-1
@@ -1 +1 @@
|
|||||||
/build/**/*
|
/*/**/*
|
||||||
|
|||||||
+2
-2
@@ -15,7 +15,7 @@ target_sources(${PROJECT} PRIVATE
|
|||||||
bt_device.c
|
bt_device.c
|
||||||
hid_report.c
|
hid_report.c
|
||||||
main.c
|
main.c
|
||||||
usb_descriptors.c
|
#usb_descriptors.c
|
||||||
usb_device.c
|
usb_device.c
|
||||||
usb_host.c
|
usb_host.c
|
||||||
)
|
)
|
||||||
@@ -38,7 +38,7 @@ target_link_libraries(${PROJECT} PRIVATE
|
|||||||
pico_pio_usb
|
pico_pio_usb
|
||||||
pico_stdlib
|
pico_stdlib
|
||||||
tinyusb_board
|
tinyusb_board
|
||||||
tinyusb_device
|
#tinyusb_device
|
||||||
tinyusb_host
|
tinyusb_host
|
||||||
tinyusb_pico_pio_usb
|
tinyusb_pico_pio_usb
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,14 +4,19 @@ This project uses a Raspberry Pi Pico W as a Bluetooth Low Energy adapter for
|
|||||||
a wired USB HID input peripheral, allowing it to connect to a host device
|
a wired USB HID input peripheral, allowing it to connect to a host device
|
||||||
over BLE using HID over GATT Profile.
|
over BLE using HID over GATT Profile.
|
||||||
|
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
|
[YouTube Video](https://youtu.be/YuHbTrccshw)
|
||||||
|
|
||||||
### Hardware
|
### Hardware
|
||||||
|
|
||||||
You will need the following hardware to make the device:
|
You will need the following hardware to make the device:
|
||||||
- Raspberry Pi Pico W
|
- Raspberry Pi Pico W
|
||||||
- USB extension cable
|
- USB extension cable
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
You will need to cut the USB extension in half and connect the wires from the
|
You will need to cut the USB extension in half and connect the wires from the
|
||||||
female end to the Raspberry Pi Pico W. The default configuration is to attach
|
female end to the Raspberry Pi Pico W. The default configuration is to attach
|
||||||
the USB's green wire to pin 1/GP0 and USB's white wire to pin 2/GP1. You will
|
the USB's green wire to pin 1/GP0 and USB's white wire to pin 2/GP1. You will
|
||||||
|
|||||||
@@ -45,9 +45,6 @@ const uint8_t adv_data_len = sizeof(adv_data);
|
|||||||
static void bt_hid_setup(void);
|
static void bt_hid_setup(void);
|
||||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||||
|
|
||||||
//extern uint8_t desc_hid_report[];
|
|
||||||
//extern uint16_t desc_hid_report_len;
|
|
||||||
|
|
||||||
// start BTstack
|
// start BTstack
|
||||||
void btstack_main(void){
|
void btstack_main(void){
|
||||||
bt_hid_setup();
|
bt_hid_setup();
|
||||||
|
|||||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 511 KiB |
@@ -27,7 +27,7 @@ int main(void) {
|
|||||||
usb_host_init();
|
usb_host_init();
|
||||||
|
|
||||||
// init and run usb device
|
// init and run usb device
|
||||||
usb_device_init();
|
//usb_device_init();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
switch ( get_host_state() ) {
|
switch ( get_host_state() ) {
|
||||||
@@ -64,8 +64,8 @@ int main(void) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
tuh_task(); // tinyusb host task
|
tuh_task(); // tinyusb host task
|
||||||
tud_task(); // tinyusb device task
|
//tud_task(); // tinyusb device task
|
||||||
tud_cdc_write_flush();
|
//tud_cdc_write_flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
+2
-1
@@ -39,7 +39,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Enable device stack
|
// Enable device stack
|
||||||
#define CFG_TUD_ENABLED 1
|
//#define CFG_TUD_ENABLED 1
|
||||||
|
#define CFG_TUD_ENABLED 0
|
||||||
|
|
||||||
// Enable host stack
|
// Enable host stack
|
||||||
#define CFG_TUH_ENABLED 1
|
#define CFG_TUH_ENABLED 1
|
||||||
|
|||||||
+7
-3
@@ -44,18 +44,22 @@ uint16_t tud_hid_get_report_cb(uint8_t instance, uint8_t report_id, hid_report_t
|
|||||||
|
|
||||||
// print message to CDC in raw hex
|
// print message to CDC in raw hex
|
||||||
void cdc_print_hex(uint8_t const* msg, uint16_t msg_len) {
|
void cdc_print_hex(uint8_t const* msg, uint16_t msg_len) {
|
||||||
char tempbuf[8];
|
(void) msg;
|
||||||
|
(void) msg_len;
|
||||||
|
/*char tempbuf[8];
|
||||||
size_t count;
|
size_t count;
|
||||||
for (int i=0; i<msg_len; i++) {
|
for (int i=0; i<msg_len; i++) {
|
||||||
count=sprintf(tempbuf, "%02X ", msg[i]);
|
count=sprintf(tempbuf, "%02X ", msg[i]);
|
||||||
tud_cdc_write(tempbuf, count);
|
tud_cdc_write(tempbuf, count);
|
||||||
}
|
}
|
||||||
tud_cdc_write_str("\n");
|
tud_cdc_write_str("\n");*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// print text message to CDC
|
// print text message to CDC
|
||||||
void cdc_print_str(char const* msg, uint16_t msg_len) {
|
void cdc_print_str(char const* msg, uint16_t msg_len) {
|
||||||
tud_cdc_write(msg, msg_len);
|
(void) msg;
|
||||||
|
(void) msg_len;
|
||||||
|
//tud_cdc_write(msg, msg_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cdc_print_msg(char const* msg) {
|
void cdc_print_msg(char const* msg) {
|
||||||
|
|||||||
Reference in New Issue
Block a user