Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 9124

General • Is my understanding of this code correct?

$
0
0

Code:

#include "tusb.h"#include "usbh.h"#include "hid_host.h"#include "H:/tinyusb/src/host/hcd.h"#include <stdio.h>void keyboard_processing(void){    hcd_event_t event; //this variable stores the things and the main events that happen in the host    tuh_itf_info_t interface_info;    struct tuh_xfer_s transfer_s;    hid_interface_protocol_enum_t protocol_enum = HID_ITF_PROTOCOL_KEYBOARD;        uint8_t interface_protocol_save = 0;    uint8_t interface_count = tuh_hid_itf_get_count(transfer_s.daddr);        for(uint8_t i = 0; i < interface_count;i++){        uint8_t idx = tuh_hid_itf_get_index(interface_info.daddr,i);        uint8_t interface_protocol = tuh_hid_interface_protocol(interface_count,idx);        if (interface_protocol == HID_ITF_PROTOCOL_KEYBOARD) {            printf("%d protocol\n",interface_protocol);            interface_protocol_save = interface_protocol;        }        else if(interface_protocol ==(protocol_enum =HID_ITF_PROTOCOL_NONE )){            printf("%d protocol\n",interface_protocol);            interface_protocol_save = interface_protocol;        }        else{            printf("None!!\n");            interface_protocol_save = interface_protocol;        }    }}
Hello all.

I'm trying to use the tinyusb code to process my keybiard and have used their interface function so far. My Q is that is my understanding right that when I declare a functioin like hcd_event it would have sdata stored into it from the prior callbacks and usagess, and therefore I could use the value stored in there as parameters to pass to functions.

Kind regards
Maaz Madha

Statistics: Posted by Maaz1 — Wed Nov 05, 2025 10:41 am



Viewing all articles
Browse latest Browse all 9124

Trending Articles