Finally got USB enumeration working on this stm32 cortex-m3 board. Spend the night working through a host of errors and bugs and reading and re-reading the manual and parts of Jan Axelsons USB complete book.
The invariant settings code in
stm32_usb_enable_endp
stm32_usb_clean_epr_ctr
stm32_usb_set_epr_dtog
stm32_usb_set_epr_stat
was flawed. I had left out the check against toggling RX and TX status. Later I had to examine the stm32_usb_post_reset_setup() code fearing I had omitted some detail. I did but there were not show stoppers. It was really the little things like
1. CLEARING RX and TX SPURIOUS interrupts on USB RESET in the stm32_usb_post_reset_setup() code. This was preventing me from getting further IN and OUT interrupts.
2. setting the data toggle to 1 for TX before calling stm32_usb_send_packet or stm32_usb_queue_IN_transfers. And later realizing that the hardware will auto toggle it afterwards and I neednt do anything more than set it to 1 for the initial transfer or start of transfer
3. cancelling queue IN transfers whenever a new OUT/SETUP command comes through.
4. omitting the check for SETUP and just relying on CTR_RX for incoming control commands
5. fixing a bug in stm32_usb_dequeue_IN_transfers that was preventing me from transfer more than just the first data block
I will be using libusb to write the data communication software to talk to this device. I have yet to decide what sort of data I am going to pipe out. Maybe simulate a joystick or take the genesis controller and run it through ... after decoding. Or better yet design something in fpga and interface to this stm32 or the new one I purchased ...
No comments:
Post a Comment