STM32F103 LibUsb
Re: STM32F103 LibUsb
So i modified the line from bulk transfer to packet transfer and everything seems to work flawlessly. On to autobinding winusb to the stm32.
Re: STM32F103 LibUsb
I'm not sure what line you changed and what works now, but did you install the libUSBx driver for the device? Like described here?
Re: STM32F103 LibUsb
I Changed
to USB_EP_MODE_PACKET from USB_EP_MODE_TYPE_BULK
I am using Zadig for driver installation, as of right now but my ultimate goal is to autobind the driver so that i do not have to use zadig.
Code: Select all
/**
* @brief EP1 initialization structure (IN only).
*/
static const USBEndpointConfig ep1config = {
USB_EP_MODE_PACKET, //Type and mode of the endpointto USB_EP_MODE_PACKET from USB_EP_MODE_TYPE_BULK
I am using Zadig for driver installation, as of right now but my ultimate goal is to autobind the driver so that i do not have to use zadig.
Re: STM32F103 LibUsb
So just a bump on this thread. Having some troubles with the usb receive callback. Currently I have a C# program that is used for basic communication and I'm sending a packet to the stm32, for example I may send the packet 0x31 to the receiveBuf[0] position. Using a packet sniffer I can see that the packet is indeed being sent and is 0x31 (ascii character 1) and if I use the following code:
the default case is triggered instead of case '1'.
Been pounding my head on the keyboard for two days now. Any ideas why the receiveBuf is not matching case '1'?
Code: 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;
}the default case is triggered instead of case '1'.
Been pounding my head on the keyboard for two days now. Any ideas why the receiveBuf is not matching case '1'?
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: STM32F103 LibUsb
Not enough code to see, is the callback actually invoked or it is just the character that is not matched?
Re: STM32F103 LibUsb
I'll show the whole data received code.
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
}Re: STM32F103 LibUsb
The call back is being invoked. It appears that the character isn't being matched. When any data is sent is goes to the default and bypasses all other cases as if the character doesn't match. The default case does toggle.
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: STM32F103 LibUsb
Is that a "one" or a "letter L"? alternatively a stack corruption by overflow or a compiler bug.
Giovanni
Giovanni
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times