He also has a similar project for the F411 that I will be looking at soon (I hope).
It uses just a simple Makefile to build, this guy is doing things the right way.
The compiler was complaining about an anonymous enum in main.c. I made some simple changes and the whole thing compiles by just typing make.
I use an ST-Link device connected to my Maple board, so I add an entry to the Makefile so that "make flash" now does the proper thing using openocd to download code.
No enumeration is/was happening. This is because of the disconnect circuit on the Maple. I add some more code to main.c to set up PC12 for this and now the board enumerates with vid 0483 and pid 5722. Linux does not have this in its list of known gadgets, so it assigns no driver. The trick is this command:
su echo 0483 5722 >/sys/bus/usb-serial/drivers/generic/new_idNow it shows up as /dev/ttyUSB1.
Nov 30 22:54:22 trona kernel: usbserial_generic 2-1.2:1.0: The "generic" usb-serial driver is only for testing and one-off prototypes. Nov 30 22:54:22 trona kernel: usbserial_generic 2-1.2:1.0: Tell [email protected] to add your device to a proper driver. Nov 30 22:54:22 trona kernel: usbserial_generic 2-1.2:1.0: generic converter detected Nov 30 22:54:22 trona kernel: usb 2-1.2: generic converter now attached to ttyUSB1
The serial console works and is chattering away. At 921600 baud of all things, sending this message about once a second, incrementing the count.
USB 6627: DEFAULT ... USB 1118: CONFIGUREDHere "DEFAULT" (or "CONFIGURED") is the usb status string.
When I connect to ttyUSB1 using picocom, I see:
bingo 388 bingo 389 ...
Best of all the LED on the maple board is blinking with my hack to set up A5 as the proper maple LED.
I can go to bed happy now, having accomplished something.
Indeed, once I gave the serial IO a queue and made it interrupt drive, the USB enumeration started working again!
0 Enum Reset 1 Enum Reset 2 Enum Rx S 8210 EA60 8 8006000100004000 3 Enum Tx 8000 62A0 18 120100020000004083042257000200000001 4 Enum Rx 8010 A220 0 5 Enum Reset 6 Enum Rx S 8210 EA60 8 0005670000000000 7 Enum Tx 8000 62A0 0 8 Enum Rx S 8210 EA60 8 8006000100001200 9 Enum Tx 8000 62A0 18 120100020000004083042257000200000001 10 Enum Rx 8010 A220 0 11 Enum Rx S 8010 EA60 8 8006000600000A00 12 Enum Rx S 8210 EA60 8 8006000600000A00 13 Enum Rx S 8010 EA60 8 8006000600000A00 14 Enum Rx S 8010 EA60 8 8006000200000900 15 Enum Tx 8000 62A0 9 090220000101008032 16 Enum Rx 8010 A220 0 17 Enum Rx S 8010 EA60 8 8006000200002000 18 Enum Tx 8200 62A0 32 09022000010100803209040000020A0000000705010240000007058102400000 19 Enum Rx 8010 A220 0 20 Enum Rx S 8010 EA60 8 0009010000000000 21 Enum Tx 8000 62A0 0What I find interesting is that no strings are sent. None are asked for either! This is because the device descriptor has 3 places for string indices, and they were all set to zero (for vendor, product, and serial). We might change this to test our skill and ability and understanding.
It needs to be enabled (in the RCC APB! enable register), right alongside of USB.
The NVIC needs to be told about the interrupt.
Then it gets set up for 1 Hz interrupts as follows:
TIM3.DIER |= TIM_DIER_UIE; TIM3.PSC = 7200 - 1; // 72MHz/7200 = 10KHz TIM3.ARR = 10000 - 1; // 10KHz/10000 = 1Hz TIM3.CR1 |= TIM_CR1_CEN;The DIER is the "DMA/Interrupt" enable register, and we set the UIE (update interrupt enable) bit.
The handler routine checks the UIF bit in the status register, perhaps to reject spurious interrupts, then clears this bit if it was set.
It is as simple as that, and you get 1 Hz interrupts.
Tom's Computer Info / [email protected]