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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Erik Strand
lufa
Commits
961da384
Commit
961da384
authored
12 years ago
by
Dean Camera
Browse files
Options
Downloads
Patches
Plain Diff
Add proper reset handling to the USB Printer Device Class driver.
parent
95ba6527
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
LUFA/Drivers/USB/Class/Device/PrinterClassDevice.c
+18
-1
18 additions, 1 deletion
LUFA/Drivers/USB/Class/Device/PrinterClassDevice.c
LUFA/Drivers/USB/Class/Device/PrinterClassDevice.h
+9
-3
9 additions, 3 deletions
LUFA/Drivers/USB/Class/Device/PrinterClassDevice.h
with
27 additions
and
4 deletions
LUFA/Drivers/USB/Class/Device/PrinterClassDevice.c
+
18
−
1
View file @
961da384
...
...
@@ -59,7 +59,7 @@ void PRNT_Device_ProcessControlRequest(USB_ClassInfo_PRNT_Device_t* const PRNTIn
}
uint16_t
IEEEStringLen
=
strlen
(
PRNTInterfaceInfo
->
Config
.
IEEE1284String
);
Endpoint_Write_16_BE
(
IEEEStringLen
+
1
);
Endpoint_Write_16_BE
(
IEEEStringLen
);
Endpoint_Write_Control_Stream_LE
(
PRNTInterfaceInfo
->
Config
.
IEEE1284String
,
IEEEStringLen
);
Endpoint_ClearStatusStage
();
}
...
...
@@ -87,6 +87,8 @@ void PRNT_Device_ProcessControlRequest(USB_ClassInfo_PRNT_Device_t* const PRNTIn
Endpoint_ClearSETUP
();
Endpoint_ClearStatusStage
();
PRNTInterfaceInfo
->
State
.
IsPrinterReset
=
true
;
EVENT_PRNT_Device_SoftReset
(
PRNTInterfaceInfo
);
}
...
...
@@ -122,6 +124,21 @@ void PRNT_Device_USBTask(USB_ClassInfo_PRNT_Device_t* const PRNTInterfaceInfo)
if
(
Endpoint_IsINReady
())
PRNT_Device_Flush
(
PRNTInterfaceInfo
);
#endif
if
(
PRNTInterfaceInfo
->
State
.
IsPrinterReset
)
{
Endpoint_ResetEndpoint
(
PRNTInterfaceInfo
->
Config
.
DataOUTEndpoint
.
Address
);
Endpoint_ResetEndpoint
(
PRNTInterfaceInfo
->
Config
.
DataINEndpoint
.
Address
);
Endpoint_SelectEndpoint
(
PRNTInterfaceInfo
->
Config
.
DataOUTEndpoint
.
Address
);
Endpoint_ClearStall
();
Endpoint_ResetDataToggle
();
Endpoint_SelectEndpoint
(
PRNTInterfaceInfo
->
Config
.
DataINEndpoint
.
Address
);
Endpoint_ClearStall
();
Endpoint_ResetDataToggle
();
PRNTInterfaceInfo
->
State
.
IsPrinterReset
=
false
;
}
}
uint8_t
PRNT_Device_SendString
(
USB_ClassInfo_PRNT_Device_t
*
const
PRNTInterfaceInfo
,
...
...
This diff is collapsed.
Click to expand it.
LUFA/Drivers/USB/Class/Device/PrinterClassDevice.h
+
9
−
3
View file @
961da384
...
...
@@ -87,14 +87,20 @@
USB_Endpoint_Table_t
DataOUTEndpoint
;
/**< Data OUT endpoint configuration table. */
char
*
IEEE1284String
;
/**< IEEE 1284 identification string, sent to the host during enumeration
* to identify the printer model, manufacturer and other characteristics. */
* to identify the printer model, manufacturer and other characteristics.
*/
}
Config
;
/**< Config data for the USB class interface within the device. All elements in this section
* <b>must</b> be set or the interface will fail to enumerate and operate correctly.
*/
struct
{
uint8_t
PortStatus
;
/**< Current status of the Printer virtual port, a collection of \c PRNT_PORTSTATUS_*
* bitmask values. */
* bitmask values.
*/
volatile
bool
IsPrinterReset
;
/**< Flag indicating that the host has requested that the Printer interface be reset
* and that all current Mass Storage operations should immediately abort.
*/
}
State
;
/**< State data for the USB class interface within the device. All elements in this section
* are reset to their defaults when the interface is enumerated.
*/
...
...
@@ -131,7 +137,7 @@
*
* \param[in,out] PRNTInterfaceInfo Pointer to a structure containing a Printer Class configuration and state.
*/
void
EVENT_PRNT_Device_SoftReset
(
USB_ClassInfo_
CDC
_Device_t
*
const
CDC
InterfaceInfo
)
ATTR_NON_NULL_PTR_ARG
(
1
);
void
EVENT_PRNT_Device_SoftReset
(
USB_ClassInfo_
PRNT
_Device_t
*
const
PRNT
InterfaceInfo
)
ATTR_NON_NULL_PTR_ARG
(
1
);
/** Sends a given data buffer to the attached USB host, if connected. If a host is not connected when the function is
* called, the string is discarded. Bytes will be queued for transmission to the host until either the endpoint bank
...
...
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