libopencm3-examples icon indicating copy to clipboard operation
libopencm3-examples copied to clipboard

bad examples

Open karlp opened this issue 7 years ago • 6 comments

~~https://github.com/libopencm3/libopencm3-examples/blob/master/examples/stm32/f1/stm32-h103/exti_rising_falling/exti_rising_falling.c~~

~~does not mention the AFIO requirements if you happen to want to change to another port for the EXTI~~

That's wrong, exti_select_source() sets the SYSCFG or the AFIO registers depending on target. original reported bug was misidagnosed.

examples/stm32/f1/other/usb_hid/usbhid.c and lots of others copied there use HSI for USB on F1, which is really not supported, even though it sometimes works. Should replace them all with hse8_72, and usb div 1.5 to show the "right" way of doing it

karlp avatar Jan 16 '18 20:01 karlp

https://github.com/libopencm3/libopencm3-examples/blob/master/examples/stm32/f4/stm32f4-discovery/tick_blink/tick_blink.c#L42 uses an implementation that doesn't handle wrapping correctlky too

karlp avatar Aug 18 '19 20:08 karlp

adc.c: In function 'clock_setup':
adc.c:135:23: error: 'rcc_hsi_8mhz' undeclared (first use in this function); did you mean 'rcc_osc_off'?
  rcc_clock_setup_hsi(&rcc_hsi_8mhz[RCC_CLOCK_64MHZ]);
                       ^~~~~~~~~~~~
                       rcc_osc_off
adc.c:135:23: note: each undeclared identifier is reported only once for each function it appears in
adc.c:135:36: error: 'RCC_CLOCK_64MHZ' undeclared (first use in this function); did you mean 'RCC_CLOCK_HSI_64MHZ'?
  rcc_clock_setup_hsi(&rcc_hsi_8mhz[RCC_CLOCK_64MHZ]);
                                    ^~~~~~~~~~~~~~~
                                    RCC_CLOCK_HSI_64MHZ
../../../../rules.mk:201: recipe for target 'adc.o' failed
make[1]: *** [adc.o] Error 1
Makefile:71: recipe for target 'examples/stm32/f3/stm32f3-discovery/adc/' failed
make: *** [examples/stm32/f3/stm32f3-discovery/adc/] Error 2

Fails to build

ChuckM avatar Aug 19 '19 03:08 ChuckM

Works with current code as is in repo? had you updated the library ahead or something? (Also, that's just straight up breakage. this ticket is more for examples that might work, but aren't good examples to copy)

karlp avatar Aug 19 '19 11:08 karlp

I also pulled the library to latest and it still builds fine, are you sure you're looking at latest code?

karlp avatar Aug 19 '19 11:08 karlp

Ok, I remoted the libopencm3 library to upstream, fetched it and pulled master on the sub module to latest. That got rid of that build error but still has a warning about flash_erase_page() on usbdfu_getstatus_complete about fallthrough of the case statement.

And I submitted a PR with a fix for the msleep issue in tick_blink

ChuckM avatar Aug 19 '19 15:08 ChuckM

yeah, the fallthrough warnings are a different matter. In one case we even had a comment saying, "fall through" but it was't the style that gcc recognized :)

karlp avatar Aug 20 '19 10:08 karlp