Code works on cli but not web IDE

My code will compile on the particle-cli but not on the web IDE. The error is that a function was not declared in this scope. The function is “defined” at the top of the file with the macros created to deal with the PIN_MAP issue. Any idea why it wouldn’t work in the web IDE? Here’s the code that seems to be affecting this:

#if defined(PLATFORM_ID)  //Only defined if a Particle device
  #include "application.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

/********************************** low level pin interface */

inline void Adafruit_SSD1351::spiwrite(uint8_t c) {
    //Serial.println(c, HEX);
if (!_sid) {
    SPI.transfer(c);
	// might be able to make this even faster but
	// a delay -is- required
	//delayMicroseconds(1);
    return;
}

//Software SPI, MSB first
for (uint8_t bit = 0; bit < 8; bit++)  {
pinLO(_sclk); // PIN_MAP[_sclk].gpio_peripheral->BRR = PIN_MAP[_sclk].gpio_pin; // Clock Low

	if (c & (1 << (7-bit)))		// walk down mask from bit 7 to bit 0
  pinHI(_sid); // PIN_MAP[_sid].gpio_peripheral->BSRR = PIN_MAP[_sid].gpio_pin; // Data High
	else
  pinLO(_sid); // PIN_MAP[_sid].gpio_peripheral->BRR = PIN_MAP[_sid].gpio_pin; // Data Low

pinHI(_sclk); // PIN_MAP[_sclk].gpio_peripheral->BSRR = PIN_MAP[_sclk].gpio_pin; // Clock High
}

}

The errors are that pinLO and pinHI are not declared in this scope. But it works fine in the cli. Any ideas??

Hey @osmithy are you sure you defined your variables correctly at the top? I know you’re trying to re-use the example related to the PIN_MAP issue, but let’s make sure the the variables are correctly defined.

I’m also saying this to be taken with a “grain of salt” since I cannot see the entire program nor can I see the header in its completeness.

I’ll look further into this issue! :smile:

Be Back Soon Enough,
Corey

Hi Corey! If you can access my un-published library, it’s at https://build.particle.io/libs/559d853ada4c3c23a70007ca and the example is test.ino.

Are you building against a Core or Photon?
If you’re building against a Core, try this

#if defined(SPARK)
  #include "application.h"

  #if defined(PLATFORM_ID)  // Only defined for Particle device with HAL FW
    STM32_Pin_Info* PIN_MAP = HAL_Pin_Map(); // ptr required
  #endif

  #if !defined(PLATFORM_ID) || (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

I’m not sure that PLATFORM_ID is already defined for Core FW v0.3.4