Re: STM32F103 LibUsb
Posted: Mon Aug 20, 2012 11:12 pm
So i modified the line from bulk transfer to packet transfer and everything seems to work flawlessly. On to autobinding winusb to the stm32.
Code: Select all
/**
* @brief EP1 initialization structure (IN only).
*/
static const USBEndpointConfig ep1config = {
USB_EP_MODE_PACKET, //Type and mode of the endpointCode: Select all
void dataReceived(USBDriver *usbp, usbep_t ep){
(void) usbp;
(void) ep;
switch(receiveBuf[0]){
case 'V':
palTogglePad(GPIOD, 4);
break;
case '1':
palTogglePad(GPIOD, 4);
break;
case '3':
palTogglePad(GPIOD, 4);
break;
case '4':
palTogglePad(GPIOD, 4);
break;
default:
palTogglePad(GPIOD, 5);
break;
}Code: Select all
/* IN EP1 state */
static USBInEndpointState ep1instate;
/* EP1 initialization structure (IN only) */
static const USBEndpointConfig ep1config = {
USB_EP_MODE_TYPE_BULK | USB_EP_MODE_PACKET, //Type and mode of the endpoint
NULL, //Setup packet notification callback (NULL for non-control EPs)
dataTransmitted, //IN endpoint notification callback
NULL, //OUT endpoint notification callback
IN_PACKETSIZE, //IN endpoint maximum packet size
0x0000, //OUT endpoint maximum packet size
&ep1instate, //USBEndpointState associated to the IN endpoint
NULL //USBEndpointState associated to the OUTendpoint
};
/*
* Data Received Callback
* it writes the received Data to the output buffer
* to have an echo effect
*/
void dataReceived(USBDriver *usbp, usbep_t ep){
(void) usbp;
(void) ep;
switch(receiveBuf[0]){
case 'V':
palTogglePad(GPIOD, 4);
break;
case '1':
palTogglePad(GPIOD, 4);
break;
case '3':
palTogglePad(GPIOD, 4);
break;
case '4':
palTogglePad(GPIOD, 4);
break;
default:
palTogglePad(GPIOD, 5);
break;
}
/* Initiate next receive */
usbPrepareReceive(usbp, EP_OUT, receiveBuf, 64);
chSysLockFromIsr();
usbStartReceiveI(usbp, EP_OUT);
chSysUnlockFromIsr();
}
/* OUT EP2 state */
USBOutEndpointState ep2outstate;
/*
* @brief EP2 initialization structure (OUT only).
*/
static const USBEndpointConfig ep2config = {
USB_EP_MODE_TYPE_BULK | USB_EP_MODE_PACKET,
NULL,
NULL,
dataReceived,
0x0000,
OUT_PACKETSIZE,
NULL,
&ep2outstate
}