Hi guys,
Really having fun with the Spark platform. I built a smart power strip a few months ago and it works just fine.
Working on new project in which I’d like to be able to change many output pins at once. I know the ARM chip can do this, but is there any support for it planned for the firmware? I’m thinking of potential calls that are like digitalRead() and digitalWrite() but which take a port identifier and return bytes or whatever the port width is. In the Arduino world, everyone just drops down to the setting the AVR PORTx registers. I think wrapper fns would be nicer.
Regards,
Dave J
1 Like
@peekay123 has given it a shot but… it’s super crazy with the pins mapped all over the STM32
@djacobow, @kennethlimcp, the mapping of “user” pins to STM32 GPIO pins is the limiting factor. For example, digital pins D0-D4 map onto port GPIOB, whereas pins D5-D7 map to port GPIOA! So you can’t read or write to a “whole” 8-bit port like on the Arduino.
However, there are several STM32 registers that can be used to read and write to GPIO ports or just single bits. In the case of the Spark, in order to simulate a “whole” port operation to D0-D7, the data byte would have to be split into 5bit and 3bit values and written to ports GPIOB and GPIOA. I am having this exact challenge in optimizing the RGB-matrix-led library.
I super speed is not a problem, I could write a couple of functions to do the “whole” port simulation but it will never be as fast (oddly enough!) as the Arduino direct port write. Any thoughts?
Actually, 5b and 3b would work well for me. I have an interface with 5 data lines and 3 control lines, and I intend to toggle them alternately.
I don’t think there is much sense in trying to simulate contiguous ports, but getting access to whatever contiguousness is there be nice.