X-Git-Url: https://git.rohieb.name/hackover2013-badge-firmware.git/blobdiff_plain/3c19c7c8bd6b8c4d47bb3acba9e5b0ab2abe6a53..1ab16aec62e20065faba56c469ddf75830860162:/core/gpio/gpio.c?ds=sidebyside diff --git a/core/gpio/gpio.c b/core/gpio/gpio.c index 89e4c95..2f03e9a 100644 --- a/core/gpio/gpio.c +++ b/core/gpio/gpio.c @@ -227,88 +227,6 @@ void gpioSetDir (uint32_t portNum, uint32_t bitPos, gpioDirection_t dir) dir == gpioDirection_Output ? (*gpiodir |= (1 << bitPos)) : (*gpiodir &= ~(1 << bitPos)); } -/**************************************************************************/ -/*! - @brief Gets the value for a specific port pin - - @param[in] portNum - The port number (0..3) - @param[in] bitPos - The bit position (0..31) - - @return The current value for the specified port pin (0..1) -*/ -/**************************************************************************/ -uint32_t gpioGetValue (uint32_t portNum, uint32_t bitPos) -{ - if (!_gpioInitialised) gpioInit(); - - uint32_t value = 0; - - switch (portNum) - { - case 0: - value = (GPIO_GPIO0DATA & (1 << bitPos)) ? 1 : 0; - break; - case 1: - value = (GPIO_GPIO1DATA & (1 << bitPos)) ? 1 : 0; - break; - case 2: - value = (GPIO_GPIO2DATA & (1 << bitPos)) ? 1 : 0; - break; - case 3: - value = (GPIO_GPIO3DATA & (1 << bitPos)) ? 1 : 0; - break; - default: - break; - } - - return value; -} - -/**************************************************************************/ -/*! - @brief Sets the value for a specific port pin (only relevant when a - pin is configured as output). - - @param[in] portNum - The port number (0..3) - @param[in] bitPos - The bit position (0..31) - @param[in] bitValue - The value to set for the specified bit (0..1). 0 will set - the pin low and 1 will set the pin high. -*/ -/**************************************************************************/ -void gpioSetValue (uint32_t portNum, uint32_t bitPos, uint32_t bitVal) -{ - if (!_gpioInitialised) gpioInit(); - - // // Get the appropriate register (handled this way to optimise code size) - // REG32 *gpiodata = &GPIO_GPIO0DATA; - // switch (portNum) - // { - // case 0: - // gpiodata = &GPIO_GPIO0DATA; - // break; - // case 1: - // gpiodata = &GPIO_GPIO1DATA; - // break; - // case 2: - // gpiodata = &GPIO_GPIO2DATA; - // break; - // case 3: - // gpiodata = &GPIO_GPIO3DATA; - // break; - // } - // - // // Toggle value - // bitVal == 1 ? (*gpiodata |= (1 << bitPos)) : (*gpiodata &= ~(1 << bitPos)); - - // Take advantage of the fact the GPIO registers are bit-banded - (*(pREG32 ((GPIO_GPIO0_BASE + (portNum << 16)) + ((1 << bitPos) << 2)))) = bitVal ? 0xFFF : 0; -} - /**************************************************************************/ /*! @brief Sets the interrupt sense, event, etc. @@ -388,7 +306,7 @@ void gpioSetInterrupt (uint32_t portNum, uint32_t bitPos, gpioInterruptSense_t s *gpiois |= (0x1<