Skip to content

Extend GPIO mode #275

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

Closed
fpistm opened this issue Jun 29, 2018 · 5 comments · Fixed by #369
Closed

Extend GPIO mode #275

fpistm opened this issue Jun 29, 2018 · 5 comments · Fixed by #369
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@fpistm
Copy link
Member

fpistm commented Jun 29, 2018

Current mode available using pinMode() are:

  • INPUT
  • INPUT_PULLUP
  • INPUT_PULLDOWN
  • OUTPUT

Some other mode could be added as done in Arduino_STM32
At least:

  • INPUT_ANALOG
  • INPUT_FLOATING same as INPUT
  • OUTPUT_OPEN_DRAIN

Maybe AF mode.

@fpistm fpistm added the enhancement New feature or request label Jun 29, 2018
@Adminius
Copy link
Contributor

Adminius commented Jul 9, 2018

Hi @fpistm ,
it sounds interesting, but this will make STM32 core incompatible to Arduino (if anybody will port STM32 sketch to Arudino)...

INPUT_ANALOG is the "same" as analogRead
INPUT_FLOATING is the same as INPUT
OUTPUT_OPEN_DRAIN ist the same as OUTPU LOW + INPUT...

IMHO: only INPUT_PULLDOWN makes sense.

@fpistm
Copy link
Member Author

fpistm commented Jul 9, 2018

I think no, it will not make core incompatible this is just an extension. Default Arduino value are kept.
If user use it yes his sketch will be incompatible but if he use it this is probably to take benefits of STM32 features. Up to him to tag it as STM32 compatible only.

@davidanger
Copy link

davidanger commented Jul 10, 2018

What is different between INPUT, INPUT_ANALOGand INPUT_FLOATING?
I think maybe like that:
INPUT (MODER:00 PUPDR:00) as same as INPUT_FLOATING
INPUT_ANALOG (MODER:11 PUPDR:00)
Right?

@davidanger
Copy link

davidanger commented Jul 10, 2018

I think add one more OUTPUT_PULLUPorOUTPUT_OPEN_DRAIN_PULLUP (MODER:01 OTYPER:1 PUPDR:01) OpenDrain + Pullup maybe have some useful in some cases.
Can make I2C or something like that.

@fpistm
Copy link
Member Author

fpistm commented Jul 10, 2018

Right.
Why not add some new OUTPUT_* value.
Currently for some specific feature the config is get from the PeripheralPins.c
ex for ADC pin:
{PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3

where STM_PIN_DATA is used to get pin configuration coded on 32 bits:
STM PIN data as used in pin_function is coded on 32 bits as below:

    [2:0]  Function (like in MODER reg) : Input / Output / Alt / Analog
       [3]  Output Push-Pull / Open Drain (as in OTYPER reg)
    [5:4]  as in PUPDR reg: No Pull, Pull-up, Pull-Donc
    [7:6]  Reserved for speed config (as in OSPEEDR), but not used yet
  [14:8]  Alternate Num (as in AFRL/AFRG reg)
[19:15]  Channel (Analog/Timer specific)
     [20]  Inverted (Analog/Timer specific)
     [21]  Analog ADC control - Only valid for specific families
[32:22]  Reserved

See https://github.com/stm32duino/Arduino_Core_STM32/blob/master/cores/arduino/stm32/PinNamesTypes.h#L36

@fpistm fpistm self-assigned this Nov 13, 2018
@fpistm fpistm added this to the 1.5.0 milestone Nov 13, 2018
@fpistm fpistm added the on going Currently work on this label Nov 13, 2018
fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Nov 13, 2018
Fix stm32duino#275

Signed-off-by: Frederic.Pillon <[email protected]>
fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Nov 14, 2018
Fix stm32duino#275

Signed-off-by: Frederic.Pillon <[email protected]>
fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Nov 15, 2018
Fix stm32duino#275

Signed-off-by: Frederic.Pillon <[email protected]>
@fpistm fpistm removed the on going Currently work on this label Nov 16, 2018
xC0000005 pushed a commit to xC0000005/Arduino_Core_STM32 that referenced this issue Nov 27, 2018
Fix stm32duino#275

Signed-off-by: Frederic.Pillon <[email protected]>
benwaffle pushed a commit to benwaffle/Arduino_Core_STM32 that referenced this issue Apr 10, 2019
Fix stm32duino#275

Signed-off-by: Frederic.Pillon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants