Hey folks, more generally I'd like to compile a master list of problems and fixes for porting from Core to Photon, with a strong preference for maintaining compatibility with both. There are two that I'm aware of,
PIN_MAP needing to be mapped to
HAL_Pin_Map() and the change in port names when making low-level calls.
Another one that's going to come up after the next firmware is a name collision on
PIN_MAP. The fix is pretty simple, just making
PIN_MAP2 on Photons. Below is my fixed code for OneWire, which illustrates both of these and the use of
PLATFORM_ID to define different behaviors on Core and Photon.
What other issues and fixes are there?
#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
STM32_Pin_Info* PIN_MAP2 = HAL_Pin_Map(); // Pointer required for highest access speed
#define pinLO(_pin) (PIN_MAP2[_pin].gpio_peripheral->BSRRH = PIN_MAP2[_pin].gpio_pin)
#define pinHI(_pin) (PIN_MAP2[_pin].gpio_peripheral->BSRRL = PIN_MAP2[_pin].gpio_pin)
#error "*** PLATFORM_ID not supported by this library. PLATFORM should be Core or Photon ***"
// fast pin access
#define pinSet(_pin, _hilo) (_hilo ? pinHI(_pin) : pinLO(_pin))
and this block of code, which occurs in a couple of places and versions:
#if PLATFORM_ID == 6