-
Notifications
You must be signed in to change notification settings - Fork 3k
InterruptIn rise/fall methods overwrite pullup/pulldown mode for STM32F4 targets #2638
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
Comments
hi - I can have a look at it |
I think if we save the gpio mode inside the gpio_t structure and reuse it after in the gpio_irq_set function it should work... |
unfortunately gpio_irq_set is using a gpio_irq_t object, not the gpio_t one ... the common point being the assigned "pin" ... I'll look into this further tomorrow |
@LMESTM, any updates on this? |
This function reads the pull mode from HW and can then be used to avoid over-writing the previously set pull-up / pull-down modes. This is done following reported issue: ARMmbed#2638
This way the pull-up / pull-down modes would not be overwritten as first reported in issue ARMmbed#2638
@andreaslarssonublox I hope you'll agree that this is better late than never ? ;-) |
This function reads the pull mode from HW and can then be used to avoid over-writing the previously set pull-up / pull-down modes. This is done following reported issue: #2638
This way the pull-up / pull-down modes would not be overwritten as first reported in issue #2638
This applies the same fix as was done for F4 to solve issue ARMmbed#2638. The fix applies ell to all other families excpet STM32F1. Basically, to avoid over-writing the pull-up/-down settings, we read the current state from HW.
This fix addresses issue ARMmbed#2638 for STM32F1. The STM32F1 family has a diffeerent register set for pull-up and pull-down settings. The same principle to read HW state is applied, as in commit: [STM32] Fix pull over write to all families except registers are different. Also in this patch we make code a bit more linear. Depending on pin_index, different register and shift index must be used. Instead of checking this in several place, let's make a check at the beginning of the function and use local register and shift variables.
This applies the same fix as was done for F4 to solve issue #2638. The fix applies ell to all other families excpet STM32F1. Basically, to avoid over-writing the pull-up/-down settings, we read the current state from HW.
This fix addresses issue #2638 for STM32F1. The STM32F1 family has a diffeerent register set for pull-up and pull-down settings. The same principle to read HW state is applied, as in commit: [STM32] Fix pull over write to all families except registers are different. Also in this patch we make code a bit more linear. Depending on pin_index, different register and shift index must be used. Instead of checking this in several place, let's make a check at the beginning of the function and use local register and shift variables.
I think this issue can be closed. |
Thanks @bcostm! |
…..4a3c5c5 4a3c5c5 Merge remote-tracking branch 'origin/release_internal' into release_external 2b8d2e1 Do not reset radio when MAC data request timeouts (ARMmbed#2647) 95c506a Frame counters for nw keys are now stored to NVM only after send key is set (ARMmbed#2641) 3b3010a Adjusted stagger random to [min,min+max] and for small nw set the stagger value to 10 seconds 02bc33a Adjusted security protocol (EAP-TLS,4WH,2WH) retry timers eb26726 High Priority timestamp compare overflow support fix. 928723a FHSS WS: Initialize broadcast channel count when enabling FHSS (ARMmbed#2642) 6040d70 Updated change log 667b191 Changed initial EAPOL-key retries from trickle to exponential backup d925145 Add RTT calculation for DHCP Time calculation 0b82953 Traceroute bug fix. 04de6e2 Merge pull request ARMmbed#2638 from PelionIoT/mbed_os_fix_ufsi_calculation 2012347 Fixed FHSS UFSI calculation unit tests 436f16e Handle timer rollover in calculate_ufsi 411cf5c coding style d6f4421 Correct ufsi timing calculation 560619d Add network time vendor data element to DHCPv6 reply message 6d290dc System time read/write callbacks (ARMmbed#2637) 7905df6 Restart or remove transmission when MAC data request timeouts (ARMmbed#2636) c97695c Bug fix: EAPOL parent compare fix e283e62 Fixed channel mask usage with OFDM configurations (ARMmbed#2633) 24168f8 Do not send too old packets (ARMmbed#2632) dbd83be Fix copyrights (ARMmbed#2631) 7f0cffd Merge pull request ARMmbed#2630 from PelionIoT/use_pelion_copyright 511bd5a Corrected coding style 57ec028 Corrected comparison 7d853de When EAPOL waiting queue is full oldest entry is removed acf580f Update copyright in changed MDNS files 933c0bb Update copyright 3aeb2af Statistics for data request latencies (ARMmbed#2629) 3f7eae6 EAPOL FHSS temp entry discover 5200b66 DHCP time elapsed time write fix. 0536874 Removed empty EAPOL-key message send after 4WH completion to nodes on relay 8a2a683 Fixed DHCP wrong time elapsed value write. 283f2ee DHCPv6 update: 99be778 EAPOL temp neighbour update 4f9e3d1 Adaptation layer to remove oldest packet first 20f1f64 Added ignoring of retry messages from RADIUS server when waiting EAP-TLS 8a8b407 Add RSL check for ETX Calculation for RPL parent selection c05e1da Fix DHCP server Uninitialized memory read 77229ee Fix CPP error from domain prefix check 7e47889 support filtering of EAPOL parents based device-min-sens configuration 618a191 Wi-SUN Expedite forward state update 4371462 Fix NULL read from RPL header addition 7802c7e Update CHANGELOG.md b2c8104 CHANGELOG for Nanostack v13.0.0 (ARMmbed#2615) git-subtree-dir: features/nanostack/sal-stack-nanostack git-subtree-split: 4a3c5c5
…903b81..4a3c5c5 4a3c5c5 Merge remote-tracking branch 'origin/release_internal' into release_external 2b8d2e1 Do not reset radio when MAC data request timeouts (ARMmbed#2647) 95c506a Frame counters for nw keys are now stored to NVM only after send key is set (ARMmbed#2641) 3b3010a Adjusted stagger random to [min,min+max] and for small nw set the stagger value to 10 seconds 02bc33a Adjusted security protocol (EAP-TLS,4WH,2WH) retry timers eb26726 High Priority timestamp compare overflow support fix. 928723a FHSS WS: Initialize broadcast channel count when enabling FHSS (ARMmbed#2642) 6040d70 Updated change log 667b191 Changed initial EAPOL-key retries from trickle to exponential backup d925145 Add RTT calculation for DHCP Time calculation 0b82953 Traceroute bug fix. 04de6e2 Merge pull request ARMmbed#2638 from PelionIoT/mbed_os_fix_ufsi_calculation 2012347 Fixed FHSS UFSI calculation unit tests 436f16e Handle timer rollover in calculate_ufsi 411cf5c coding style d6f4421 Correct ufsi timing calculation 560619d Add network time vendor data element to DHCPv6 reply message 6d290dc System time read/write callbacks (ARMmbed#2637) 7905df6 Restart or remove transmission when MAC data request timeouts (ARMmbed#2636) c97695c Bug fix: EAPOL parent compare fix e283e62 Fixed channel mask usage with OFDM configurations (ARMmbed#2633) 24168f8 Do not send too old packets (ARMmbed#2632) dbd83be Fix copyrights (ARMmbed#2631) 7f0cffd Merge pull request ARMmbed#2630 from PelionIoT/use_pelion_copyright 511bd5a Corrected coding style 57ec028 Corrected comparison 7d853de When EAPOL waiting queue is full oldest entry is removed acf580f Update copyright in changed MDNS files 933c0bb Update copyright 3aeb2af Statistics for data request latencies (ARMmbed#2629) 3f7eae6 EAPOL FHSS temp entry discover 5200b66 DHCP time elapsed time write fix. 0536874 Removed empty EAPOL-key message send after 4WH completion to nodes on relay 8a2a683 Fixed DHCP wrong time elapsed value write. 283f2ee DHCPv6 update: 99be778 EAPOL temp neighbour update 4f9e3d1 Adaptation layer to remove oldest packet first 20f1f64 Added ignoring of retry messages from RADIUS server when waiting EAP-TLS 8a8b407 Add RSL check for ETX Calculation for RPL parent selection c05e1da Fix DHCP server Uninitialized memory read 77229ee Fix CPP error from domain prefix check 7e47889 support filtering of EAPOL parents based device-min-sens configuration 618a191 Wi-SUN Expedite forward state update 4371462 Fix NULL read from RPL header addition 7802c7e Update CHANGELOG.md b2c8104 CHANGELOG for Nanostack v13.0.0 (ARMmbed#2615) git-subtree-dir: connectivity/nanostack/sal-stack-nanostack git-subtree-split: 4a3c5c5
…903b81..4a3c5c5 4a3c5c5 Merge remote-tracking branch 'origin/release_internal' into release_external 2b8d2e1 Do not reset radio when MAC data request timeouts (ARMmbed#2647) 95c506a Frame counters for nw keys are now stored to NVM only after send key is set (ARMmbed#2641) 3b3010a Adjusted stagger random to [min,min+max] and for small nw set the stagger value to 10 seconds 02bc33a Adjusted security protocol (EAP-TLS,4WH,2WH) retry timers eb26726 High Priority timestamp compare overflow support fix. 928723a FHSS WS: Initialize broadcast channel count when enabling FHSS (ARMmbed#2642) 6040d70 Updated change log 667b191 Changed initial EAPOL-key retries from trickle to exponential backup d925145 Add RTT calculation for DHCP Time calculation 0b82953 Traceroute bug fix. 04de6e2 Merge pull request ARMmbed#2638 from PelionIoT/mbed_os_fix_ufsi_calculation 2012347 Fixed FHSS UFSI calculation unit tests 436f16e Handle timer rollover in calculate_ufsi 411cf5c coding style d6f4421 Correct ufsi timing calculation 560619d Add network time vendor data element to DHCPv6 reply message 6d290dc System time read/write callbacks (ARMmbed#2637) 7905df6 Restart or remove transmission when MAC data request timeouts (ARMmbed#2636) c97695c Bug fix: EAPOL parent compare fix e283e62 Fixed channel mask usage with OFDM configurations (ARMmbed#2633) 24168f8 Do not send too old packets (ARMmbed#2632) dbd83be Fix copyrights (ARMmbed#2631) 7f0cffd Merge pull request ARMmbed#2630 from PelionIoT/use_pelion_copyright 511bd5a Corrected coding style 57ec028 Corrected comparison 7d853de When EAPOL waiting queue is full oldest entry is removed acf580f Update copyright in changed MDNS files 933c0bb Update copyright 3aeb2af Statistics for data request latencies (ARMmbed#2629) 3f7eae6 EAPOL FHSS temp entry discover 5200b66 DHCP time elapsed time write fix. 0536874 Removed empty EAPOL-key message send after 4WH completion to nodes on relay 8a2a683 Fixed DHCP wrong time elapsed value write. 283f2ee DHCPv6 update: 99be778 EAPOL temp neighbour update 4f9e3d1 Adaptation layer to remove oldest packet first 20f1f64 Added ignoring of retry messages from RADIUS server when waiting EAP-TLS 8a8b407 Add RSL check for ETX Calculation for RPL parent selection c05e1da Fix DHCP server Uninitialized memory read 77229ee Fix CPP error from domain prefix check 7e47889 support filtering of EAPOL parents based device-min-sens configuration 618a191 Wi-SUN Expedite forward state update 4371462 Fix NULL read from RPL header addition 7802c7e Update CHANGELOG.md b2c8104 CHANGELOG for Nanostack v13.0.0 (ARMmbed#2615) git-subtree-dir: connectivity/nanostack/sal-stack-nanostack git-subtree-split: 4a3c5c5
…..4a3c5c5 4a3c5c5 Merge remote-tracking branch 'origin/release_internal' into release_external 2b8d2e1 Do not reset radio when MAC data request timeouts (ARMmbed#2647) 95c506a Frame counters for nw keys are now stored to NVM only after send key is set (ARMmbed#2641) 3b3010a Adjusted stagger random to [min,min+max] and for small nw set the stagger value to 10 seconds 02bc33a Adjusted security protocol (EAP-TLS,4WH,2WH) retry timers eb26726 High Priority timestamp compare overflow support fix. 928723a FHSS WS: Initialize broadcast channel count when enabling FHSS (ARMmbed#2642) 6040d70 Updated change log 667b191 Changed initial EAPOL-key retries from trickle to exponential backup d925145 Add RTT calculation for DHCP Time calculation 0b82953 Traceroute bug fix. 04de6e2 Merge pull request ARMmbed#2638 from PelionIoT/mbed_os_fix_ufsi_calculation 2012347 Fixed FHSS UFSI calculation unit tests 436f16e Handle timer rollover in calculate_ufsi 411cf5c coding style d6f4421 Correct ufsi timing calculation 560619d Add network time vendor data element to DHCPv6 reply message 6d290dc System time read/write callbacks (ARMmbed#2637) 7905df6 Restart or remove transmission when MAC data request timeouts (ARMmbed#2636) c97695c Bug fix: EAPOL parent compare fix e283e62 Fixed channel mask usage with OFDM configurations (ARMmbed#2633) 24168f8 Do not send too old packets (ARMmbed#2632) dbd83be Fix copyrights (ARMmbed#2631) 7f0cffd Merge pull request ARMmbed#2630 from PelionIoT/use_pelion_copyright 511bd5a Corrected coding style 57ec028 Corrected comparison 7d853de When EAPOL waiting queue is full oldest entry is removed acf580f Update copyright in changed MDNS files 933c0bb Update copyright 3aeb2af Statistics for data request latencies (ARMmbed#2629) 3f7eae6 EAPOL FHSS temp entry discover 5200b66 DHCP time elapsed time write fix. 0536874 Removed empty EAPOL-key message send after 4WH completion to nodes on relay 8a2a683 Fixed DHCP wrong time elapsed value write. 283f2ee DHCPv6 update: 99be778 EAPOL temp neighbour update 4f9e3d1 Adaptation layer to remove oldest packet first 20f1f64 Added ignoring of retry messages from RADIUS server when waiting EAP-TLS 8a8b407 Add RSL check for ETX Calculation for RPL parent selection c05e1da Fix DHCP server Uninitialized memory read 77229ee Fix CPP error from domain prefix check 7e47889 support filtering of EAPOL parents based device-min-sens configuration 618a191 Wi-SUN Expedite forward state update 4371462 Fix NULL read from RPL header addition 7802c7e Update CHANGELOG.md b2c8104 CHANGELOG for Nanostack v13.0.0 (ARMmbed#2615) git-subtree-dir: features/nanostack/sal-stack-nanostack git-subtree-split: 4a3c5c5
The gpio_irq_set function calls pin_function with GPIO_NOPULL.
The code below was used to generate the issue on an STM32F429i-DISCO board using the DISCO_F429ZI target. If the mode method is called after rise/fall it works as expected.
`
include <stdio.h>
include <string.h>
include "mbed.h"
InterruptIn button(PF_2);
DigitalOut led1(LED1);
DigitalOut led2(LED2);
void handleRise() {
led1 = 1;
led2 = 0;
}
void handleFall() {
led1 = 0;
led2 = 1;
}
int main() {
button.mode(PullUp); // Set PF_2 to pullup. GPIOF->PUPDR=0x00000010 -> OK
button.rise(&handleRise); // Will overwrite the mode. GPIOF->PUPDR=0x00000000 -> Not OK
button.fall(&handleFall); // Will overwrite the mode. GPIOF->PUPDR=0x00000000 -> Not OK
while (1) {
wait(0.25);
}
}
`
The text was updated successfully, but these errors were encountered: