If you should happen to be using my port of this library, I’m sorry to hear that, but I’ve not been able to ensure for it to run on the Photon (due to the lack of hardware ), but I’ll try to look at it as soon as i can.
@sazp96, the solution to the PIN_MAP issue is a little more complex due to the differences in the bitset and reset registers on the STM32F103 (core) and the STM32F205 (photon). Here is a set of macros I used to port the SparkIntervalTimer library:
#if defined(PLATFORM_ID)
#include "application.h"
#include "pinmap_impl.h"
STM32_Pin_Info* PIN_MAP = HAL_Pin_Map(); // Pointer required for highest access speed
#if (PLATFORM_ID == 0) // Core
#define pinLO(_pin) (PIN_MAP[_pin].gpio_peripheral->BRR = PIN_MAP[_pin].gpio_pin)
#define pinHI(_pin) (PIN_MAP[_pin].gpio_peripheral->BSRR = PIN_MAP[_pin].gpio_pin)
#elif (PLATFORM_ID == 6) // Photon
#define pinLO(_pin) (PIN_MAP[_pin].gpio_peripheral->BSRRH = PIN_MAP[_pin].gpio_pin)
#define pinHI(_pin) (PIN_MAP[_pin].gpio_peripheral->BSRRL = PIN_MAP[_pin].gpio_pin)
#else
#error "*** PLATFORM_ID not supported by this library. PLATFORM should be Core or Photon ***"
#endif
#endif
You will need to replace any PIN_MAP operation in the code with pinHI and pinLO if you want the code to be common for both the Core and the Photon.
Thanks @peekay123 for that hint.
I’m not sure, but it might well be that this could be unified back together into one set of macros, since I think the HIGH/LOW words of the BSRR register do exist on the 103 too - I’ll have a look to confirm or revoke
That’s a nice set of macros! One change I suggest is rather than using platform ID, instead use the various MCU defines - STM32F10X and STM32F2XX so that this is forward compatible with the electron.
Some times when I #include "pinmap_impl.h" using Particle Dev IDE (but compiling in the cloud), I get an error that it can’t find the library. Any toughs on why this is the case?
It is also not consistent, sometimes it says PIN_MAP error (this one should be fix with @peekay123’s macros) , and sometimes it says library not found.
Phew, as I see you don’t seem to use my port of the lib - good for you (and for me )
Have you retried it, a while later, maybe the build farm was down for a moment.
Or have you got blanks or other “funny” characters in your file names, that weren’t there before?
Hi @ScruffR. I just retried to compile and I get the same error. At least it is consistent
I also checked the file names, and they haven’t changed.
The good news is that after copying the code to Web IDE, I do get a bit more information about the error:
/spark/compile_service/shared/workspace/6_hal_12_0/firmware-privaADAFRUIT_HX8357.cpp:16:29: fatal error: Adafruit_HX8357.h: No such file or directoryindent preformatted text by 4 spaces
Have you got this library in your file tabs too, or are you using the Web IDE provided one?
If you are using the Web IDE one, you'd need to do it like this
#include "Adafruit_HX8356/Adafruit_HX8356.h"
Which would be provided in the main sketch, when you include the lib from the libraries section, but not into your other libraries and header files.
You have included Adafruit_mfGFX but your Adafruit_HX8357 demands the (assumingly) not provided Adafruit_GFX
And maybe you also need to adjust the casing of the file names - they are displayed capitalized, but the error message complains about a mixed case file beeing missing - case does play a role here.
Nice. You were right, the mismatch in the case was causing the error in Web IDE.
I changed the HX8357 libraries for them to use the mfGFX library instead of the GFX one.
Now I’m getting this error:
../../../build/target/user/platform-6/libuser.a(test_3.5_tft_photon.o):(.bss.PIN_MAP+0x0): multiple definition of `PIN_MAP'
../../../build/target/user/platform-6/libuser.a(ADAFRUIT_HX8357.o):/spark/compile_service/shared/workspace/6_hal_12_0/firmware-privaADAFRUIT_HX8357.cpp:506: first defined here
collect2: error: ld returned 1 exit status
make: *** [/spark/compile_service/shared/workspace/6_hal_12_0/firmware-privac7e0917f655a26685cab44569335592e23024427f0e2c129eaf8a5ba48c3.elf] Error 1
The weird part is that I’m defining PIN_MAP only once in HX8357.h.
The root cause of the issue is that I was declaring the PIN_MAP macros in HX8357.h instead of doing so in the HX8357.cpp file. Once I moved the macros the code compiled successfully.