Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
ws2-cap
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
Package registry
Model registry
Operate
Environments
Terraform modules
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
k2-alfadhala
ws2-cap
Commits
1bb1cef3
Commit
1bb1cef3
authored
2 months ago
by
k2-alfadhala
Browse files
Options
Downloads
Patches
Plain Diff
usb functions
parent
7dbb00b3
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
usb_serial.c
+35
-0
35 additions, 0 deletions
usb_serial.c
with
35 additions
and
0 deletions
usb_serial.c
0 → 100644
+
35
−
0
View file @
1bb1cef3
#include
"usb_serial.h"
void
usb_init
(
void
)
{
tusb_init
();
// Setup USB
}
int
usb_write
(
const
uint8_t
*
buf
,
int
len
)
{
if
(
!
tud_cdc_connected
())
return
-
1
;
int
sent_total
=
0
;
while
(
len
>
0
)
{
int
sent
=
tud_cdc_write
(
buf
,
len
);
if
(
sent
<
0
)
return
sent
;
tud_cdc_write_flush
();
buf
+=
sent
;
len
-=
sent
;
sent_total
+=
sent
;
}
return
sent_total
;
}
int
usb_read
(
uint8_t
*
buf
,
int
len
)
{
if
(
tud_cdc_available
())
{
return
tud_cdc_read
(
buf
,
len
);
}
return
0
;
}
void
usb_cleanup
(
void
)
{
}
bool
usb_connected
(
void
)
{
return
tud_cdc_connected
();
}
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