Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
fwatch
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
8
Issues
8
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
fwatch
Commits
98faf2d7
Commit
98faf2d7
authored
Aug 20, 2014
by
Theodor-Adrian Stana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
usb-debug: Made easier to use
parent
d945b39c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
18 deletions
+70
-18
usbdbg.c
sw/common/usb/usbdbg.c
+52
-2
usbdbg.h
sw/common/usb/usbdbg.h
+14
-12
Makefile
sw/usbdcdc/armgcc/Makefile
+1
-1
main.c
sw/usbdcdc/src/main.c
+3
-3
No files found.
sw/common/usb/usbd
esc
.c
→
sw/common/usb/usbd
bg
.c
View file @
98faf2d7
#include "usbdesc.h"
#include <stdio.h>
#include <string.h>
#include "usbdbg.h"
#include "em_usb.h"
/* The serial port LINE CODING data structure, used to carry information */
/* about serial port baudrate, parity etc. between host and device. */
...
...
@@ -36,7 +39,7 @@ EFM32_PACK_END()
* USB_STATUS_REQ_UNHANDLED when command is unknown, the USB device
* stack will handle the request.
*****************************************************************************/
int
usbd
esc
_cb_setup
(
const
USB_Setup_TypeDef
*
setup
)
int
usbd
bg
_cb_setup
(
const
USB_Setup_TypeDef
*
setup
)
{
int
r
=
USB_STATUS_REQ_UNHANDLED
;
...
...
@@ -82,3 +85,50 @@ int usbdesc_cb_setup(const USB_Setup_TypeDef *setup)
return
r
;
}
/**************************************************************************//**
* @brief
* Wrapper for USB device stack init.
*
* @param[in] none
*
* @return none
*****************************************************************************/
void
usbdbg_init
()
{
USBD_Init
(
&
initstruct
);
}
/**************************************************************************//**
* @brief
* USB puts() function. Prints up to USBDBG_BULK_EP_SIZE-1 characters on
* USB, or throws EOF if more than USBDBG_BULK_EP_SIZE-1 characters are
* attempted to be transmitted, or the EOF character itself is received.
*
* @param[in] s String to put on USB
*
* @return 1 on success
* -1 (EOF) otherwise
*****************************************************************************/
int
usbdbg_puts
(
const
char
*
s
)
{
char
buf
[
USBDBG_BULK_EP_SIZE
];
int
cnt
=
0
;
/* Fill buffer */
while
(
*
s
)
{
if
((
*
s
==
EOF
)
||
(
cnt
==
USBDBG_BULK_EP_SIZE
-
1
))
return
EOF
;
buf
[
cnt
++
]
=
*
s
;
s
++
;
}
/* Null-terminate and roll back pointer */
buf
[
cnt
]
=
'\0'
;
/* Call USB stack function we're so desperately trying to hide */
USBD_Write
(
USBDBG_EP_DATA_OUT
,
(
void
*
)
buf
,
strlen
(
buf
),
NULL
);
return
1
;
}
sw/common/usb/usbd
esc
.h
→
sw/common/usb/usbd
bg
.h
View file @
98faf2d7
...
...
@@ -22,17 +22,19 @@ extern "C" {
/*=====================*/
/* Function prototypes */
/*=====================*/
int
usbdesc_cb_setup
(
const
USB_Setup_TypeDef
*
setup
);
void
usbdbg_init
();
int
usbdbg_puts
(
const
char
*
s
);
int
usbdbg_cb_setup
(
const
USB_Setup_TypeDef
*
setup
);
/*===============================*/
/* Define USB endpoint addresses */
/*===============================*/
#define USBD
ESC_EP_DATA_IN
0x01
/* Endpoint for USB data reception. */
#define USBD
ESC_EP_DATA_OUT
0x81
/* Endpoint for USB data transmission. */
#define USBD
ESC_EP_NOTIFY
0x82
/* The notification endpoint (not used). */
#define USBD
BG_EP_DATA_IN
0x01
/* Endpoint for USB data reception. */
#define USBD
BG_EP_DATA_OUT
0x81
/* Endpoint for USB data transmission. */
#define USBD
BG_EP_NOTIFY
0x82
/* The notification endpoint (not used). */
#define USBD
ESC_BULK_EP_SIZE
USB_MAX_EP_SIZE
/* This is the max. ep size. */
#define USBD
BG_BULK_EP_SIZE
USB_MAX_EP_SIZE
/* This is the max. ep size. */
EFM32_ALIGN
(
4
)
static
const
USB_DeviceDescriptor_TypeDef
deviceDesc
__attribute__
((
aligned
(
4
)))
=
...
...
@@ -126,9 +128,9 @@ static const uint8_t configDesc[] __attribute__ ((aligned(4)))=
/*** CDC Notification endpoint descriptor ***/
USB_ENDPOINT_DESCSIZE
,
/* bLength */
USB_ENDPOINT_DESCRIPTOR
,
/* bDescriptorType */
USBD
ESC_EP_NOTIFY
,
/* bEndpointAddress (IN) */
USBD
BG_EP_NOTIFY
,
/* bEndpointAddress (IN) */
USB_EPTYPE_INTR
,
/* bmAttributes */
USBD
ESC_BULK_EP_SIZE
,
/* wMaxPacketSize (LSB) */
USBD
BG_BULK_EP_SIZE
,
/* wMaxPacketSize (LSB) */
0
,
/* wMaxPacketSize (MSB) */
0xFF
,
/* bInterval */
...
...
@@ -146,17 +148,17 @@ static const uint8_t configDesc[] __attribute__ ((aligned(4)))=
/*** CDC Data interface endpoint descriptors ***/
USB_ENDPOINT_DESCSIZE
,
/* bLength */
USB_ENDPOINT_DESCRIPTOR
,
/* bDescriptorType */
USBD
ESC_EP_DATA_IN
,
/* bEndpointAddress (IN) */
USBD
BG_EP_DATA_IN
,
/* bEndpointAddress (IN) */
USB_EPTYPE_BULK
,
/* bmAttributes */
USBD
ESC_BULK_EP_SIZE
,
/* wMaxPacketSize (LSB) */
USBD
BG_BULK_EP_SIZE
,
/* wMaxPacketSize (LSB) */
0
,
/* wMaxPacketSize (MSB) */
0
,
/* bInterval */
USB_ENDPOINT_DESCSIZE
,
/* bLength */
USB_ENDPOINT_DESCRIPTOR
,
/* bDescriptorType */
USBD
ESC_EP_DATA_OUT
,
/* bEndpointAddress (OUT)*/
USBD
BG_EP_DATA_OUT
,
/* bEndpointAddress (OUT)*/
USB_EPTYPE_BULK
,
/* bmAttributes */
USBD
ESC_BULK_EP_SIZE
,
/* wMaxPacketSize (LSB) */
USBD
BG_BULK_EP_SIZE
,
/* wMaxPacketSize (LSB) */
0
,
/* wMaxPacketSize (MSB) */
0
/* bInterval */
};
...
...
@@ -186,7 +188,7 @@ static const USBD_Callbacks_TypeDef callbacks =
{
.
usbReset
=
NULL
,
.
usbStateChange
=
NULL
,
.
setupCmd
=
usbd
esc
_cb_setup
,
.
setupCmd
=
usbd
bg
_cb_setup
,
.
isSelfPowered
=
NULL
,
.
sofInt
=
NULL
};
...
...
sw/usbdcdc/armgcc/Makefile
View file @
98faf2d7
...
...
@@ -147,7 +147,7 @@ C_SRC += \
../../common/usb/src/em_usbdint.c
\
../../common/usb/src/em_usbtimer.c
\
../kits/common/drivers/dmactrl.c
\
../../common/usb/usbd
esc
.c
\
../../common/usb/usbd
bg
.c
\
../src/main.c
s_SRC
+=
...
...
sw/usbdcdc/src/main.c
View file @
98faf2d7
...
...
@@ -27,7 +27,7 @@
#include "bsp.h"
#include "bsp_trace.h"
#include "usbd
esc
.h"
#include "usbd
bg
.h"
/**************************************************************************//**
*
...
...
@@ -82,7 +82,7 @@ int main(void)
GPIO_PinModeSet
(
gpioPortE
,
11
,
gpioModePushPull
,
0
);;
GPIO_PinModeSet
(
gpioPortE
,
12
,
gpioModePushPull
,
1
);;
USBD_Init
(
&
initstruct
);
usbdbg_init
(
);
/*
* When using a debugger it is practical to uncomment the following three
...
...
@@ -98,7 +98,7 @@ int main(void)
{
GPIO_PinOutToggle
(
gpioPortE
,
11
);
GPIO_PinOutToggle
(
gpioPortE
,
12
);
USBD_Write
(
USBDESC_EP_DATA_OUT
,
(
void
*
)
tmp
,
strlen
(
tmp
),
NULL
);
usbdbg_puts
(
tmp
);
delay
(
1000
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment