Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lufa
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Erik Strand
lufa
Commits
dab7e06a
Commit
dab7e06a
authored
14 years ago
by
Dean Camera
Browse files
Options
Downloads
Patches
Plain Diff
Split HIDReportViewer project sub-components into seperate functions for readability/convenience.
parent
ea3b5c74
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Projects/HIDReportViewer/HIDReportViewer.c
+100
-70
100 additions, 70 deletions
Projects/HIDReportViewer/HIDReportViewer.c
Projects/HIDReportViewer/HIDReportViewer.h
+3
-0
3 additions, 0 deletions
Projects/HIDReportViewer/HIDReportViewer.h
with
103 additions
and
70 deletions
Projects/HIDReportViewer/HIDReportViewer.c
+
100
−
70
View file @
dab7e06a
...
@@ -123,10 +123,29 @@ int main(void)
...
@@ -123,10 +123,29 @@ int main(void)
case
HOST_STATE_Configured
:
case
HOST_STATE_Configured
:
LEDs_SetAllLEDs
(
LEDMASK_USB_BUSY
);
LEDs_SetAllLEDs
(
LEDMASK_USB_BUSY
);
OutputReportSizes
();
OutputParsedReportItems
();
LEDs_SetAllLEDs
(
LEDMASK_USB_READY
);
USB_HostState
=
HOST_STATE_WaitForDeviceRemoval
;
break
;
}
HID_Host_USBTask
(
&
Device_HID_Interface
);
USB_USBTask
();
}
}
/** Prints a summary of the device's HID report sizes from the HID parser output to the serial port
* for display to the user.
*/
void
OutputReportSizes
(
void
)
{
printf_P
(
PSTR
(
"
\r\n\r\n
Total Device Reports: %"
PRId8
"
\r\n
"
),
HIDReportInfo
.
TotalDeviceReports
);
printf_P
(
PSTR
(
"
\r\n\r\n
Total Device Reports: %"
PRId8
"
\r\n
"
),
HIDReportInfo
.
TotalDeviceReports
);
for
(
uint8_t
ReportIndex
=
0
;
ReportIndex
<
HIDReportInfo
.
TotalDeviceReports
;
ReportIndex
++
)
for
(
uint8_t
ReportIndex
=
0
;
ReportIndex
<
HIDReportInfo
.
TotalDeviceReports
;
ReportIndex
++
)
{
{
HID_ReportSizeInfo_t
*
CurrReportIDInfo
=
&
HIDReportInfo
.
ReportIDSizes
[
ReportIndex
];
const
HID_ReportSizeInfo_t
*
CurrReportIDInfo
=
&
HIDReportInfo
.
ReportIDSizes
[
ReportIndex
];
uint8_t
ReportSizeInBits
=
CurrReportIDInfo
->
ReportSizeBits
[
HID_REPORT_ITEM_In
];
uint8_t
ReportSizeInBits
=
CurrReportIDInfo
->
ReportSizeBits
[
HID_REPORT_ITEM_In
];
uint8_t
ReportSizeOutBits
=
CurrReportIDInfo
->
ReportSizeBits
[
HID_REPORT_ITEM_Out
];
uint8_t
ReportSizeOutBits
=
CurrReportIDInfo
->
ReportSizeBits
[
HID_REPORT_ITEM_Out
];
...
@@ -145,8 +164,15 @@ int main(void)
...
@@ -145,8 +164,15 @@ int main(void)
ReportSizeFeatureBits
,
ReportSizeFeatureBits
,
((
ReportSizeFeatureBits
>>
3
)
+
((
ReportSizeFeatureBits
&
0x07
)
!=
0
)));
((
ReportSizeFeatureBits
>>
3
)
+
((
ReportSizeFeatureBits
&
0x07
)
!=
0
)));
}
}
}
/** Prints a summary of the device's parsed and stored report items along with their attributes
* to the serial port for display to the user.
*/
void
OutputParsedReportItems
(
void
)
{
printf_P
(
PSTR
(
"
\r\n
Report Items (%"
PRId8
" in Table):
\r\n
"
),
HIDReportInfo
.
TotalReportItems
);
printf_P
(
PSTR
(
"
\r\n
Report Items (%"
PRId8
" Stored in Table):
\r\n
"
),
HIDReportInfo
.
TotalReportItems
);
for
(
uint8_t
ItemIndex
=
0
;
ItemIndex
<
HIDReportInfo
.
TotalReportItems
;
ItemIndex
++
)
for
(
uint8_t
ItemIndex
=
0
;
ItemIndex
<
HIDReportInfo
.
TotalReportItems
;
ItemIndex
++
)
{
{
const
HID_ReportItem_t
*
RItem
=
&
HIDReportInfo
.
ReportItems
[
ItemIndex
];
const
HID_ReportItem_t
*
RItem
=
&
HIDReportInfo
.
ReportItems
[
ItemIndex
];
...
@@ -181,27 +207,31 @@ int main(void)
...
@@ -181,27 +207,31 @@ int main(void)
RItem
->
Attributes
.
Physical
.
Minimum
,
RItem
->
Attributes
.
Physical
.
Minimum
,
RItem
->
Attributes
.
Physical
.
Maximum
);
RItem
->
Attributes
.
Physical
.
Maximum
);
const
HID_CollectionPath_t
*
CollectionPath
=
RItem
->
CollectionPath
;
OutputCollectionPath
(
RItem
->
CollectionPath
);
}
}
while
(
CollectionPath
!=
NULL
)
/** Prints the HID Collection path (along with each node's attributes) to the serial port
* for display to the user, from the given starting node to the root node.
*
* \param[in] CollectionPath Starting HID Collection node to print
*/
void
OutputCollectionPath
(
const
HID_CollectionPath_t
*
const
CollectionPath
)
{
const
HID_CollectionPath_t
*
CurrentNode
=
CollectionPath
;
while
(
CurrentNode
!=
NULL
)
{
{
printf_P
(
PSTR
(
" |
\r\n
"
printf_P
(
PSTR
(
" |
\r\n
"
" - Type: 0x%02"
PRIX8
"
\r\n
"
" - Type: 0x%02"
PRIX8
"
\r\n
"
" - Usage: 0x%02"
PRIX8
"
\r\n
"
),
" - Usage: 0x%02"
PRIX8
"
\r\n
"
),
CollectionPath
->
Type
,
CollectionPath
->
Usage
);
CurrentNode
->
Type
,
CurrentNode
->
Usage
);
CollectionPath
=
CollectionPath
->
Parent
;
CurrentNode
=
CurrentNode
->
Parent
;
}
}
}
LEDs_SetAllLEDs
(
LEDMASK_USB_READY
);
printf_P
(
PSTR
(
" |
\r\n
"
USB_HostState
=
HOST_STATE_WaitForDeviceRemoval
;
" END
\r\n
"
));
break
;
}
HID_Host_USBTask
(
&
Device_HID_Interface
);
USB_USBTask
();
}
}
}
/** Configures the board hardware and chip peripherals for the demo's functionality. */
/** Configures the board hardware and chip peripherals for the demo's functionality. */
...
...
This diff is collapsed.
Click to expand it.
Projects/HIDReportViewer/HIDReportViewer.h
+
3
−
0
View file @
dab7e06a
...
@@ -69,6 +69,9 @@
...
@@ -69,6 +69,9 @@
/* Function Prototypes: */
/* Function Prototypes: */
void
SetupHardware
(
void
);
void
SetupHardware
(
void
);
void
OutputReportSizes
(
void
);
void
OutputParsedReportItems
(
void
);
void
OutputCollectionPath
(
const
HID_CollectionPath_t
*
const
CollectionPath
);
void
EVENT_USB_Host_HostError
(
const
uint8_t
ErrorCode
);
void
EVENT_USB_Host_HostError
(
const
uint8_t
ErrorCode
);
void
EVENT_USB_Host_DeviceAttached
(
void
);
void
EVENT_USB_Host_DeviceAttached
(
void
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment