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

AVR GPIO macro defines more readable #5937

Merged
merged 9 commits into from
Aug 22, 2019

Conversation

mtei
Copy link
Contributor

@mtei mtei commented May 20, 2019

Description

  • A little easier to read the definition of the GPIO control macro for AVR.
    quantum/quantum.h, quantum/config_common.h
  • Modified split_common/serial.c to use qmk_firmware standard GPIO control macro.
    quantum/split_common/serial.c

There is no change in compilation results for this PR.

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout/userspace (addition or update)
  • Documentation

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

quantum/quantum.h Outdated Show resolved Hide resolved
@drashna
Copy link
Member

drashna commented May 20, 2019

This looks good to me.

@pelrun ?

quantum/quantum.h Outdated Show resolved Hide resolved
quantum/quantum.h Outdated Show resolved Hide resolved
quantum/split_common/serial.c Outdated Show resolved Hide resolved
Copy link
Contributor

@pelrun pelrun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The duplicated definitions in serial.c bug me a little bit, but not enough to change.

@mtei
Copy link
Contributor Author

mtei commented May 21, 2019

I deliberately avoided serial.c to depend on quantum.h. serial.c is a very timing-dependent module, so we want to avoid other impacts as much as possible.

@drashna
Copy link
Member

drashna commented May 21, 2019

In that case, would it make sense to move both out of the respective files, and into a separate header file, where both quantum.h and serial.c could include them?

That way, we're not maintaining multiple copies of the GPIO commands, and don't have to worry about keeping them in sync (for behavioral reasons)?

@mtei
Copy link
Contributor Author

mtei commented May 22, 2019

In that case, would it make sense to move both out of the respective files, and into a separate header file, where both quantum.h and serial.c could include them?

I already thought about that method, but I did not adopt it. If serial.c imports gpio_control.h, you need to be careful modifying gpio_control.h as you would for serial.c. It's not desirable.

That way, we're not maintaining multiple copies of the GPIO commands, and don't have to worry about keeping them in sync (for behavioral reasons)?

Do you need to sync? I do not think that it is necessary. It is dangerous to change the working serial.c just to synchronize.

@fauxpark
Copy link
Member

fauxpark commented May 22, 2019

If serial.c imports gpio_control.h, you need to be careful modifying gpio_control.h as you would for serial.c.

Not sure I understand. Of course you need to be careful modifying these GPIO macros, however they are fairly simple so I would be surprised if there were any major problems with them that haven't been discovered yet. If something does need to be changed, they must both be changed anyway, because otherwise you have two conflicting #defines which will probably make GCC complain.

The thing is that serial.c shouldn't need to know nor define how eg. setPinOutput() works at this level. All of that should be abstracted away, that's the whole point of these macros in the first place.

@mtei
Copy link
Contributor Author

mtei commented May 22, 2019

In general I like to be abstract. However, the abstraction is not necessary only for serial.c. What is important is that the generated binaries do not change.

We have already experienced that when the GCC version changes the generation code will change and the timing changes. (#4269) We can't trust the simplicity of the source code's appearance.

@drashna
Copy link
Member

drashna commented Jul 30, 2019

It looks like there is a merge conflict here, now.

@mtei
Copy link
Contributor Author

mtei commented Jul 30, 2019

Thanks, I fixed.

Then I checked again that there was no change in the binary generated by this PR.

$ git checkout avr_gpio_macro_more_readable
Switched to branch 'avr_gpio_macro_more_readable'
$ make SKIP_DEBUG_INFO=y SKIP_VERSION=y lets_split:default:clean
$ make SKIP_DEBUG_INFO=y SKIP_VERSION=y lets_split:default
....
 * The firmware size is fine - 19450/28672 (67%, 9222 bytes free)
$ mv lets_split_rev2_default.hex new-lets_split_rev2_default.hex

$ git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
$ make SKIP_DEBUG_INFO=y SKIP_VERSION=y lets_split:default:clean
$ make SKIP_DEBUG_INFO=y SKIP_VERSION=y lets_split:default
....
 * The firmware size is fine - 19450/28672 (67%, 9222 bytes free)

$ md5 *lets_split_rev2_default.hex
MD5 (lets_split_rev2_default.hex) = 4999375ced50a8e7f731bc06bdeb534f
MD5 (new-lets_split_rev2_default.hex) = 4999375ced50a8e7f731bc06bdeb534f

Copy link
Member

@drashna drashna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@drashna drashna merged commit 1c5b0cb into qmk:master Aug 22, 2019
drashna pushed a commit to zsa/qmk_firmware that referenced this pull request Aug 27, 2019
* A little easier to read the definition of the GPIO control macro for AVR.

No change in build result.

* Changed to not use GNU statement expression extension.

No change in build result.

* Modified split_common/serial.c to use qmk_firmware standard GPIO control macro.

No change in build result.

* fix PE6 -> E6

* remove some space

* add some comment to config_common.h

* Changed split_common/serial.c to use a newer version of qmk_firmware standard GPIO control macro.
fdidron pushed a commit to zsa/qmk_firmware that referenced this pull request Aug 28, 2019
* A little easier to read the definition of the GPIO control macro for AVR.

No change in build result.

* Changed to not use GNU statement expression extension.

No change in build result.

* Modified split_common/serial.c to use qmk_firmware standard GPIO control macro.

No change in build result.

* fix PE6 -> E6

* remove some space

* add some comment to config_common.h

* Changed split_common/serial.c to use a newer version of qmk_firmware standard GPIO control macro.
doughsay pushed a commit to doughsay/qmk_firmware that referenced this pull request Aug 31, 2019
* A little easier to read the definition of the GPIO control macro for AVR.

No change in build result.

* Changed to not use GNU statement expression extension.

No change in build result.

* Modified split_common/serial.c to use qmk_firmware standard GPIO control macro.

No change in build result.

* fix PE6 -> E6

* remove some space

* add some comment to config_common.h

* Changed split_common/serial.c to use a newer version of qmk_firmware standard GPIO control macro.
swanmatch pushed a commit to swanmatch/qmk_firmware that referenced this pull request Sep 3, 2019
* A little easier to read the definition of the GPIO control macro for AVR.

No change in build result.

* Changed to not use GNU statement expression extension.

No change in build result.

* Modified split_common/serial.c to use qmk_firmware standard GPIO control macro.

No change in build result.

* fix PE6 -> E6

* remove some space

* add some comment to config_common.h

* Changed split_common/serial.c to use a newer version of qmk_firmware standard GPIO control macro.
fdidron pushed a commit to zsa/qmk_firmware that referenced this pull request Sep 5, 2019
* A little easier to read the definition of the GPIO control macro for AVR.

No change in build result.

* Changed to not use GNU statement expression extension.

No change in build result.

* Modified split_common/serial.c to use qmk_firmware standard GPIO control macro.

No change in build result.

* fix PE6 -> E6

* remove some space

* add some comment to config_common.h

* Changed split_common/serial.c to use a newer version of qmk_firmware standard GPIO control macro.
@mtei mtei deleted the avr_gpio_macro_more_readable branch October 16, 2019 19:42
ripxorip pushed a commit to ripxorip/qmk_firmware that referenced this pull request Dec 3, 2019
* A little easier to read the definition of the GPIO control macro for AVR.

No change in build result.

* Changed to not use GNU statement expression extension.

No change in build result.

* Modified split_common/serial.c to use qmk_firmware standard GPIO control macro.

No change in build result.

* fix PE6 -> E6

* remove some space

* add some comment to config_common.h

* Changed split_common/serial.c to use a newer version of qmk_firmware standard GPIO control macro.
ridingqwerty pushed a commit to ridingqwerty/qmk_firmware that referenced this pull request Jan 10, 2020
* A little easier to read the definition of the GPIO control macro for AVR.

No change in build result.

* Changed to not use GNU statement expression extension.

No change in build result.

* Modified split_common/serial.c to use qmk_firmware standard GPIO control macro.

No change in build result.

* fix PE6 -> E6

* remove some space

* add some comment to config_common.h

* Changed split_common/serial.c to use a newer version of qmk_firmware standard GPIO control macro.
BorisTestov pushed a commit to BorisTestov/qmk_firmware that referenced this pull request May 23, 2024
* A little easier to read the definition of the GPIO control macro for AVR.

No change in build result.

* Changed to not use GNU statement expression extension.

No change in build result.

* Modified split_common/serial.c to use qmk_firmware standard GPIO control macro.

No change in build result.

* fix PE6 -> E6

* remove some space

* add some comment to config_common.h

* Changed split_common/serial.c to use a newer version of qmk_firmware standard GPIO control macro.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants