Forum: Mikrocontroller und Digitale Elektronik AT90USC1287 Generic HID Device (LUFA Library)


von Börly M. (boerly)


Lesenswert?

Hallo,

ich habe vor ein paar Zuständer der IO Ports über USB an den PC zu 
senden.
Geplant habe ich dieses mit der LUFA Library wie in der Demo 
'ClassDriver/Generic HID Device' zu machen. In der Demo wird der Wert 
welcher vom usb empfangen wird wider an den PC über den USB 
zurückgesendet. Ich habe den Ansatz verfolgt an der Stelle wo die Daten 
zurückgesendet werden so zu ändern, dass dort die Informationen der der 
IO Ports gesendet werden sollen.

Leider komme ich mit der lokalisierung noch nicht so ganz zurecht.
Hat da Jemand schon Erfahrungen gemacht und kann mir einen Tipp geben?

Auszug aus der GenerigHID.c:

/** HID class driver callback function for the creation of HID reports 
to the host.
 *
 *  \param[in]     HIDInterfaceInfo  Pointer to the HID class interface 
configuration structure being referenced
 *  \param[in,out] ReportID    Report ID requested by the host if 
non-zero, otherwise callback should set to the generated report ID
 *  \param[in]     ReportType  Type of the report to create, either 
REPORT_ITEM_TYPE_In or REPORT_ITEM_TYPE_Feature
 *  \param[out]    ReportData  Pointer to a buffer where the created 
report should be stored
 *  \param[out]    ReportSize  Number of bytes written in the report (or 
zero if no report is to be sent
 *
 *  \return Boolean true to force the sending of the report, false to 
let the library determine if it needs to be sent
 */
bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* 
const HIDInterfaceInfo,
                                         uint8_t* const ReportID,
                                         const uint8_t ReportType,
                                         void* ReportData,
                                         uint16_t* const ReportSize)
{
  if (HIDReportEcho.ReportID)
    *ReportID = HIDReportEcho.ReportID;

  memcpy(ReportData, HIDReportEcho.ReportData, 
HIDReportEcho.ReportSize);

  *ReportSize = HIDReportEcho.ReportSize;
  return true;
}

/** HID class driver callback function for the processing of HID reports 
from the host.
 *
 *  \param[in] HIDInterfaceInfo  Pointer to the HID class interface 
configuration structure being referenced
 *  \param[in] ReportID    Report ID of the received report from the 
host
 *  \param[in] ReportType  The type of report that the host has sent, 
either REPORT_ITEM_TYPE_Out or REPORT_ITEM_TYPE_Feature
 *  \param[in] ReportData  Pointer to a buffer where the created report 
has been stored
 *  \param[in] ReportSize  Size in bytes of the received HID report
 */
void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* 
const HIDInterfaceInfo,
                                          const uint8_t ReportID,
                                          const uint8_t ReportType,
                                          const void* ReportData,
                                          const uint16_t ReportSize)
{
  HIDReportEcho.ReportID   = ReportID;
  HIDReportEcho.ReportSize = ReportSize;
  memcpy(HIDReportEcho.ReportData, ReportData, ReportSize);
}

von Stefan B. (-stefan-)


Lesenswert?

Hallo,

Kein Anhung, ob es noch von Interesse ist. Daher eine sehr kurze 
Antwort.
Deine gesendete und empfangene Daten stecken im Array 'ReportData'. 
Dieses hat die Länge ReportSize. Definiert in Descriptors.h. Im Array 
stecken uint8_t Werte.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.