rewrite a rawhid program with tinyusb

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
hlcm
 
Posts: 1
Joined: Tue May 17, 2022 10:46 pm

rewrite a rawhid program with tinyusb

Post by hlcm »

I am recently working on a project using RawHID from NicoHood's HID-Project, but the code only works on promicro but not samd21

I want to rewrite it using TinyUSB, But failed to understand how to send buffer and receive buffer just like the old code.

here is my original code

Code: Select all

#include "stdinclude.hpp"

namespace component {
    namespace raw_hid {
        uint8_t rawBuffer[255];
        uint8_t outBuffer[64];
        uint8_t inBuffer[64];

        output_data_t *pOutputData = reinterpret_cast<output_data_t *>(outBuffer);
        input_data_t *pInputData = reinterpret_cast<input_data_t *>(inBuffer);

        void start() {
            RawHID.begin(rawBuffer, sizeof(rawBuffer));
        }

        void update() {
            ongeki_hardware::read_io(pOutputData);
            RawHID.write(outBuffer, 64);

            if (RawHID.available()) {
                RawHID.readBytes(inBuffer, 64);

                switch (pInputData->type) {
                    case 0: {
                        ongeki_hardware::set_led(pInputData->led);
                        break;
                    }
                    case 1: {
                        break;
                    }
                }
            }
        }
    }
}
How could I use the TinyUSB lib to inplace the "RawHID.begin" , "RawHID.write" and "RawHID.readbytes" commands ?
Or what command in TinyUSB lib has the same function as those above?

I will glad if someone could teach me!

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”