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
a3dd4e81
Commit
a3dd4e81
authored
Aug 08, 2014
by
Theodor-Adrian Stana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
usbled compiles, but segfaults
parent
53985415
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
47 deletions
+62
-47
descriptors.h
sw/usbdcdc/src/descriptors.h
+2
-2
main.c
sw/usbdcdc/src/main.c
+47
-40
Makefile
sw/usbled/Makefile
+6
-2
usbled.c
sw/usbled/usbled.c
+7
-3
No files found.
sw/usbdcdc/src/descriptors.h
View file @
a3dd4e81
...
...
@@ -28,7 +28,7 @@ static const USB_DeviceDescriptor_TypeDef deviceDesc __attribute__ ((aligned(4))
.
bDeviceProtocol
=
0
,
.
bMaxPacketSize0
=
USB_EP0_SIZE
,
.
idVendor
=
0x10C4
,
.
idProduct
=
0x00
03
,
.
idProduct
=
0x00
ff
,
.
bcdDevice
=
0x0000
,
.
iManufacturer
=
1
,
.
iProduct
=
2
,
...
...
@@ -168,7 +168,7 @@ static const uint8_t bufferingMultiplier[ NUM_EP_USED + 1 ] = { 1, 1, 2, 2 };
static
const
USBD_Callbacks_TypeDef
callbacks
=
{
.
usbReset
=
NULL
,
.
usbStateChange
=
StateChange
,
.
usbStateChange
=
NULL
,
//
StateChange,
.
setupCmd
=
SetupCmd
,
.
isSelfPowered
=
NULL
,
.
sofInt
=
NULL
...
...
sw/usbdcdc/src/main.c
View file @
a3dd4e81
...
...
@@ -53,6 +53,9 @@
/* baudrate. Minimum timeout is set to 10 ms. */
#define RX_TIMEOUT EFM32_MAX(10U, 50000 / (cdcLineCoding.dwDTERate))
#define LED_SET 0x11
/* The serial port LINE CODING data structure, used to carry information */
/* about serial port baudrate, parity etc. between host and device. */
EFM32_PACK_START
(
1
)
...
...
@@ -156,8 +159,8 @@ int main(void)
GPIO_PinModeSet
(
gpioPortE
,
11
,
gpioModePushPull
,
0
);;
GPIO_PinModeSet
(
gpioPortE
,
12
,
gpioModePushPull
,
1
);;
SerialPortInit
();
DmaSetup
();
//
SerialPortInit();
//
DmaSetup();
USBD_Init
(
&
initstruct
);
/*
...
...
@@ -170,9 +173,9 @@ int main(void)
for
(;;)
{
GPIO_PinOutToggle
(
gpioPortE
,
11
);
GPIO_PinOutToggle
(
gpioPortE
,
12
);
delay
(
1000
);
//
GPIO_PinOutToggle(gpioPortE, 11);
//
GPIO_PinOutToggle(gpioPortE, 12);
//
delay(1000);
}
}
...
...
@@ -492,41 +495,45 @@ static int SetupCmd(const USB_Setup_TypeDef *setup)
{
switch
(
setup
->
bRequest
)
{
case
USB_CDC_GETLINECODING
:
/********************/
if
((
setup
->
wValue
==
0
)
&&
(
setup
->
wIndex
==
0
)
&&
/* Interface no. */
(
setup
->
wLength
==
7
)
&&
/* Length of cdcLineCoding */
(
setup
->
Direction
==
USB_SETUP_DIR_IN
))
{
/* Send current settings to USB host. */
USBD_Write
(
0
,
(
void
*
)
&
cdcLineCoding
,
7
,
NULL
);
retVal
=
USB_STATUS_OK
;
}
break
;
case
USB_CDC_SETLINECODING
:
/********************/
if
((
setup
->
wValue
==
0
)
&&
(
setup
->
wIndex
==
0
)
&&
/* Interface no. */
(
setup
->
wLength
==
7
)
&&
/* Length of cdcLineCoding */
(
setup
->
Direction
!=
USB_SETUP_DIR_IN
))
{
/* Get new settings from USB host. */
USBD_Read
(
0
,
(
void
*
)
&
cdcLineCoding
,
7
,
LineCodingReceived
);
retVal
=
USB_STATUS_OK
;
}
break
;
case
USB_CDC_SETCTRLLINESTATE
:
/********************/
if
((
setup
->
wIndex
==
0
)
&&
/* Interface no. */
(
setup
->
wLength
==
0
))
/* No data */
{
/* Do nothing ( Non compliant behaviour !! ) */
retVal
=
USB_STATUS_OK
;
}
break
;
case
LED_SET
:
setup
->
wValue
?
GPIO_PinOutSet
(
gpioPortE
,
setup
->
wIndex
)
:
GPIO_PinOutClear
(
gpioPortE
,
setup
->
wIndex
);
break
;
// case USB_CDC_GETLINECODING:
// /********************/
// if ((setup->wValue == 0) &&
// (setup->wIndex == 0) && /* Interface no. */
// (setup->wLength == 7) && /* Length of cdcLineCoding */
// (setup->Direction == USB_SETUP_DIR_IN))
// {
// /* Send current settings to USB host. */
// USBD_Write(0, (void*) &cdcLineCoding, 7, NULL);
// retVal = USB_STATUS_OK;
// }
// break;
//
// case USB_CDC_SETLINECODING:
// /********************/
// if ((setup->wValue == 0) &&
// (setup->wIndex == 0) && /* Interface no. */
// (setup->wLength == 7) && /* Length of cdcLineCoding */
// (setup->Direction != USB_SETUP_DIR_IN))
// {
// /* Get new settings from USB host. */
// USBD_Read(0, (void*) &cdcLineCoding, 7, LineCodingReceived);
// retVal = USB_STATUS_OK;
// }
// break;
//
// case USB_CDC_SETCTRLLINESTATE:
// /********************/
// if ((setup->wIndex == 0) && /* Interface no. */
// (setup->wLength == 0)) /* No data */
// {
// /* Do nothing ( Non compliant behaviour !! ) */
// retVal = USB_STATUS_OK;
// }
// break;
}
}
...
...
sw/usbled/Makefile
View file @
a3dd4e81
CC
=
gcc
CFLAGS
=
-Wall
INCLUDE
=
SOURCES
=
usbled.c
LIB
=
-L
/usr/lib/i386-linux-gnu
LIB
=
LDFLAGS
=
-lusb
all
:
$(CC)
$(INCLUDE)
$(LIB)
$(LDFLAGS)
-o
usbled
$(SOURCES)
$(CC)
-o
usbled
$(CFLAGS)
$(INCLUDE)
$(SOURCES)
$(LIB)
$(LDFLAGS)
clean
:
rm
usbled
sw/usbled/usbled.c
View file @
a3dd4e81
...
...
@@ -9,7 +9,8 @@ int main()
static
struct
usb_device
*
pDev
;
static
struct
usb_bus
*
pBus
;
int
led
=
0
;
int
led
=
12
;
int
val
=
0
;
usb_init
();
...
...
@@ -51,16 +52,19 @@ int main()
while
(
1
)
{
led
^=
1
;
if
(
led
==
11
)
led
=
12
;
if
(
led
==
12
)
led
=
11
;
val
^=
1
;
if
(
pDevH
)
{
printf
(
"led%d
\n
"
,
led
);
usb_control_msg
(
pDevH
,
// Device handle
USB_ENDPOINT_IN
|
USB_TYPE_VENDOR
|
USB_RECIP_DEVICE
,
// bmRequestType
LED_SET
,
// bRequest
0
,
// wValue
val
,
// wValue
led
,
// wIndex
NULL
,
// char *pBuffer
1
,
// wLength
...
...
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