🇺🇸Adafruit will not be shipping orders on Independence Day Monday 7/4/2022. Please allow extra time for your order to ship and plan accordingly.🇺🇸
0

rewrite a rawhid program with tinyusb
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

rewrite a rawhid program with tinyusb

by hlcm on Tue May 17, 2022 10:56 pm

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 | TOGGLE FULL SIZE
#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!

hlcm
 
Posts: 1
Joined: Tue May 17, 2022 10:46 pm

Please be positive and constructive with your questions and comments.