#include "gpio.h"
#ifdef CFG_CHIBI
-#include "drivers/chibi/chb_drvr.h"
+#include "drivers/rf/chibi/chb_drvr.h"
volatile uint32_t chibi_counter = 0;
#endif
/**************************************************************************/
/*!
@brief IRQ Handler for GPIO port 0 (currently checks pin 0.1)
+
+ @note By default, this IRQ handler is probably disabled in
+ projectconfig.h (see GPIO_ENABLE_IRQ0), but you can use
+ the code below as a model to implement this interrupt
+ handler in an appropriate place in your project.
*/
/**************************************************************************/
+#if defined GPIO_ENABLE_IRQ0
void PIOINT0_IRQHandler(void)
{
uint32_t regVal;
}
return;
}
+#endif
/**************************************************************************/
/*!
@brief IRQ Handler for GPIO port 1 (currently checks pin 1.1)
*/
/**************************************************************************/
+#if defined GPIO_ENABLE_IRQ1
void PIOINT1_IRQHandler(void)
{
uint32_t regVal;
return;
}
+#endif
/**************************************************************************/
/*!
@brief IRQ Handler for GPIO port 2 (currently checks pin 2.1)
+
+ @note By default, this IRQ handler is probably disabled in
+ projectconfig.h (see GPIO_ENABLE_IRQ2), but you can use
+ the code below as a model to implement this interrupt
+ handler in an appropriate place in your project.
*/
/**************************************************************************/
+#if defined GPIO_ENABLE_IRQ2
void PIOINT2_IRQHandler(void)
{
uint32_t regVal;
}
return;
}
+#endif
/**************************************************************************/
/*!
@brief IRQ Handler for GPIO port 3 (currently checks pin 3.1)
+
+ @note By default, this IRQ handler is probably disabled in
+ projectconfig.h (see GPIO_ENABLE_IRQ3), but you can use
+ the code below as a model to implement this interrupt
+ handler in an appropriate place in your project.
*/
/**************************************************************************/
+#if defined GPIO_ENABLE_IRQ3
void PIOINT3_IRQHandler(void)
{
uint32_t regVal;
}
return;
}
+#endif
/**************************************************************************/
/*!
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));
-}
-
/**************************************************************************/
/*!
@brief Sets the interrupt sense, event, etc.
break;
}
-
if (sense == gpioInterruptSense_Edge)
{
*gpiois &= ~(0x1<<bitPos);
*gpiois |= (0x1<<bitPos);
}
- event == gpioInterruptEvent_ActiveHigh ? (*gpioiev &= ~(0x1<<bitPos)) : (*gpioiev |= (0x1<<bitPos));
+ event == gpioInterruptEvent_ActiveLow ? (*gpioiev &= ~(0x1<<bitPos)) : (*gpioiev |= (0x1<<bitPos));
return;
}