Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Easier to change LEDs #252

Merged
merged 1 commit into from
Feb 10, 2024
Merged

Easier to change LEDs #252

merged 1 commit into from
Feb 10, 2024

Conversation

dotsam
Copy link

@dotsam dotsam commented Aug 11, 2023

I've got a BluePill with slightly different pins in use for the internal LED and PA0, and in trying to change them, I wanted an easier way to do so in the defines.

Switched from setting the GPIO register directly to using gpio_write, which does add 104 bytes or so

@erichelgeson
Copy link
Owner

I cant find the original discussion but I believe we implemented directly setting the LEDs like that as we could do it in fewer cycles which (IIRC) did provide a noticeable speed bump. Is there any way you could run a side by side comparison of your change and the original way to ensure there's not a regression in speed?

@dotsam
Copy link
Author

dotsam commented Aug 11, 2023

I’m still waiting for some parts to build up my BlueSCSI, so I can’t do any benchmarking right now, but I’ll take another look and see if I can use some constants and bitshifting and bitwise operators to accomplish this like was being done before

@dotsam
Copy link
Author

dotsam commented Aug 11, 2023

Alright, tried again, this time using all macros and defines so that everything gets sorts out at compile time, and this should generate the same code as before. Not quite as nice to only have to set a single define to change the pin, but not horrendous either, and a little less opaque to anyone else trying to read or change this code

 - For building for boards with different LEDs and configurations
 - Define mode for LED
 - Update GPIO macros for port C
 - Use macros to generate bits for registers
@dotsam
Copy link
Author

dotsam commented Feb 10, 2024

Rebased this, swapped the pin initialization back to the same order, and then confirmed that this builds a byte-for-byte binary against main

35db1cd8e3f846ee80ab394cce9d4fd2  BlueSCSI-v1.1-20240209-STM32F1-USB-128MHz.bin
6ce93afa5bd32069d8f170d5b9c7974e  BlueSCSI-v1.1-20240209-STM32F1-USB-96MHz.bin
22e7f7308dd540a7e0c9b811f9ae2b0d  BlueSCSI-v1.1-20240209-STM32F1-USB.bin
41c58cc137ef4ce37b3e8b49456c8ed6  BlueSCSI-v1.1-20240209-STM32F1-XCVR.bin
00eed42ed15e163f9fc875f50b45a4d6  BlueSCSI-v1.1-20240209-STM32F1.bin
35db1cd8e3f846ee80ab394cce9d4fd2  easy-leds/BlueSCSI-v1.1-20240209-STM32F1-USB-128MHz.bin
6ce93afa5bd32069d8f170d5b9c7974e  easy-leds/BlueSCSI-v1.1-20240209-STM32F1-USB-96MHz.bin
22e7f7308dd540a7e0c9b811f9ae2b0d  easy-leds/BlueSCSI-v1.1-20240209-STM32F1-USB.bin
41c58cc137ef4ce37b3e8b49456c8ed6  easy-leds/BlueSCSI-v1.1-20240209-STM32F1-XCVR.bin
00eed42ed15e163f9fc875f50b45a4d6  easy-leds/BlueSCSI-v1.1-20240209-STM32F1.bin

@erichelgeson erichelgeson merged commit e236b5b into erichelgeson:main Feb 10, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants