Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of nRF51822 by
Diff: nordic/nrf-sdk/nrf_gpio.h
- Revision:
- 37:c29c330d942c
- Parent:
- 0:eff01767de02
--- a/nordic/nrf-sdk/nrf_gpio.h Thu Jul 03 10:01:02 2014 +0100 +++ b/nordic/nrf-sdk/nrf_gpio.h Mon Jul 07 13:43:31 2014 +0100 @@ -1,7 +1,6 @@ #ifndef NRF_GPIO_H__ #define NRF_GPIO_H__ -#include "nordic_global.h" #include "nrf51.h" #include "nrf51_bitfields.h" @@ -91,7 +90,7 @@ NRF_GPIO->PIN_CNF[pin_range_start] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) - | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) + | (GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); } } @@ -136,7 +135,7 @@ NRF_GPIO->PIN_CNF[pin_number] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) - | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) + | (GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); } @@ -245,7 +244,19 @@ */ static __INLINE void nrf_gpio_pin_toggle(uint32_t pin_number) { - NRF_GPIO->OUT ^= (1UL << pin_number); + const uint32_t pin_bit = 1UL << pin_number; + const uint32_t pin_state = ((NRF_GPIO->OUT >> pin_number) & 1UL); + + if (pin_state == 0) + { + // Current state low, set high. + NRF_GPIO->OUTSET = pin_bit; + } + else + { + // Current state high, set low. + NRF_GPIO->OUTCLR = pin_bit; + } } /**