Skip to content
This repository has been archived by the owner on Apr 19, 2022. It is now read-only.

Add drivemode for alternate function #2

Merged
merged 2 commits into from Dec 22, 2017
Merged

Add drivemode for alternate function #2

merged 2 commits into from Dec 22, 2017

Conversation

ghost
Copy link

@ghost ghost commented Dec 21, 2017

Description

This permits to set a pin to an alternate function (e.g. PWM, ADC)

Motivation and Context

Will enable users to select a function other than input/output for a pin.

Types of changes

  • Improvement (non-breaking change that improves a feature, code or algorithm)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

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.
  • All new and existing tests passed.

This permits to set a pin to an alternate function (e.g. PWM, ADC)

Signed-off-by: Christophe Gerbier <christophe@mikrobusnet.org>
@nfbot
Copy link
Member

nfbot commented Dec 21, 2017

Hi @MikroBusNet,

I'm nanoFramework bot.
Thank you for your contribution!

A human will be reviewing it shortly. 😉

@CLAassistant
Copy link

CLAassistant commented Dec 21, 2017

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@josesimoes josesimoes left a comment

Choose a reason for hiding this comment

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

I'm all right with these.
Despite of it I would rather see this "changing the function of a GPIO pin to an alternate function" in a separate assembly and with general parameters so it won't depend on Gpio.

@josesimoes josesimoes merged commit 930e36b into nanoframework:develop Dec 22, 2017
@ghost
Copy link
Author

ghost commented Dec 22, 2017

"Alternate function" is one of the standard pin functions, like input or output (be it opendrain or not, pullup or pulldown and so on). Hence this location for the implementation.

It is meant to be able to assign pin functions "on the fly" as you can see on this excerpt of the STM32 doc, without having to recompile the firmware to assign the function in board.h :
image

Now you can choose the "AFx" function. "x" varying from 0 to 15, 0 being often simple GPIO.

@josesimoes
Copy link
Member

I wasn't implying that this is something awkward or trying to force anything. It's perfectly "legal"!
Was more thinking that with this implementation one has to reference the Gpio assembly (which brings the Native.Events along with) just to be able to do that.
If a specific method to set pin function would exist on the Runtime.Native assembly, for example, it would be more resource wise.

@ghost
Copy link
Author

ghost commented Dec 22, 2017

Do you know many applications that won't need Gpio ? :)
To me, if there is only one assembly that is loaded every time, this is this one ! Adding SystemInfo code (for example) only to have the opportunity of setting an alternate function of a pin is indeed a waste of ressource.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants