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

kinetis: Abstraction for PORT module #4813

Closed
wants to merge 3 commits into from

Conversation

jnohlgard
Copy link
Member

Pin configuration and alternate function handling driver for internal periph driver use, similar to stm32f0's gpio_init_af.

This PR only updates the GPIO component. I have prepared the other periph drivers as well, but need to rebase on top of the periph API changes.

@haukepetersen can we merge this first and rebase the periph changes in #4780, #4431, #4430 on top? It will save us work on the kinetis periph drivers in those PRs.

@jnohlgard jnohlgard added Platform: ARM Platform: This PR/issue effects ARM-based platforms Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Feb 14, 2016
@jnohlgard jnohlgard added this to the Release 2016.03 milestone Feb 14, 2016
@jnohlgard jnohlgard force-pushed the pr/kinetis-port-af-gpio branch from e9aed73 to 6f7ca79 Compare February 14, 2016 07:57
@jnohlgard
Copy link
Member Author

Added PWM module changes since #4638 was merged

@jnohlgard jnohlgard force-pushed the pr/kinetis-port-af-gpio branch from 6f7ca79 to 1563aa1 Compare February 14, 2016 08:22
@haukepetersen
Copy link
Contributor

Hmm, this seems still overly complicated to me, why not just make this as part of the GPIO driver, e.g. with some CPU internal function as gpio_init_af/mux or similar everything should be in order?! This is what we did for many other CPUs and I can't imagine that the kinetis are so much different...

@jnohlgard
Copy link
Member Author

I don't see what is overly complicated? The only difference between this and other CPUs is that the port_init function is inside port.c instead of gpio.c and exported so that it can be used from the other periph drivers as well instead of only from inside gpio.c.

@jnohlgard
Copy link
Member Author

ah, and the push/pull configuration. I built this on the premise that we'd need that parameter but depending on the outcome of #4750 and #4472 we might need to refactor port_init a little.

@haukepetersen
Copy link
Contributor

But why put in i'ts own module. I think there is actually no need to export functions like '_gpio_port(gpio_t dev)' or '_gpio_port(gpio_t dev)` to the other periph drivers, as these are only needed internally in the GPIO driver. This keeps the code simpler and IMHO easier to follow.

@jnohlgard
Copy link
Member Author

The idea is that the periph drivers will also use port_init to select their desired alternate functions in the mux. I don't know how to do this without exporting some new symbol or changing the current GPIO API to support an AF parameter?

@haukepetersen
Copy link
Contributor

Here is how I would envision the gpio module to look like: #4830. Only thing open is the open-drain configuration, but can be put in easily... I think #4830 looks much easier (at least to me :-))

@haukepetersen
Copy link
Contributor

so when using this from other peripheral drivers (e.g. spi/uart), you just call

gpio_ini(mosi_pin, GPIO_DIR_OUT, GPIO_NOPULL);  // adapt to changes when integrating OD mode...
gpio_init_af(mosi_pin, GPIO_AFx);

-> easy to use, and no need for the SPI driver to know anything about ports/gpio/pins in depth...

@jnohlgard
Copy link
Member Author

Closing in favour of #4830

@jnohlgard jnohlgard closed this Feb 21, 2016
@jnohlgard jnohlgard deleted the pr/kinetis-port-af-gpio branch April 6, 2017 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ARM Platform: This PR/issue effects ARM-based platforms Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants