I posted some time ago about reusing a Maple board's JTAG pins as GPIOs. This is proving to be very frustrating. I can't get the Maple IDE to let me use any of the utilities defined in libmaple.
I want to do this:
afio_remap(AFIO_MAPR_SWJ_CFG_NO_JTAG_NO_SW);
afio_remap() is defined in libmaple/stm32f1/include/series/gpio.h. Trying to include that directory leads to the following stupid guessing game:
fatal error: libmaple/stm32f1/include/series/gpio.h: No such file or directorycompilation terminated.
fatal error: stm32f1/include/series/gpio.h: No such file or directorycompilation terminated.
fatal error: include/series/gpio.h: No such file or directorycompilation terminated.
fatal error: series/gpio.h: No such file or directorycompilation terminated.
Not really clear how to find the gpio.h which defines afio_remap. Unfortunately for me, there is a second gpio.h which *is* on the include path, and when I #include "gpio.h" I get several dozen repetitions of this error:
/Applications/MapleIDE.app/Contents/Resources/Java/hardware/leaflabs/cores/maple/gpio.h:82: error: 'uint32' does not name a type
For some reason gpio.h does not include all the headers it needs, so I have to #include <util.h> and <libmaple_types.h> in order to make it compile; but that still doesn't solve my problem, because neither AFIO_MAPR_SWJ_CFG_NO_JTAG_NO_SW nor afio_remap() are defined in this version of gpio.h.
Time for some brutal kludgery. I copy all the definitions I need out of the correct version of gpio.h and paste them into my maple sketch, hoping that the linker will sort it out. No such luck:
undefined reference to `afio_remap(afio_remap_peripheral)'collect2: ld returned 1 exit status
This is really frustrating. How is this *supposed* to work? Is there documentation *anywhere* of the include path?
I'd just ditch the whole Maple IDE thing and try to build my project on the command line, but I have never had any luck getting dfu-util to work, and on this project I can't just use the serial bootloader.
-----
Right. I was running an old version of the Maple IDE (0.0.9). Upgrading to 0.0.12 solved the problem, afio_remap did its job, and I have control over the JTAG pins within the Maple IDE system. All good. On to the next thing.