technobly / Particle-DotStar

An Implementation of Adafruit's DotStar Library for the Spark Core
GNU General Public License v3.0
8 stars 14 forks source link

'struct GPIO_TypeDef' has no member named 'BSRR' #3

Closed nick-jonas closed 8 years ago

nick-jonas commented 9 years ago

Veryfing code using this library in Particle Build fails with this error:

dotstar/dotstar.cpp:39:53: error: 'struct GPIO_TypeDef' has no member named 'BSRR'
 #define pinHI(_pin) (PIN_MAP[_pin].gpio_peripheral->BSRR = PIN_MAP[_pin].gpio_pin)
                                                     ^
nick-jonas commented 9 years ago

@technobly any advice here would be greatly appreciated!

nick-jonas commented 9 years ago

I fixed it implementing this guy's fix:

https://community.particle.io/t/photon-and-sd-card-library-error/14707/3?u=njonas

You can see it in my fork here:

https://github.com/nick-jonas/SparkCore-DotStar/blob/master/firmware/dotstar.cpp#L39-L43

nick-jonas commented 9 years ago

Well now I'm getting this error actually:

dotstar/dotstar.cpp:43:42: error: 'pinSetFast' was not declared in this scope
 #define pinHI(_pin) (void)pinSetFast(_pin)

and

dotstar/dotstar.cpp:40:44: error: 'pinResetFast' was not declared in this scope
 #define pinLO(_pin) (void)pinResetFast(_pin)
                                            ^
peter247 commented 8 years ago

Any clues , if this library will ever work for the photon ?

willdages commented 8 years ago

I'm having the same problem. I have both a Core and a Photon; using the default example project through build.particle.io, the project will compile if I'm flashing my Core, but fails with the same error when it compiles for the Photon.

Additional error, that's probably related:

dotstar/dotstar.cpp:38:53: error: 'struct GPIO_TypeDef' has no member named 'BRR'
 #define pinLO(_pin) (PIN_MAP[_pin].gpio_peripheral->BRR = PIN_MAP[_pin].gpio_pin)
                                                     ^
peter247 commented 8 years ago

Hi , after a lot of playing around I found a solution, in dotstar.ccp comment out all the lines related to software spi and use hardware only . I also found that any function like rainbow used in the neopixel program work on dotstar too.

willdages commented 8 years ago

@peter247 Hey Peter, I saw that in the forums, but that didn't work for me either. I got it to compile by doing that, but couldn't get any of the color methods to work right, the whole strip just lit up white, or went wacky random rainbow. Were you able to set colors on specific LEDs?

peter247 commented 8 years ago

@willdages , Did you use a logic converter , to get the 3.3 volt logic up to 5 volt which the strip needs ? and the right constructor for hardware spi . I don't know it just worked for me after the tweaking to the dotstar.cpp libarary.

willdages commented 8 years ago

@peter247 I'm not using a logic converter (I'm not sure what that even is so perhaps I'm in a bit over my head, but I'll read up on it). Thanks!

I found this in the forums, which I think applies to the issue reported here in regards to compilation on the Photon: https://community.particle.io/t/photon-and-the-pin-map-challenge/12223

I'll have to do a little testing, but if it works, I'll submit a PR.

peter247 commented 8 years ago

Read this . https://learn.adafruit.com/adafruit-dotstar-leds

this bit.

DotStars are 5V devices. While you might get them to respond to 3.3V signals, this is not a guaranteed thing and should not be counted on. For low-voltage microcontrollers and systems such as Raspberry Pi, a logic level shifter (e.g. 74AHCT125) is recommended for both the data and clock pins.

technobly commented 8 years ago

Hey guys, I will be working on updating this library this weekend. Expect it to be fixed by Monday :)

peter247 commented 8 years ago

Or , if not , make a define to remove the software spi lines .

@willdages this is the logic converter I use . https://www.coolcomponents.co.uk/logic-level-converter.html

willdages commented 8 years ago

@technobly Thanks!

@peter247 Thanks for pointing me towards the logic converter. I happened to have a 74AHCT125 (I must have seen that footnote when I bought the leds months ago, and then just forgot about it). That got things working perfectly!

@technobly I ended up making a change very similar to @wesner0019's PR: https://github.com/technobly/SparkCore-DotStar/pull/2, and verified that it's working with both Hardware and Software SPI, on both the Core and Photon. Hopefully that will save you some time!

technobly commented 8 years ago

v0.0.3 is published to Particle Libraries, tested and working on Core and Photon. Compiles for P1 and Electron (sorry no time to test those right now but they should work fine). https://build.particle.io/libs/56247fe4eef6db92ae000c69/tab/1-strandtest.cpp