Adafruit_SSD1351.cpp: In member function 'void Adafruit_SSD1351::spiwrite(uint8_t)':
Adafruit_SSD1351.cpp:38:35: error: 'struct GPIO_TypeDef' has no member named 'BRR'
PIN_MAP[_sclk].gpio_peripheral->BRR = PIN_MAP[_sclk].gpio_pin; // Clock Low
^
Adafruit_SSD1351.cpp:41:35: error: 'struct GPIO_TypeDef' has no member named 'BSRR'
PIN_MAP[_sid].gpio_peripheral->BSRR = PIN_MAP[_sid].gpio_pin; // Data High
^
Adafruit_SSD1351.cpp:43:35: error: 'struct GPIO_TypeDef' has no member named 'BRR'
PIN_MAP[_sid].gpio_peripheral->BRR = PIN_MAP[_sid].gpio_pin; // Data Low
^
Adafruit_SSD1351.cpp:45:35: error: 'struct GPIO_TypeDef' has no member named 'BSRR'
PIN_MAP[_sclk].gpio_peripheral->BSRR = PIN_MAP[_sclk].gpio_pin; // Clock High
This is related to the PIN_MAP discussion. However, I could not find anything conclusive there. Copied the macros provided by @peekay123 at the start of the thread but did not compile.
Question 2: When I use the Particle Dev to compile, it automatically compiles it as a core - successfully. Where can I specify if I want code compiled for core or photon in the Particle Dev?
If you use the target to select one of your Photons and then compile it will create a Photon binary. How to default to a Photon without having to select one? Great question.
Since we are having the HAL feature released already for Core and Photon libraries can easily be ported for both platforms, but it’ll take some time till the contributors get round to updating existing libs.
But since you got the source code accessible for alterations you can get it working by just replacing some things.
PIN_MAP[_pin].gpio_peripheral->BRR = PIN_MAP[_pin].gpio_pin;
// becomes
pinResetFast(_pin); // can also replace digitalWrite(_pin, LOW)
// and
PIN_MAP[_pin].gpio_peripheral->BSRR = PIN_MAP[_pin].gpio_pin;
// becomes
pinSetFast(_pin); // can also replace digitalWrite(_pin, HIGH)
// and
digitalWriteFast(_pin, _value); // can replace any digitalWrite(_pin, _value)
@pteja, I have it in my task list to update all my github libraries. @BulldogLowell’s recommendations are spot on. I tend to leave non-time-critical digitalWrite() code as-is since those calls include a bunch of “safety” checks. However, for time-critical code, using digitalWriteFast() and digitalReadFast() are huge assets.
@pteja, I updated the library to support the new firmware fast GPIO commands and to support the older Core 0.3.4 firmware. If you get a chance to test, I would greatly appreciate it.
There is an SD library on the IDE though I’m not sure if it up to date. Otherwise, I have an SD library you could use. Which display unit are you using?
Yes, since firmware version 0.4.5 there are dedicated high speed functions that wrap the hardware specifics away that may cause incompatibilities like the one you’ve seen.
But if you want to understand how the original line worked:
PIN_MAP[] is an array that holds some info about each of the GPIO pins. PIN_MAP[misoPin_].gpio_peripheral points to the memory address of the hardware port to which misoPin_ belongs.
At this address are several hardware registers like the IDR (input data register) which represents all 16 GPIO states of the pins of this port.
By binary “ANDing” this 16bit word with a word that only has the one bit set which identifies misoPin_ you’ll get a result ==0 (considered FALSE or LOW) or !=0 (considered TRUE or HIGH).