cancel
Showing results for 
Search instead for 
Did you mean: 

USB lib error?

uz slm
Associate
Posted on November 01, 2017 at 15:08

i just want to build a HID device with STM32f103,and start with most new USB lib:

STM32_USB-FS-Device_Lib_V4.1.0;

after carefully reading the demo code of usb_pwr.c, i think one line in below funciton is not correct,as i marked below;

RESULT PowerOn(void)

{

uint16_t wRegVal;

&sharpif !defined (USE_NUCLEO)

/*** cable plugged-in ? ***/

USB_Cable_Config(ENABLE);

&sharpendif

/*** CNTR_PWDN = 0 ***/

wRegVal = CNTR_FRES;

_SetCNTR(wRegVal);

/* The following sequence is recommended:

1- FRES = 0

2- Wait until RESET flag = 1 (polling)

3- clear ISTR register */

/*** CNTR_FRES = 0 ***/

wInterrupt_Mask = 0;

_SetCNTR(wInterrupt_Mask);

/* Wait until RESET flag = 1 (polling) */

while((_GetISTR()&ISTR_RESET) == 1);//-->change to while((_GetISTR()&ISTR_RESET) == 0);  ??

/*** Clear pending interrupts ***/

SetISTR(0);

/*** Set interrupt mask ***/

wInterrupt_Mask = CNTR_RESETM | CNTR_SUSPM | CNTR_WKUPM;

_SetCNTR(wInterrupt_Mask);

return USB_SUCCESS;

}

in fact i am still not sure if i was right,since the lib must have pass the test;

Please kindly give your advice,if i need to correct it as i marked.

Thanks in advance!

#usb-fs-device_lib
0 REPLIES 0